Subversion Repositories oidplus

Rev

Rev 373 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

  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()->deleteConfigKey('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.  
  47.                 if ($this->oobeRequired()) {
  48.                         // Show registration/configuration wizard once
  49.                         if ($html) {
  50.                                 if (basename($_SERVER['SCRIPT_NAME']) != 'oobe.php') {
  51.                                         header('Location:'.OIDplus::webpath(__DIR__).'oobe.php');
  52.                                         die(_L('Redirecting to Out-Of-Box-Experience wizard...'));
  53.                                 }
  54.                         } else {
  55.                                 // We cannot guarantee that everything works correctly if OOBE never ran once. So abort AJAX and co.
  56.                                 throw new OIDplusException(_L('A plugin has requested that the initialization wizard (OOBE) is shown. Please reload the page.'));
  57.                         }
  58.                 }
  59.         }
  60.  
  61.         public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
  62.                 return true;
  63.         }
  64.  
  65.         public function tree_search($request) {
  66.                 return false;
  67.         }
  68. }
  69.