Subversion Repositories oidplus

Rev

Rev 1050 | Rev 1116 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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