Rev 1267 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1267 | Rev 1293 | ||
---|---|---|---|
Line 25... | Line 25... | ||
25 | // phpcs:enable PSR1.Files.SideEffects |
25 | // phpcs:enable PSR1.Files.SideEffects |
26 | 26 | ||
27 | class OIDplusPagePublicRaBaseUtils extends OIDplusPagePluginPublic { |
27 | class OIDplusPagePublicRaBaseUtils extends OIDplusPagePluginPublic { |
28 | 28 | ||
29 | /** |
29 | /** |
30 | * @param string $actionID |
- | |
31 | * @param array $params |
30 | * @param array $params email |
32 | * @return array |
31 | * @return array |
33 | * @throws OIDplusException |
32 | * @throws OIDplusException |
34 | */ |
33 | */ |
35 | public function action(string $actionID, array $params): array { |
34 | private function action_Delete(array $params): array { |
- | 35 | _CheckParamExists($params, 'email'); |
|
36 | 36 | ||
37 | // Action: delete_ra |
- | |
38 | // Method: POST |
- | |
39 | // Parameters: email |
- | |
40 | // Outputs: Text |
- | |
41 | if ($actionID == 'delete_ra') { |
- | |
42 | _CheckParamExists($params, 'email'); |
37 | $email = $params['email']; |
43 | 38 | ||
44 | $email = $params['email']; |
39 | $ra_logged_in = OIDplus::authUtils()->isRaLoggedIn($email); |
45 | 40 | ||
46 | $ra_logged_in = OIDplus::authUtils()->isRaLoggedIn($email); |
41 | if (!OIDplus::authUtils()->isAdminLoggedIn() && !$ra_logged_in) { |
- | 42 | throw new OIDplusException(_L('Authentication error. Please log in.'), null, 401); |
|
- | 43 | } |
|
47 | 44 | ||
48 | if (!OIDplus::authUtils()->isAdminLoggedIn() && !$ra_logged_in) { |
45 | if ($ra_logged_in) OIDplus::authUtils()->raLogout($email); |
49 | throw new OIDplusException(_L('Authentication error. Please log in.'), null, 401); |
- | |
50 | } |
- | |
51 | 46 | ||
- | 47 | $ra = new OIDplusRA($email); |
|
- | 48 | if (!$ra->existing()) { |
|
52 | if ($ra_logged_in) OIDplus::authUtils()->raLogout($email); |
49 | throw new OIDplusException(_L('RA "%1" does not exist.',$email)); |
- | 50 | } |
|
- | 51 | $ra->delete(); |
|
- | 52 | $ra = null; |
|
53 | 53 | ||
54 | $ra = new OIDplusRA($email); |
- | |
55 | if (!$ra->existing()) { |
- | |
56 | throw new OIDplusException(_L('RA "%1" does not exist.',$email)); |
54 | OIDplus::logger()->log("V2:[OK/WARN]RA(%1)+[OK/INFO]A", "RA '%1' deleted", $email); |
57 | } |
- | |
58 | $ra->delete(); |
- | |
59 | $ra = null; |
- | |
60 | 55 | ||
61 | OIDplus::logger()->log("V2:[OK/WARN]RA(%1)+[OK/INFO]A", "RA '%1' deleted", $email); |
56 | return array("status" => 0); |
- | 57 | } |
|
62 | 58 | ||
- | 59 | /** |
|
- | 60 | * @param string $actionID |
|
- | 61 | * @param array $params |
|
- | 62 | * @return array |
|
- | 63 | * @throws OIDplusException |
|
- | 64 | */ |
|
- | 65 | public function action(string $actionID, array $params): array { |
|
- | 66 | if ($actionID == 'delete_ra') { |
|
63 | return array("status" => 0); |
67 | return $this->action_Delete($params); |
64 | } else { |
68 | } else { |
65 | return parent::action($actionID, $params); |
69 | return parent::action($actionID, $params); |
66 | } |
70 | } |
67 | - | ||
68 | } |
71 | } |
69 | 72 | ||
70 | /** |
73 | /** |
71 | * @param bool $html |
74 | * @param bool $html |
72 | * @return void |
75 | * @return void |