/**
  * Les limites de l'utilisateur, basees sur l'URL, sur un champ particulier ou toutes les infos
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2009/09/24
  * @param $pField string (option) Si on veut un champ particulier. Si null, on renvoit tous les champs
  * @return mixed Si pField=null, tout le recordset, sinon la valeur du champ (ou null si vide)
  */
 public function getKernelLimits($pField = null)
 {
     _classInclude('welcome|welcome');
     $null = _dao("kernel|kernel_limits_urls");
     $cache_type = 'kernel_limits_urls';
     $cache_id = CopixUrl::get();
     if (0 && CopixCache::exists($cache_id, $cache_type)) {
         $node = CopixCache::read($cache_id, $cache_type);
     } else {
         $node = Welcome::findNodeByUrl($cache_id);
         if ($node != null) {
             if ($node->ville) {
                 $node->ville_as_array = explode(',', $node->ville);
             } else {
                 $node->ville_as_array = array();
             }
         }
         //var_dump($node);
         CopixCache::write($cache_id, $node, $cache_type);
     }
     //var_dump($node);
     if ($pField && $node != null && $node->{$pField}) {
         $return = $node->{$pField};
     } elseif ($pField) {
         $return = null;
     } else {
         $return = $node;
     }
     return $return;
 }
 /**
  * Le droit de l'usager courant sur une intervention precise. Regarde en session, sinon va chercher dans la base et met en session
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2009/01/21
  * @param integer $idinter Id de l'intervention
  * @return integer Son droit
  */
 public function getDroit($idinter)
 {
     $user_type = _currentUser()->getExtra('type');
     $user_id = _currentUser()->getExtra('id');
     $cache_id = $user_type . '-' . $user_id . '-' . $idinter;
     $cache_type = 'telepdroit';
     if (!CopixCache::exists($cache_id, $cache_type)) {
         $getDroit = 0;
         $DAOinterventionDroit = _dao('teleprocedures|intervention_droit');
         if ($droit = $DAOinterventionDroit->findForIdinterAndUser($idinter, $user_type, $user_id)) {
             if (isset($droit->droit)) {
                 $getDroit = $droit->droit;
             }
         }
         CopixCache::write($cache_id, $getDroit, $cache_type);
     } else {
         // En cache
         $getDroit = CopixCache::read($cache_id, $cache_type);
     }
     return $getDroit;
 }
 /**
  * Test de cache non-existsant
  *
  */
 public function testNoCache()
 {
     $config = CopixConfig::instance();
     $tempDefault = $config->copixcache_getDefaultTypeName();
     $config->copixcache_setDefaultTypeName(null);
     CopixCache::write('myval', 'tttt', 'nocachetest');
     $this->assertTrue(!CopixCache::exists('myval', 'nocachetest'));
     try {
         CopixCache::read('myval', 'tttt', 'nocachetest');
         $testbool = false;
     } catch (Exception $e) {
         if ($e instanceof CopixCacheException) {
             $testbool = true;
         } else {
             $testbool = false;
         }
     }
     $this->assertTrue($testbool);
     $this->assertTrue(CopixCache::clear('myval', 'nocachetest'));
     CopixConfig::instance()->apcEnabled = false;
     /*
             unset(CopixCache::$_strategy['unittestapc']);
             try {
                 CopixCache::write('myval','tttt','unittestapc');
                 $testbool=false;
             } catch (Exception $e) {
                 $testbool=true;
             }
             $this->assertTrue($testbool);
             $config->copixcache_setDefaultTypeName($tempDefault);
             CopixCache::write('myval','tttt','nocachetest');
             $this->assertTrue(CopixCache::exists('myval','nocachetest'));
     */
 }
 /**
  * Affiche la liste des dernieres actualites des blogs publics
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2012/02/21
  * @param string $titre Titre a donner a la zone
  * @param integer $nb Nombre d'articles a afficher
  * @param boolean $chapo Si on veut afficher les chapos. Par defaut : false
  * @param boolean $hr Affiche un HR entre chaque article. Par defaut : false
  * @param boolean $showtitle Si on veut afficher le titre des articles. Par defaut : true
  * @param boolean $showdate Si on veut afficher la date des articles. Par defaut : true
  * @param boolean $dateformat Format de la date (si autre que i18n), envoyé dans strftime
  * @param boolean $showtime Si on veut afficher l'heure, sera formaté par |time (HH:MM). Par défaut : false
  * @param boolean $showcategorie Si on veut afficher les categories des articles. Par defaut : true
  * @param boolean $showparent Si on veut afficher l'origine de l'article. Par defaut : false
  * @param integer $blogId Pour limiter à un blog dont on connait l'ID
  * @param boolean $cache Si on veut mettre les données en cache, selon les paramètres du cache welcome. Par défaut : true
  * @param integer $cacheDuration Durée du cache, en secondes, pour écraser la valeur par défaut du cache welcome
  * @param boolean $future Pour afficher les articles post-datés ayant une date de publication dans le futur. Par défaut : true
  * @param boolean $dateutf8encode Pour encoder en UTF8 la date (si $dateformat passé). Par défaut : false
  */
 public function _createContent(&$toReturn)
 {
     $this->addJs('js/iconito/module_welcome.js');
     $titre = $this->getParam('titre');
     $nb = (int) $this->getParam('nb');
     $chapo = $this->getParam('chapo', false);
     $hr = $this->getParam('hr', false);
     $showtitle = $this->getParam('showtitle', true);
     $showdate = $this->getParam('showdate', true);
     $dateformat = $this->getParam('dateformat');
     $showtime = $this->getParam('showtime', false);
     $showcategorie = $this->getParam('showcategorie', true);
     $showparent = $this->getParam('showparent', false);
     $blogId = (int) $this->getParam('blogId');
     $cache = $this->getParam('cache', true);
     $cacheDuration = (int) $this->getParam('cacheDuration');
     $future = $this->getParam('future', true);
     $dateutf8encode = $this->getParam('dateutf8encode', false);
     if ($cache) {
         $cacheId = 'zoneActualites2';
         $cacheId .= '|' . $nb;
         $cacheId .= '|' . $chapo;
         $cacheId .= '|' . $hr;
         $cacheId .= '|' . $showtitle;
         $cacheId .= '|' . $showdate;
         $cacheId .= '|' . $dateformat;
         $cacheId .= '|' . $showtime;
         $cacheId .= '|' . $showcategorie;
         $cacheId .= '|' . $showparent;
         $cacheId .= '|' . $blogId;
         $cacheId .= '|' . $future;
         $existsParams = array();
         if ($cacheDuration > 0) {
             $existsParams['duration'] = $cacheDuration;
         }
         if (CopixCache::exists($cacheId, 'welcome', $existsParams)) {
             $toReturn = CopixCache::read($cacheId, 'welcome', array(''));
             return true;
         }
     }
     $tpl = new CopixTpl();
     $tpl->assign('titre', $titre);
     $tpl->assign('chapo', $chapo);
     $tpl->assign('hr', $hr);
     $tpl->assign('showtitle', $showtitle);
     $tpl->assign('showdate', $showdate);
     $tpl->assign('dateformat', $dateformat);
     $tpl->assign('showtime', $showtime);
     $tpl->assign('showcategorie', $showcategorie);
     $tpl->assign('showparent', $showparent);
     $tpl->assign('blogId', $blogId);
     $tpl->assign('cache', $cache);
     $tpl->assign('future', $future);
     $tpl->assign('dateutf8encode', $dateutf8encode);
     $articles = _ioDAO('blog|blogarticle')->findPublic(array('categories' => true, 'nb' => $nb, 'parent' => $showparent, 'blogId' => $blogId, 'future' => $future));
     $tpl->assign('articles', $articles);
     $tpl->assign('listArticle', $articles);
     $toReturn = $tpl->fetch('zone_actualites2.tpl');
     if ($cache) {
         //_dump('CopixCache::write');
         CopixCache::write($cacheId, $toReturn, 'welcome');
     }
     return true;
 }
 /**
  * Méthode qui calcul le contenu de la zone en fonction de ses paramètres.
  *  Choisi entre le cache et la génération du contenu
  *
  * @param array  $pParams les paramètres de contexte pour la zone. (généralement le contenu de l'url)
  * @return   string  le contenu de la zone
  * @access private
  */
 protected function _process($pParams)
 {
     $this->_params = $pParams;
     $contents = '';
     if ($this->_useCache) {
         $module = CopixContext::get();
         if (CopixCache::exists($this->_makeId(), 'zones|' . $module . get_class($this))) {
             $contents = CopixCache::read($this->_makeId(), 'zones|' . $module . get_class($this));
         } else {
             if ($this->_createContent($contents)) {
                 CopixCache::write($this->_makeId(), 'zones|' . $module . get_class($this), $contents);
             }
         }
     } else {
         $this->_createContent($contents);
     }
     return $contents;
 }