Rev 635 | Rev 1086 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 635 | Rev 1050 | ||
---|---|---|---|
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * OIDplus 2.0 |
4 | * OIDplus 2.0 |
5 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
6 | * |
6 | * |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | * you may not use this file except in compliance with the License. |
8 | * you may not use this file except in compliance with the License. |
9 | * You may obtain a copy of the License at |
9 | * You may obtain a copy of the License at |
10 | * |
10 | * |
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
12 | * |
12 | * |
13 | * Unless required by applicable law or agreed to in writing, software |
13 | * Unless required by applicable law or agreed to in writing, software |
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | * See the License for the specific language governing permissions and |
16 | * See the License for the specific language governing permissions and |
17 | * limitations under the License. |
17 | * limitations under the License. |
18 | */ |
18 | */ |
19 | 19 | ||
20 | if (!defined('INSIDE_OIDPLUS')) die(); |
20 | namespace ViaThinkSoft\OIDplus; |
21 | 21 | ||
22 | // TODO: should this be a different plugin type? A page without gui is weird! |
22 | // TODO: should this be a different plugin type? A page without gui is weird! |
23 | class OIDplusPagePublicRaBaseUtils extends OIDplusPagePluginPublic { |
23 | class OIDplusPagePublicRaBaseUtils extends OIDplusPagePluginPublic { |
24 | 24 | ||
25 | public function action($actionID, $params) { |
25 | public function action($actionID, $params) { |
26 | 26 | ||
27 | // Action: delete_ra |
27 | // Action: delete_ra |
28 | // Method: POST |
28 | // Method: POST |
29 | // Parameters: email |
29 | // Parameters: email |
30 | // Outputs: Text |
30 | // Outputs: Text |
31 | if ($actionID == 'delete_ra') { |
31 | if ($actionID == 'delete_ra') { |
32 | _CheckParamExists($params, 'email'); |
32 | _CheckParamExists($params, 'email'); |
33 | 33 | ||
34 | $email = $params['email']; |
34 | $email = $params['email']; |
35 | 35 | ||
36 | $ra_logged_in = OIDplus::authUtils()->isRaLoggedIn($email); |
36 | $ra_logged_in = OIDplus::authUtils()->isRaLoggedIn($email); |
37 | 37 | ||
38 | if (!OIDplus::authUtils()->isAdminLoggedIn() && !$ra_logged_in) { |
38 | if (!OIDplus::authUtils()->isAdminLoggedIn() && !$ra_logged_in) { |
39 | throw new OIDplusException(_L('Authentication error. Please log in.')); |
39 | throw new OIDplusException(_L('Authentication error. Please log in.')); |
40 | } |
40 | } |
41 | 41 | ||
42 | if ($ra_logged_in) OIDplus::authUtils()->raLogout($email); |
42 | if ($ra_logged_in) OIDplus::authUtils()->raLogout($email); |
43 | 43 | ||
44 | $ra = new OIDplusRA($email); |
44 | $ra = new OIDplusRA($email); |
45 | if (!$ra->existing()) { |
45 | if (!$ra->existing()) { |
46 | throw new OIDplusException(_L('RA "%1" does not exist.',$email)); |
46 | throw new OIDplusException(_L('RA "%1" does not exist.',$email)); |
47 | } |
47 | } |
48 | $ra->delete(); |
48 | $ra->delete(); |
49 | $ra = null; |
49 | $ra = null; |
50 | 50 | ||
51 | OIDplus::logger()->log("[?WARN/!OK]RA($email)!/[?INFO/!OK]A?", "RA '$email' deleted"); |
51 | OIDplus::logger()->log("[?WARN/!OK]RA($email)!/[?INFO/!OK]A?", "RA '$email' deleted"); |
52 | 52 | ||
53 | return array("status" => 0); |
53 | return array("status" => 0); |
54 | } else { |
54 | } else { |
55 | throw new OIDplusException(_L('Unknown action ID')); |
55 | throw new OIDplusException(_L('Unknown action ID')); |
56 | } |
56 | } |
57 | 57 | ||
58 | } |
58 | } |
59 | 59 | ||
60 | public function init($html=true) { |
60 | public function init($html=true) { |
61 | // Will be used by: plugins admin-130, public-091, public-200, ra-092, ra-101 |
61 | // Will be used by: plugins admin-130, public-091, public-200, ra-092, ra-101 |
62 | OIDplus::config()->prepareConfigKey('ra_min_password_length', 'Minimum length for RA passwords', '6', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
62 | OIDplus::config()->prepareConfigKey('ra_min_password_length', 'Minimum length for RA passwords', '6', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
63 | if (!is_numeric($value) || ($value < 1)) { |
63 | if (!is_numeric($value) || ($value < 1)) { |
64 | throw new OIDplusException(_L('Please enter a valid password length.')); |
64 | throw new OIDplusException(_L('Please enter a valid password length.')); |
65 | } |
65 | } |
66 | }); |
66 | }); |
67 | } |
67 | } |
68 | 68 | ||
69 | public function gui($id, &$out, &$handled) { |
69 | public function gui($id, &$out, &$handled) { |
70 | } |
70 | } |
71 | 71 | ||
72 | public function publicSitemap(&$out) { |
72 | public function publicSitemap(&$out) { |
73 | } |
73 | } |
74 | 74 | ||
75 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
75 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
76 | } |
76 | } |
77 | 77 | ||
78 | public function tree_search($request) { |
78 | public function tree_search($request) { |
79 | return false; |
79 | return false; |
80 | } |
80 | } |
81 | } |
81 | } |