Subversion Repositories oidplus

Rev

Rev 1283 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1283 Rev 1293
Line 53... Line 53...
53
                }
53
                }
54
                return $getId ? null : false;
54
                return $getId ? null : false;
55
        }
55
        }
56
 
56
 
57
        /**
57
        /**
58
         * @param string $actionID
-
 
59
         * @param array $params
58
         * @param array $params
60
         * @return array
59
         * @return array
61
         * @throws OIDplusException
60
         * @throws OIDplusException
62
         * @throws OIDplusMailException
61
         * @throws OIDplusMailException
63
         */
62
         */
64
        public function action(string $actionID, array $params): array {
63
        private function action_Request(array $params): array {
65
                if (empty(self::getFreeRootOid(false))) throw new OIDplusException(_L('FreeOID service not available. Please ask your administrator.'));
64
                if (empty(self::getFreeRootOid(false))) throw new OIDplusException(_L('FreeOID service not available. Please ask your administrator.'));
66
 
65
 
67
                if ($actionID == 'request_freeoid') {
-
 
68
                        _CheckParamExists($params, 'email');
66
                _CheckParamExists($params, 'email');
69
                        $email = $params['email'];
67
                $email = $params['email'];
70
 
68
 
71
                        if ($already_registered_oid = $this->alreadyHasFreeOid($email, true)) {
69
                if ($already_registered_oid = $this->alreadyHasFreeOid($email, true)) {
72
                                throw new OIDplusHtmlException(_L('This email address already has a FreeOID registered (%1)', '<a '.OIDplus::gui()->link($already_registered_oid).'>'.htmlentities($already_registered_oid).'</a>'));
70
                        throw new OIDplusHtmlException(_L('This email address already has a FreeOID registered (%1)', '<a '.OIDplus::gui()->link($already_registered_oid).'>'.htmlentities($already_registered_oid).'</a>'));
Line 90... Line 88...
90
                        $message = str_replace('{{ACTIVATE_URL}}', $activate_url, $message);
88
                $message = str_replace('{{ACTIVATE_URL}}', $activate_url, $message);
91
 
89
 
92
                        OIDplus::mailUtils()->sendMail($email, OIDplus::config()->getValue('system_title').' - Free OID request', $message);
90
                OIDplus::mailUtils()->sendMail($email, OIDplus::config()->getValue('system_title').' - Free OID request', $message);
93
 
91
 
94
                        return array("status" => 0);
92
                return array("status" => 0);
-
 
93
        }
-
 
94
 
-
 
95
        /**
-
 
96
         * @param array $params
-
 
97
         * @return array
-
 
98
         * @throws OIDplusException
-
 
99
         * @throws OIDplusMailException
-
 
100
         */
-
 
101
        private function action_Activate(array $params): array {
-
 
102
                if (empty(self::getFreeRootOid(false))) throw new OIDplusException(_L('FreeOID service not available. Please ask your administrator.'));
95
 
103
 
96
                } else if ($actionID == 'activate_freeoid') {
-
 
97
                        _CheckParamExists($params, 'email');
104
                _CheckParamExists($params, 'email');
98
                        _CheckParamExists($params, 'auth');
105
                _CheckParamExists($params, 'auth');
99
 
106
 
100
                        $email = $params['email'];
107
                $email = $params['email'];
101
                        $auth = $params['auth'];
108
                $auth = $params['auth'];
Line 195... Line 202...
195
 
202
 
196
                        return array(
203
                return array(
197
                                "new_oid" => $new_oid,
204
                        "new_oid" => $new_oid,
198
                                "status" => 0
205
                        "status" => 0
199
                        );
206
                );
-
 
207
        }
-
 
208
 
-
 
209
        /**
-
 
210
         * @param string $actionID
-
 
211
         * @param array $params
-
 
212
         * @return array
-
 
213
         * @throws OIDplusException
-
 
214
         * @throws OIDplusMailException
-
 
215
         */
-
 
216
        public function action(string $actionID, array $params): array {
-
 
217
                if ($actionID == 'request_freeoid') {
-
 
218
                        return $this->action_Request($params);
-
 
219
                } else if ($actionID == 'activate_freeoid') {
-
 
220
                        return $this->action_Activate($params);
200
                } else {
221
                } else {
201
                        return parent::action($actionID, $params);
222
                        return parent::action($actionID, $params);
202
                }
223
                }
203
        }
224
        }
204
 
225