/** * 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; }
/** * supression de tous les types de cache. */ function _clearAll() { foreach ($GLOBALS['COPIX']['CONFIG']->cacheTypeDir as $key => $elem) { CopixCache::_clearType($key); } }
/** * 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; }
/** * 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; }
/** * Vidage du cache * * @param mixed $pId Identifiant du cache * @param string $pType Type de cache * @return boolean */ public static function clear($pId = null, $pType = 'default') { if (self::isEnabled(self::_getMain($pType))) { if ($pId == null) { if (count(explode('|', $pType)) == 1) { CopixCache::_cascadeClear($pType); } return self::_getStrategy(self::_getStrategyNameFor(self::_getMain($pType)))->clear(null, $pType, CopixConfig::instance()->copixcache_getType(self::_getMain($pType))); } return self::_getStrategy(self::_getStrategyNameFor(self::_getMain($pType)))->clear(serialize($pId), $pType, CopixConfig::instance()->copixcache_getType(self::_getMain($pType))); } return true; }
public function testEnabled() { CopixConfig::instance()->cacheEnabled = false; CopixCache::write('myval', 'test', 'unittestfile'); $this->assertTrue(!CopixCache::exists('myval', 'unittestfile')); CopixConfig::instance()->cacheEnabled = true; CopixCache::write('myval', 'test', 'unittestfiledisable'); $this->assertTrue(!CopixCache::exists('myval', 'unittestfile')); }
/** * Suppression des droits atribués à des membres sur un blog * * @author Christophe Beyer <*****@*****.**> * @since 2007/06/04 * @param integer $id Id du blog * @param integer $kind Numéro générique de la rubrique (ne pas y toucher) * @param array $membres Les membres à désinscrire (les valeurs sont de type USER_TYPE|USER_ID) */ public function doUnsubscribe() { $id = $this->getRequest('id', null); $kind = $this->getRequest('kind', null); $membres = $this->getRequest('membres', array()); $groupeService =& CopixClassesFactory::Create('groupe|groupeService'); $blogDAO = CopixDAOFactory::create('blog|blog'); $blog = $blogDAO->get($id); $errors = array(); if (!$blog || !$kind) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => $blog ? CopixUrl::get('|', array('blog' => $blog->url_blog)) : CopixUrl::get('||'))); } if (!BlogAuth::canMakeInBlog('ADMIN_DROITS', $blog)) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageBlog'), 'back' => $blog ? CopixUrl::get('|', array('blog' => $blog->url_blog)) : CopixUrl::get('||'))); } if (!$errors) { foreach ($membres as $membre) { list($user_type, $user_id) = explode("|", $membre); if ($user_type && $user_id) { //print ("user_type=$user_type / user_id=$user_id"); Kernel::setLevel("MOD_BLOG", $id, $user_type, $user_id, 0); CopixCache::clear($user_type . '-' . $user_id, 'getnodeparents'); CopixCache::clear($user_type . '-' . $user_id, 'getmynodes'); } } $back = CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id, 'kind' => $kind)); return new CopixActionReturn(COPIX_AR_REDIRECT, $back); } }
/** * Effectue une demande d'inscription � un groupe pour l'utilisateur courant * * @author Christophe Beyer <*****@*****.**> * @since 2005/11/16 * @param integer $id Id du groupe */ public function doJoin() { if (!Kernel::is_connected()) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.nologin'), 'back' => CopixUrl::get('auth|default|login'))); } $dao = CopixDAOFactory::create("groupe"); $kernel_service =& CopixClassesFactory::Create('kernel|kernel'); $minimail_service =& CopixClassesFactory::Create('minimail|minimailservice'); $groupeService =& CopixClassesFactory::Create('groupe|groupeService'); $id = $this->getRequest('id', null); $errors = $oks = array(); $groupe = $dao->getGroupe($id); if (!$groupe) { $errors[] = CopixI18N::get('groupe|groupe.error.noGroup'); } elseif (!$groupe[0]->is_open) { $errors[] = CopixI18N::get('groupe|groupe.error.private'); } $mondroit = $kernel_service->getLevel("CLUB", $id); if ($mondroit) { $errors[] = CopixI18N::get('groupe|groupe.error.alreadyMember'); } if ($errors) { if (!CopixConfig::exists('|can_group_showlist') || CopixConfig::get('|can_group_showlist')) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('groupe||getListPublic'))); } else { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('||'))); } } else { $kernel_service->setLevel("CLUB", $id, _currentUser()->getExtra('type'), _currentUser()->getExtra('id'), PROFILE_CCV_SHOW); CopixCache::clear(_currentUser()->getExtra('type') . '-' . _currentUser()->getExtra('id'), 'getnodeparents'); CopixCache::clear(_currentUser()->getExtra('type') . '-' . _currentUser()->getExtra('id'), 'getmynodes'); // On r�cup�re le propri�taire, afin de lui envoyer un message $childs = $kernel_service->getNodeChilds("CLUB", $id); $trouve = false; foreach ($childs as $child) { if ($trouve) { continue; } if ($groupeService->canMakeInGroupe('ADMIN', $child["droit"])) { // Propri�taire trouv� ! $trouve = $child; } } //var_dump($trouve); /* while (!$trouve && list(,$child)=each($childs)) { if ($groupeService->canMakeInGroupe('ADMIN',$child["droit"])) // Propri�taire trouv� ! $trouve = $child; } */ if ($trouve) { $userInfo = $kernel_service->getUserInfo($trouve["type"], $trouve["id"]); //print_r2($userInfo); if ($userInfo && $userInfo["user_id"]) { $his_nom = _currentUser()->getExtra('prenom') . " " . _currentUser()->getExtra('nom') . " (" . _currentUser()->getExtra('type') . ")"; $msg_from_login = _currentUser()->getLogin(); $msg_title = CopixI18N::get('groupe|groupe.msgJoin.title', array($groupe[0]->titre)); $format = CopixConfig::get('minimail|default_format'); if ($format == 'dokuwiki' || $format == 'wiki') { $msg_body = CopixI18N::get('groupe|groupe.msgJoin.body', array(CopixUrl::get('groupe||getHomeAdminMembers', array("id" => $id)), $his_nom)); $msg_body = str_replace("\\n", "\n", $msg_body); } else { $msg_body = CopixI18N::get('groupe|groupe.msgJoin.bodyHtml', array(CopixUrl::get('groupe||getHomeAdminMembers', array("id" => $id)), $his_nom)); } //print_r($msg_body); //die(); $msg_from_id = _currentUser()->getId(); $msg_destin = array($userInfo["user_id"] => 1); $send = $minimail_service->sendMinimail($msg_title, $msg_body, $msg_from_id, $msg_destin, $format); if ($send) { $oks[] = CopixI18N::get('groupe|groupe.msgJoin.Ok'); } else { $errors[] = CopixI18N::get('groupe|groupe.error.sendJoin'); } } else { $errors[] = CopixI18N::get('groupe|groupe.error.owner'); } } else { // Pas de proprio, c'est pas normal $errors[] = CopixI18N::get('groupe|groupe.error.noOwner'); } $tpl = new CopixTpl(); $tpl->assign('TITLE_PAGE', $groupe[0]->titre); // $tpl->assign ('MENU', '<a href="'.CopixUrl::get ('groupe||getListPublic').'">'.CopixI18N::get ('groupe|groupe.annuaire').'</a> :: <a href="'.CopixUrl::get ('groupe||getListMy').'">'.CopixI18N::get ('groupe|groupe.my').'</a>'); $tplHome = new CopixTpl(); $tplHome->assign('groupe', $groupe[0]); $tplHome->assign('errors', $errors); $tplHome->assign('oks', $oks); if (!CopixConfig::exists('|can_group_showlist') || CopixConfig::get('|can_group_showlist')) { $tplHome->assign('can_group_showlist', 1); } else { $tplHome->assign('can_group_showlist', 0); } $result = $tplHome->fetch('dojoin.tpl'); $tpl->assign('MAIN', $result); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); } }
/** * Méthode qui efface le cache de la zone * @param array $pParams les paramètres de contexte pour la zone. * @return boolean si tout s'est bien passé * @access private */ protected function _clear($pParams) { $this->_params = $pParams; if ($this->_useCache) { $module = CopixContext::get(); CopixCache::clear($this->_makeId(), 'zones|' . $module . get_class($this)); } return true; }