Subversion Repositories oidplus

Rev

Rev 310 | 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
 
285 daniel-mar 20
// TODO: should this be a different plugin type? A page without gui is weird!
256 daniel-mar 21
class OIDplusPagePublicRaBaseUtils extends OIDplusPagePluginPublic {
22
 
321 daniel-mar 23
        public function action($actionID, $params) {
256 daniel-mar 24
 
25
                // Action:     delete_ra
26
                // Method:     POST
27
                // Parameters: email
28
                // Outputs:    Text
321 daniel-mar 29
                if ($actionID == 'delete_ra') {
30
                        $email = $params['email'];
256 daniel-mar 31
 
32
                        $ra_logged_in = OIDplus::authUtils()->isRaLoggedIn($email);
33
 
34
                        if (!OIDplus::authUtils()->isAdminLoggedIn() && !$ra_logged_in) {
310 daniel-mar 35
                                throw new OIDplusException('Authentication error. Please log in.');
256 daniel-mar 36
                        }
37
 
38
                        if ($ra_logged_in) OIDplus::authUtils()->raLogout($email);
39
 
40
                        $ra = new OIDplusRA($email);
41
                        if (!$ra->existing()) {
42
                                throw new OIDplusException("RA '$email' does not exist.");
43
                        }
44
                        $ra->delete();
45
                        $ra = null;
46
 
288 daniel-mar 47
                        OIDplus::logger()->log("[?WARN/!OK]RA($email)!/[?INFO/!OK]A?", "RA '$email' deleted");
256 daniel-mar 48
 
49
                        echo json_encode(array("status" => 0));
321 daniel-mar 50
                } else {
51
                        throw new OIDplusException("Unknown action ID");
256 daniel-mar 52
                }
53
 
54
        }
55
 
56
        public function init($html=true) {
259 daniel-mar 57
                // Will be used by: plugins admin-130, public-091, public-200, ra-092, ra-101
263 daniel-mar 58
                OIDplus::config()->prepareConfigKey('ra_min_password_length', 'Minimum length for RA passwords', '6', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
257 daniel-mar 59
                        if (!is_numeric($value) || ($value < 1)) {
60
                                throw new OIDplusException("Please enter a valid password length.");
61
                        }
263 daniel-mar 62
                });
256 daniel-mar 63
        }
64
 
65
        public function gui($id, &$out, &$handled) {
66
        }
67
 
282 daniel-mar 68
        public function publicSitemap(&$out) {
69
        }
70
 
256 daniel-mar 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
}