Subversion Repositories oidplus

Rev

Rev 784 | Rev 801 | 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
5
 * Copyright 2019 - 2021 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('INSIDE_OIDPLUS')) die();
21
 
22
class OIDplusPageAdminOOBE extends OIDplusPagePluginAdmin {
23
 
24
        public function gui($id, &$out, &$handled) {
25
                // Nothing
26
        }
27
 
28
        public function oobeRequired() {
29
                $oobe_done = OIDplus::config()->getValue('oobe_main_done') == '1';
30
 
31
                foreach (OIDplus::getPagePlugins() as $plugin) {
32
                        if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.1')) {
33
                                if ($plugin->oobeRequested()) {
34
                                        $oobe_done = false;
35
                                        break;
36
                                }
37
                        }
38
                }
39
 
40
                return !$oobe_done;
41
        }
42
 
43
        public function init($html=true) {
44
                OIDplus::config()->delete('reg_wizard_done');
45
                OIDplus::config()->prepareConfigKey('oobe_main_done', '"Out Of Box Experience" wizard for the system settings done once?', '0', OIDplusConfig::PROTECTION_HIDDEN, function($value) {});
46
 
784 daniel-mar 47
                // In the OOBE, "get_challenge" of the ViaThinkSoft Captcha will raise the error:
48
                // "A plugin has requested that the initialization wizard (OOBE) is shown. Please reload the page."
49
                // So we must not continue if the referrer is OOBE.
50
                if (isset($_SERVER['HTTP_REFERER']) && (strpos($_SERVER['HTTP_REFERER'],'050_oobe/oobe.php') !== false)) return;
51
 
635 daniel-mar 52
                if ($this->oobeRequired()) {
53
                        // Show registration/configuration wizard once
54
                        if ($html) {
55
                                if (basename($_SERVER['SCRIPT_NAME']) != 'oobe.php') {
800 daniel-mar 56
                                        header('Location:'.OIDplus::webpath(__DIR__,true).'oobe.php');
635 daniel-mar 57
                                        die(_L('Redirecting to Out-Of-Box-Experience wizard...'));
58
                                }
59
                        } else {
60
                                // We cannot guarantee that everything works correctly if OOBE never ran once. So abort AJAX and co.
61
                                throw new OIDplusException(_L('A plugin has requested that the initialization wizard (OOBE) is shown. Please reload the page.'));
62
                        }
63
                }
64
        }
65
 
66
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
67
                return true;
68
        }
69
 
70
        public function tree_search($request) {
71
                return false;
72
        }
73
}