Falko Timme
2013-10-18 2d2fd172e1548dd24e1719accd0b856cff6a31a0
interface/web/admin/system_config_edit.php
@@ -50,6 +50,7 @@
class page_action extends tform_actions {
   //var $_js_changed = false;
   function onShowEdit() {
      global $app, $conf;
@@ -75,6 +76,24 @@
      $record['warning'] = $app->tform->lng('warning');
      $record['id'] = $this->id;
      $app->tpl->setVar($record);
   }
   function onShowEnd() {
      global $app, $conf;
      // available dashlets
      $available_dashlets_txt = '';
      $handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets');
      while ($file = @readdir ($handle)) {
         if ($file != '.' && $file != '..' && !is_dir($file)) {
            $available_dashlets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.substr($file,0,-4).']<pre class="addPlaceholderContent" style="display:none;">['.substr($file,0,-4).'],</pre></a> ';
         }
      }
      if($available_dashlets_txt == '') $available_dashlets_txt = '------';
      $app->tpl->setVar("available_dashlets_txt",$available_dashlets_txt);
      parent::onShowEnd();
   }
   
    function onSubmit() {
@@ -105,6 +124,22 @@
      $section = $app->tform->getCurrentTab();
      
      $server_config_array = $app->getconf->get_global_config();
      foreach($app->tform->formDef['tabs'][$section]['fields'] as $key => $field) {
         if ($field['formtype'] == 'CHECKBOX') {
            if($this->dataRecord[$key] == '') {
               // if a checkbox is not set, we set it to the unchecked value
               $this->dataRecord[$key] = $field['value'][0];
            }
         }
      }
      /*
      if((isset($this->dataRecord['use_loadindicator']) && $this->dataRecord['use_loadindicator'] != $server_config_array[$section]['use_loadindicator']) || (isset($this->dataRecord['use_combobox']) && $this->dataRecord['use_combobox'] != $server_config_array[$section]['use_combobox'])){
         $this->_js_changed = true;
      }
      */
      $new_config = $app->tform->encode($this->dataRecord,$section);
        if($section == 'sites' && $new_config['vhost_subdomains'] != 'y' && $server_config_array['vhost_subdomains'] == 'y') {
            // check for existing vhost subdomains, if found the mode cannot be disabled
@@ -118,8 +153,9 @@
        $server_config_array[$section] = $new_config;
      $server_config_str = $app->ini_parser->get_ini_string($server_config_array);
      
      $sql = "UPDATE sys_ini SET config = '".$app->db->quote($server_config_str)."' WHERE sysini_id = 1";
      if($conf['demo_mode'] != true) $app->db->query($sql);
      //$sql = "UPDATE sys_ini SET config = '".$app->db->quote($server_config_str)."' WHERE sysini_id = 1";
      //if($conf['demo_mode'] != true) $app->db->query($sql);
      if($conf['demo_mode'] != true) $app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($server_config_str)."'", 'sysini_id', 1);
      /*
       * If we should use the domain-module, we have to insert all existing domains into the table
@@ -146,6 +182,17 @@
      }
   }
   
   /*
   function onAfterUpdate() {
        if($this->_js_changed == true) {
            // not the best way, but it works
            header('Content-Type: text/html');
            print '<script type="text/javascript">document.location.reload(true);</script>';
            exit;
        }
    }
   */
}
$app->tform_actions = new page_action;