Subversion Repositories oidplus

Rev

Rev 256 | 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
if (!defined('IN_OIDPLUS')) die();
21
 
22
class OIDplusPagePublicRaBaseUtils extends OIDplusPagePluginPublic {
23
 
24
        public static function getPluginInformation() {
25
                $out = array();
26
                $out['name'] = 'RA base functionality';
27
                $out['author'] = 'ViaThinkSoft';
28
                $out['version'] = null;
29
                $out['descriptionHTML'] = null;
30
                return $out;
31
        }
32
 
33
        public function priority() {
34
                return 1;
35
        }
36
 
37
        public function action(&$handled) {
38
 
39
                // Action:     delete_ra
40
                // Method:     POST
41
                // Parameters: email
42
                // Outputs:    Text
43
                if (isset($_POST["action"]) && ($_POST["action"] == "delete_ra")) {
44
                        $handled = true;
45
 
46
                        $email = $_POST['email'];
47
 
48
                        $ra_logged_in = OIDplus::authUtils()->isRaLoggedIn($email);
49
 
50
                        if (!OIDplus::authUtils()->isAdminLoggedIn() && !$ra_logged_in) {
51
                                throw new OIDplusException('Authentification error. Please log in.');
52
                        }
53
 
54
                        if ($ra_logged_in) OIDplus::authUtils()->raLogout($email);
55
 
56
                        $ra = new OIDplusRA($email);
57
                        if (!$ra->existing()) {
58
                                throw new OIDplusException("RA '$email' does not exist.");
59
                        }
60
                        $ra->delete();
61
                        $ra = null;
62
 
63
                        OIDplus::logger()->log("RA($email)?/A?", "RA '$email' deleted");
64
 
65
                        echo json_encode(array("status" => 0));
66
                }
67
 
68
        }
69
 
70
        public function init($html=true) {
257 daniel-mar 71
                OIDplus::config()->prepareConfigKey('ra_min_password_length', 'Minimum length for RA passwords', '6', 0, 1);
256 daniel-mar 72
        }
73
 
74
        public function cfgSetValue($name, $value) {
257 daniel-mar 75
                if ($name == 'ra_min_password_length') {
76
                        if (!is_numeric($value) || ($value < 1)) {
77
                                throw new OIDplusException("Please enter a valid password length.");
78
                        }
79
                }
256 daniel-mar 80
        }
81
 
82
        public function gui($id, &$out, &$handled) {
83
        }
84
 
85
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
86
        }
87
 
88
        public function tree_search($request) {
89
                return false;
90
        }
91
}