Rev 263 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
256 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
4 | * OIDplus 2.0 |
||
5 | * Copyright 2019 Daniel Marschall, ViaThinkSoft |
||
6 | * |
||
7 | * Licensed under the Apache License, Version 2.0 (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 |
||
10 | * |
||
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
12 | * |
||
13 | * Unless required by applicable law or agreed to in writing, software |
||
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
16 | * See the License for the specific language governing permissions and |
||
17 | * limitations under the License. |
||
18 | */ |
||
19 | |||
20 | class OIDplusPagePublicRaBaseUtils extends OIDplusPagePluginPublic { |
||
21 | |||
22 | public function priority() { |
||
23 | return 1; |
||
24 | } |
||
25 | |||
26 | public function action(&$handled) { |
||
27 | |||
28 | // Action: delete_ra |
||
29 | // Method: POST |
||
30 | // Parameters: email |
||
31 | // Outputs: Text |
||
32 | if (isset($_POST["action"]) && ($_POST["action"] == "delete_ra")) { |
||
33 | $handled = true; |
||
34 | |||
35 | $email = $_POST['email']; |
||
36 | |||
37 | $ra_logged_in = OIDplus::authUtils()->isRaLoggedIn($email); |
||
38 | |||
39 | if (!OIDplus::authUtils()->isAdminLoggedIn() && !$ra_logged_in) { |
||
40 | throw new OIDplusException('Authentification error. Please log in.'); |
||
41 | } |
||
42 | |||
43 | if ($ra_logged_in) OIDplus::authUtils()->raLogout($email); |
||
44 | |||
45 | $ra = new OIDplusRA($email); |
||
46 | if (!$ra->existing()) { |
||
47 | throw new OIDplusException("RA '$email' does not exist."); |
||
48 | } |
||
49 | $ra->delete(); |
||
50 | $ra = null; |
||
51 | |||
52 | OIDplus::logger()->log("RA($email)?/A?", "RA '$email' deleted"); |
||
53 | |||
54 | echo json_encode(array("status" => 0)); |
||
55 | } |
||
56 | |||
57 | } |
||
58 | |||
59 | public function init($html=true) { |
||
259 | daniel-mar | 60 | // Will be used by: plugins admin-130, public-091, public-200, ra-092, ra-101 |
263 | daniel-mar | 61 | OIDplus::config()->prepareConfigKey('ra_min_password_length', 'Minimum length for RA passwords', '6', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
257 | daniel-mar | 62 | if (!is_numeric($value) || ($value < 1)) { |
63 | throw new OIDplusException("Please enter a valid password length."); |
||
64 | } |
||
263 | daniel-mar | 65 | }); |
256 | daniel-mar | 66 | } |
67 | |||
68 | public function gui($id, &$out, &$handled) { |
||
69 | } |
||
70 | |||
71 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
||
72 | } |
||
73 | |||
74 | public function tree_search($request) { |
||
75 | return false; |
||
76 | } |
||
77 | } |