Subversion Repositories oidplus

Rev

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