Subversion Repositories oidplus

Rev

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

Rev 1113 Rev 1116
Line 23... Line 23...
23
\defined('INSIDE_OIDPLUS') or die;
23
\defined('INSIDE_OIDPLUS') or die;
24
// phpcs:enable PSR1.Files.SideEffects
24
// phpcs:enable PSR1.Files.SideEffects
25
 
25
 
26
class OIDplusPageRaChangeEMail extends OIDplusPagePluginRa {
26
class OIDplusPageRaChangeEMail extends OIDplusPagePluginRa {
27
 
27
 
-
 
28
        /**
-
 
29
         * @param string $actionID
-
 
30
         * @param array $params
-
 
31
         * @return int[]
-
 
32
         * @throws OIDplusException
-
 
33
         * @throws OIDplusMailException
-
 
34
         */
28
        public function action($actionID, $params) {
35
        public function action(string $actionID, array $params): array {
29
                if ($actionID == 'change_ra_email') {
36
                if ($actionID == 'change_ra_email') {
30
                        if (!OIDplus::config()->getValue('allow_ra_email_change') && !OIDplus::authUtils()->isAdminLoggedIn()) {
37
                        if (!OIDplus::config()->getValue('allow_ra_email_change') && !OIDplus::authUtils()->isAdminLoggedIn()) {
31
                                throw new OIDplusException(_L('This functionality has been disabled by the administrator.'));
38
                                throw new OIDplusException(_L('This functionality has been disabled by the administrator.'));
32
                        }
39
                        }
33
 
40
 
Line 180... Line 187...
180
                        $message = str_replace('{{NEW_EMAIL}}', $new_email, $message);
187
                        $message = str_replace('{{NEW_EMAIL}}', $new_email, $message);
181
                        OIDplus::mailUtils()->sendMail($old_email, OIDplus::config()->getValue('system_title').' - eMail address changed', $message);
188
                        OIDplus::mailUtils()->sendMail($old_email, OIDplus::config()->getValue('system_title').' - eMail address changed', $message);
182
 
189
 
183
                        return array("status" => 0);
190
                        return array("status" => 0);
184
                } else {
191
                } else {
185
                        throw new OIDplusException(_L('Unknown action ID'));
192
                        return parent::action($actionID, $params);
186
                }
193
                }
187
        }
194
        }
188
 
195
 
-
 
196
        /**
-
 
197
         * @param bool $html
-
 
198
         * @return void
-
 
199
         * @throws OIDplusException
-
 
200
         */
189
        public function init($html=true) {
201
        public function init(bool $html=true) {
190
                OIDplus::config()->prepareConfigKey('max_ra_email_change_time', 'Max RA email change time in seconds (0 = infinite)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
202
                OIDplus::config()->prepareConfigKey('max_ra_email_change_time', 'Max RA email change time in seconds (0 = infinite)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
191
                        if (!is_numeric($value) || ($value < 0)) {
203
                        if (!is_numeric($value) || ($value < 0)) {
192
                                throw new OIDplusException(_L('Please enter a valid value.'));
204
                                throw new OIDplusException(_L('Please enter a valid value.'));
193
                        }
205
                        }
194
                });
206
                });
Line 197... Line 209...
197
                                throw new OIDplusException(_L('Please enter a valid value (0=no, 1=yes).'));
209
                                throw new OIDplusException(_L('Please enter a valid value (0=no, 1=yes).'));
198
                        }
210
                        }
199
                });
211
                });
200
        }
212
        }
201
 
213
 
-
 
214
        /**
-
 
215
         * @param string $id
-
 
216
         * @param array $out
-
 
217
         * @param bool $handled
-
 
218
         * @return void
-
 
219
         * @throws OIDplusException
-
 
220
         */
202
        public function gui($id, &$out, &$handled) {
221
        public function gui(string $id, array &$out, bool &$handled) {
203
                if (explode('$',$id)[0] == 'oidplus:change_ra_email') {
222
                if (explode('$',$id)[0] == 'oidplus:change_ra_email') {
204
                        $handled = true;
223
                        $handled = true;
205
 
224
 
206
                        $ra_email = explode('$',$id)[1];
225
                        $ra_email = explode('$',$id)[1];
207
 
226
 
Line 310... Line 329...
310
                                }
329
                                }
311
                        }
330
                        }
312
                }
331
                }
313
        }
332
        }
314
 
333
 
-
 
334
        /**
-
 
335
         * @param array $json
-
 
336
         * @param string|null $ra_email
-
 
337
         * @param bool $nonjs
-
 
338
         * @param string $req_goto
-
 
339
         * @return bool
-
 
340
         * @throws OIDplusException
-
 
341
         */
315
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
342
        public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
316
                if (!$ra_email) return false;
343
                if (!$ra_email) return false;
317
                if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) return false;
344
                if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) return false;
318
 
345
 
319
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
346
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
320
                        $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
347
                        $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
Line 329... Line 356...
329
                );
356
                );
330
 
357
 
331
                return true;
358
                return true;
332
        }
359
        }
333
 
360
 
-
 
361
        /**
-
 
362
         * @param string $request
-
 
363
         * @return array|false
-
 
364
         */
334
        public function tree_search($request) {
365
        public function tree_search(string $request) {
335
                return false;
366
                return false;
336
        }
367
        }
337
}
368
}