Example #1
0
function set_default_settings()
{
    $settings = pl_get_global_settings();
    if (!$settings) {
        $settings = pl_settings_default();
    }
    $settings_defaults = apply_filters('pl_theme_default_settings', get_default_settings());
    $region_defaults = apply_filters('pl_theme_default_regions', array());
    if (empty($settings['draft'])) {
        $settings['draft'] = array('settings' => $settings_defaults, 'regions' => $region_defaults);
    }
    if (empty($settings['live'])) {
        $settings['live'] = array('settings' => $settings_defaults, 'regions' => $region_defaults);
    }
    pl_update_global_settings($settings);
    return $settings;
}
 /**
  * Converts a old style "qi_config.cfg" config to the new profiles.
  * Tries to write settings/main.cfg and set the QI profile cookie.
  * If the file writing fails the cookie is not set.
  * The new and old cfg file syntax is the same.
  *
  * @param array $config from qi_config.cfg
  * @return true if the profile file could not be written or false for no errors.
  */
 function convert($config)
 {
     global $quickinstall_path, $phpEx, $user;
     // First convert the numeric array to a associative array and get it into $this->config.
     $this->set_config_array($config);
     // check for config fields added or changed since the "old" style.
     include "{$quickinstall_path}includes/default_settings.{$phpEx}";
     $new_config = get_default_settings();
     foreach ($new_config as $key => $value) {
         if (empty($this->config[$key])) {
             $this->config[$key] = $value;
         } else {
             if (gettype($this->config[$key]) !== gettype($value)) {
                 $this->config[$key] = $value;
             }
         }
     }
     // The config array needs to be converted to a string.
     $this->profile = 'default';
     if ($this->update() !== false) {
         $this->set_profile_cookie('default');
         $this->is_converted = true;
         $this->error[] = 'CONFIG_CONVERTED';
         return false;
     }
     return true;
 }
Example #3
0
 * @package    observium
 * @subpackage web
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
if ($_SESSION['userlevel'] < 10) {
    print_error_permission();
    return;
}
register_html_resource('js', 'clipboard.min.js');
register_html_resource('script', 'new Clipboard("#clipboard");');
// Load SQL config into $database_config
load_sqlconfig($database_config);
// cache default and config.php-defined values
$defined_config = get_defined_settings();
$default_config = get_default_settings();
echo '<form id="settings" name="settings" method="post" action="" class="form form-inline">' . PHP_EOL;
// Pretty inefficient looping everything if section != all, but meh
// This is only done on this page, so there is no performance issue for the rest of Observium
foreach ($config_subsections as $section => $subdata) {
    if (isset($config_sections[$section]['edition']) && $config_sections[$section]['edition'] != OBSERVIUM_EDITION) {
        // Skip sections not allowed for current Observium edition
        continue;
    }
    echo '  <div class="row"> <div class="col-md-12"> <!-- BEGIN SECTION ' . $section . ' -->' . PHP_EOL;
    if ($vars['section'] == 'all' || $vars['section'] == $section) {
        if ($vars['section'] == 'all') {
            // When printing all, also print the section name
            echo generate_box_open(array('title' => $config_sections[$section]['text'], 'header-border' => TRUE));
            echo generate_box_close();
        }