/**
  * Import Settings
  *
  * @access	public
  * @return	void
  **/
 public function settings()
 {
     /* INIT */
     $vars = $this->getVars();
     $output = array();
     $errors = array();
     $knownSettings = array();
     $this->registry->class_localization->loadLanguageFile(array('admin_tools'));
     if (file_exists($this->app_full_path . 'xml/' . $vars['app_directory'] . '_settings.xml')) {
         /* Get the settings class */
         require_once IPS_ROOT_PATH . 'applications/core/modules_admin/tools/settings.php';
         $settings = new admin_core_tools_settings($this->registry);
         $settings->makeRegistryShortcuts($this->registry);
         $this->request['app_dir'] = $vars['app_directory'];
         //-----------------------------------------
         // Known settings
         //-----------------------------------------
         if (substr($this->settings['_original_base_url'], -1) == '/') {
             IPSSetUp::setSavedData('install_url', substr($this->settings['_original_base_url'], 0, -1));
         }
         if (substr($this->settings['base_dir'], -1) == '/') {
             IPSSetUp::setSavedData('install_dir', substr($this->settings['base_dir'], 0, -1));
         }
         /* Fetch known settings  */
         if (file_exists(IPSLib::getAppDir($vars['app_directory']) . '/setup/versions/install/knownSettings.php')) {
             require IPSLib::getAppDir($vars['app_directory']) . '/setup/versions/install/knownSettings.php';
         }
         $settings->importAllSettings(1, 1, $knownSettings);
         $settings->settingsRebuildCache();
     } else {
         $this->registry->output->global_message = $this->lang->words['settings_nofile'];
     }
     $output[] = $this->registry->output->global_message;
     /* Clear main messaage */
     $this->registry->output->global_message = '';
     /* Show redirect... */
     $this->showRedirectScreen($vars['app_directory'], $output, $errors, $this->getNextURL('hooks', $vars));
 }
 /**
  * Installs Settings schematic
  *
  * @return void
  */
 public function install_settings()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $previous = $_REQUEST['previous'];
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $next = IPSSetUp::fetchNextApplication($previous, '{app}_settings.xml');
     /* Set up DB driver */
     $extra_install = $this->_setUpDBDriver(FALSE);
     //-----------------------------------------
     // Install settings
     //-----------------------------------------
     if ($next['key']) {
         $output[] = $next['title'] . ": Inserting settings...";
         $_PATH = IPSLib::getAppDir($next['key']) . '/xml/';
         $knownSettings = array();
         if (file_exists($_PATH . $next['key'] . '_settings.xml')) {
             //-----------------------------------------
             // Adjust the table?
             //-----------------------------------------
             if ($extra_install and method_exists($extra_install, 'before_inserts_run')) {
                 $q = $extra_install->before_inserts_run('settings');
             }
             //-----------------------------------------
             // Continue
             //-----------------------------------------
             require_once IPS_ROOT_PATH . 'applications/core/modules_admin/tools/settings.php';
             $settings = new admin_core_tools_settings();
             $settings->makeRegistryShortcuts($this->registry);
             $this->request['app_dir'] = $next['key'];
             //-----------------------------------------
             // Known settings
             //-----------------------------------------
             if (substr(IPSSetUp::getSavedData('install_url'), -1) == '/') {
                 IPSSetUp::setSavedData('install_url', substr(IPSSetUp::getSavedData('install_url'), 0, -1));
             }
             if (substr(IPSSetUp::getSavedData('install_dir'), -1) == '/') {
                 IPSSetUp::setSavedData('install_dir', substr(IPSSetUp::getSavedData('install_dir'), 0, -1));
             }
             /* Fetch known settings  */
             if (file_exists(IPSLib::getAppDir($next['key']) . '/setup/versions/install/knownSettings.php')) {
                 require IPSLib::getAppDir($next['key']) . '/setup/versions/install/knownSettings.php';
             }
             $this->request['app_dir'] = $next['key'];
             $settings->importAllSettings(1, 1, $knownSettings);
             //-----------------------------------------
             // Adjust the table?
             //-----------------------------------------
             if ($extra_install and method_exists($extra_install, 'after_inserts_run')) {
                 $q = $extra_install->after_inserts_run('settings');
             }
         }
         //-----------------------------------------
         // Done.. so get some more!
         //-----------------------------------------
         $this->_finishStep($output, "Install: Settings", 'install&do=settings&previous=' . $next['key']);
     } else {
         //-----------------------------------------
         // Next...
         //-----------------------------------------
         $output[] = "All settings installed";
         $this->_finishStep($output, "Install: Settings", 'install&do=templates');
     }
 }
 /**
  * Add Settings
  * 
  * @access	public
  * @param	int
  */
 public function addSettings()
 {
     /* INIT */
     $known = array();
     $apps = array();
     /* Grab all known settings */
     $this->DB->build(array('select' => '*', 'from' => 'conf_settings'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         if ($row['conf_value'] != '') {
             $known[$row['conf_key']] = $row['conf_value'];
         }
     }
     /* Brandon's bug report thingy #12516*/
     if (!$known['gb_char_set']) {
         /* No charset, set - so we need to now ensure that iso-8859-1 is set */
         $known['gb_char_set'] = 'iso-8859-1';
     }
     /* Wipe out custom time/date settings */
     foreach (array('clock_short', 'clock_long', 'clock_tiny', 'clock_date', 'clock_joined', 'time_use_relative_format') as $setting) {
         unset($known[$setting]);
     }
     /* Now we need to fix moderator groups who have permission to RC */
     $groups = array();
     $this->DB->build(array('select' => 'g_id', 'from' => 'groups', 'where' => 'g_access_cp=1 OR g_is_supmod=1'));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $groups[] = $r['g_id'];
     }
     $known['report_mod_group_access'] = implode(',', $groups);
     /* Load apps */
     $this->DB->build(array('select' => '*', 'from' => 'core_applications'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $apps[$row['app_directory']] = $row;
     }
     /* Add 'em */
     foreach ($apps as $dir => $data) {
         if (file_exists(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_settings.xml')) {
             require_once IPS_ROOT_PATH . 'applications/core/modules_admin/tools/settings.php';
             $settings = new admin_core_tools_settings();
             $settings->makeRegistryShortcuts($this->registry);
             $this->request['app_dir'] = $dir;
             $settings->importAllSettings(1, 1, $known);
             $this->registry->output->addMessage("Added settings for {$data['app_title']}....");
         }
     }
     /* Next Page */
     $this->request['workact'] = 'profile';
 }
 /**
  * Installs Settings schematic
  *
  * @return void
  */
 public function install_settings()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $previous = $_REQUEST['previous'];
     //-----------------------------------------
     // Fetch next 'un
     //-----------------------------------------
     $next = IPSSetUp::fetchNextApplication($previous, '{app}_settings.xml');
     //-----------------------------------------
     // Install settings
     //-----------------------------------------
     if ($next['key']) {
         $output[] = $next['title'] . ": Upgrading settings...";
         $_PATH = IPSLib::getAppDir($next['key']) . '/xml/';
         if (file_exists($_PATH . $next['key'] . '_settings.xml')) {
             //-----------------------------------------
             // Continue
             //-----------------------------------------
             require_once IPS_ROOT_PATH . 'applications/core/modules_admin/tools/settings.php';
             $settings = new admin_core_tools_settings();
             $settings->makeRegistryShortcuts($this->registry);
             $this->request['app_dir'] = $next['key'];
             //-----------------------------------------
             // Known settings
             //-----------------------------------------
             if (substr(IPSSetUp::getSavedData('install_url'), -1) == '/') {
                 IPSSetUp::setSavedData('install_url', substr(IPSSetUp::getSavedData('install_url'), 0, -1));
             }
             if (substr(IPSSetUp::getSavedData('install_dir'), -1) == '/') {
                 IPSSetUp::setSavedData('install_dir', substr(IPSSetUp::getSavedData('install_dir'), 0, -1));
             }
             /* Fetch known settings  */
             if (file_exists(IPSLib::getAppDir($next['key']) . '/setup/versions/install/knownSettings.php')) {
                 require IPSLib::getAppDir($next['key']) . '/setup/versions/install/knownSettings.php';
             }
             $settings->importAllSettings(1, 1, $knownSettings);
         }
         //-----------------------------------------
         // Done.. so get some more!
         //-----------------------------------------
         $this->_finishStep($output, "Upgrade: " . $next['title'] . " Settings", 'upgrade&do=settings&previous=' . $next['key']);
     } else {
         //-----------------------------------------
         // Next...
         //-----------------------------------------
         $output[] = "All settings upgraded";
         $this->_finishStep($output, "Upgrade: Settings", 'upgrade&do=templates');
     }
 }