/**
  * Tests de get/set avec des valeurs spéciales
  */
 public function testSpecialValues()
 {
     CopixConfig::set('copixtest|test', 'fooValue avec des \' " / / \\ ');
     $this->assertEquals(CopixConfig::get('copixtest|test'), 'fooValue avec des \' " / / \\ ');
     CopixConfig::get('copixtest|test');
     CopixConfig::set('copixtest|test', 'foo');
     $this->assertEquals(CopixConfig::get('copixtest|testSpecial'), "mon\\chemin\\et\\sous\\chemin");
 }
 /**
  * apply updates
  */
 function doValid()
 {
     if (isset($this->vars['idFirst']) && isset($this->vars['idSecond']) && isset($this->vars['value']) && CopixConfig::exists($this->vars['idFirst'] . '|' . $this->vars['idSecond'])) {
         $this->vars['id'] = $this->vars['idFirst'] . '|' . $this->vars['idSecond'];
         CopixConfig::set($this->vars['id'], $this->vars['value']);
     }
     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('parameters||', array('choiceModule' => $this->vars['choiceModule'])));
 }
 /**
  * Vide la table des configurations sauf exceptions
  *
  * @author Frederic Mossmann <*****@*****.**>
  * @since 2007/01/19
  */
 public function clearConfDB()
 {
     $sauvegarde = array('kernel|jeuEssaiInstalled');
     $saved_data = array();
     reset($sauvegarde);
     foreach ($sauvegarde as $saved_key) {
         if (CopixConfig::exists($saved_key)) {
             $saved_data[$saved_key] = CopixConfig::get($saved_key);
         }
     }
     $sql = "DELETE FROM copixconfig";
     _doQuery($sql);
     foreach ($saved_data as $saved_key => $saved_val) {
         CopixConfig::set($saved_key, $saved_val);
     }
 }
 /**
  * Définition du thème à utiliser
  */
 public function processDoSelectTheme()
 {
     $theme = _request('id_ctpt', null, true);
     CopixConfig::set('defaultThemeId', $theme);
     return _arRedirect(_url('admin|themes|'));
 }
 /**
  * Applique les changements sur le paramètre
  */
 public function processValid()
 {
     CopixRequest::assert('idFirst', 'idSecond', 'value');
     // si la config existe bien
     if (CopixConfig::exists(CopixRequest::get('idFirst') . '|' . CopixRequest::get('idSecond'))) {
         // initialisation de variables
         $id = CopixRequest::get('idFirst') . '|' . CopixRequest::get('idSecond');
         $params = CopixConfig::getParams(CopixRequest::get('idFirst'));
         $config = $params[$id];
         $value = CopixRequest::get('value');
         $error = false;
         // type int
         if ($config['Type'] == 'int') {
             // chiffre invalide
             if ((string) intval($value) != (string) $value) {
                 $error = 'typeInt';
                 // chiffre trop petit
             } elseif (!is_null($config['MinValue']) && $config['MinValue'] > intval($value)) {
                 $error = 'typeIntMin';
                 // chiffre trop grand
             } elseif (!is_null($config['MaxValue']) && $config['MaxValue'] < intval($value)) {
                 $error = 'typeIntMax';
             }
             // type email
         } elseif ($config['Type'] == 'email') {
             // email invalide
             try {
                 CopixFormatter::getMail($value);
             } catch (CopixException $e) {
                 $error = 'typeEmail';
             }
             // e-mail trop long
             if (!is_null($config['MaxLength']) && strlen($value) > $config['MaxLength']) {
                 $error = 'typeEmailMax';
             }
             // type text
         } elseif ($config['Type'] == 'text') {
             // texte trop long
             if (!is_null($config['MaxLength']) && strlen($value) > $config['MaxLength']) {
                 $error = 'typeTextMax';
             }
         }
         // si il y a eu une erreur
         if ($error !== false) {
             return _arRedirect(_url('admin|parameters|', array('choiceModule' => CopixRequest::get('choiceModule'), 'editParam' => CopixRequest::get('idSecond'), 'error' => $error)));
         }
         // modification de la config
         CopixConfig::set($id, $value);
     }
     return _arRedirect(_url('admin|parameters|', array('choiceModule' => CopixRequest::get('choiceModule'))));
 }
 /**
  * Lister les questions réponses utilisé pour les captcha
  */
 public function processListCaptcha()
 {
     $ppo = new CopixPPO();
     if (_request('status') !== null) {
         CopixConfig::set('comments|captcha', _request('status'));
     }
     $ppo->TITLE_PAGE = _i18n('comments.admin.captchalist');
     $ppo->arrCaptcha = _ioDAO('commentscaptcha')->findall();
     $ppo->boolCaptcha = CopixConfig::get('comments|captcha');
     return _arPPO($ppo, 'captcha.list.tpl');
 }
 /**
  * Set the home page of the web site
  */
 public function processsetHomePage()
 {
     if (_request('id') !== null) {
         CopixConfig::set('|homePage', _url('cms|default|get', array('id' => CopixRequest::get('id'), 'online' => 'true')));
     } elseif (($url = CopixRequest::get('urlinput')) !== null) {
         CopixConfig::set('|homePage', $url);
     } else {
         return CopixActionGroup::process('generictools|Messages::getError', array('message' => _i18n('error|error.specifyid'), 'back' => _url('admin||')));
     }
     return _arRedirect(_url('admin||'));
 }
 /**
  * Set the home page of the web site
  * @param $this->vars['id'] the page id for the home page.
  */
 function setHomePage()
 {
     if (!isset($this->vars['id'])) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('error|error.specifyid'), 'back' => 'index.php?module=install&desc=install'));
     }
     CopixConfig::set('|homePage', CopixUrl::get('cms|default|get', array('id' => $this->vars['id'], 'online' => 'true')));
     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('install|install|getAdmin'));
 }
 /**
  * Installe le jeu d'essai
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/10/26
  */
 public function processInstall()
 {
     global $params;
     $db = new Demo_DB();
     $tools = new Demo_Tools();
     $db->extract_db_infos();
     $db->db_connect();
     $fileSQL = '../instal/demo/jeu_essai.sql';
     $errors = array();
     if (CopixConfig::get('kernel|jeuEssaiInstalled') == 1) {
         $errors[] = CopixI18N::get('sysutils|demo.error.alreadyInstalled');
     } elseif (!is_file($fileSQL)) {
         $errors[] = CopixI18N::get('sysutils|demo.error.noFileSql');
     }
     if ($errors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get()));
     }
     $contents = file_get_contents($fileSQL);
     $lines = explode(";\n", $contents);
     $path = CopixUrl::getRequestedScriptPath();
     foreach ($lines as $line) {
         $line = trim($line);
         if ($line) {
             $line = str_replace('<PATH>', $path, $line);
             // print_r("<br>***line=".$line);
             $db->run_query($line);
         }
     }
     $db->db_close();
     // Copie des dossiers (pas de slashs à la fin!)
     $tools->installFolder('www/static/malle/2_9a4ba0cdef');
     $tools->installFolder('var/data/blog/logos');
     $tools->installFolder('www/static/album/2_be8550b87c');
     $tools->installFolder('www/static/album/3_cf057489c9');
     $tools->installFolder('www/static/album/4_c996b6cf13');
     $tools->installFolder('www/static/prefs/avatar');
     // Fin
     CopixConfig::set('kernel|jeuEssaiInstalled', 1);
     // Vidage de cache
     CacheServices::clearCache();
     CacheServices::clearConfDB();
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('sysutils|demo.titlePage'));
     $tplDemo = new CopixTpl();
     //$tplDemo->assign ("toto", 1);
     $tplDemo->assign('demo_txt_installed', CopixI18N::get('sysutils|demo.txt.installed'));
     $tplDemo->assign('demo_txt_accounts', CopixI18N::get('sysutils|demo.txt.accounts'));
     $tpl->assign("MAIN", $tplDemo->fetch("demo_install.tpl"));
     $tpl->assign('MENU', Admin::getMenu('demo'));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }