public function initAcl() { $cache = Zend_Registry::get('cache'); if (($acl = $cache->load('strass_acl')) === false) { $acl = new Strass_Acl(); Zend_Registry::set('acl', $acl); if ($acl->hasRole('nobody')) { return; } $acl->add(new Zend_Acl_Resource('visiteur')); $acl->add(new Zend_Acl_Resource('membres')); $acl->add(new Zend_Acl_Resource('inscriptions')); $acl->add(new Zend_Acl_Resource('site')); $acl->addRole(new Zend_Acl_Role('nobody')); // groupes virtuels $acl->addRole(new Zend_Acl_Role('admins')); $acl->addRole(new Zend_Acl_Role('sachem')); $acl->addRole(new Zend_Acl_Role('membres')); $t = new Unites(); $racines = $t->findRacines(); foreach ($racines as $u) { $u->initAclRoles($acl); } $acl->allow('admins'); $acl->allow('sachem', null, 'totem'); $acl->allow('membres', 'membres', 'voir'); $cache->save($acl, 'strass_acl'); } else { Zend_Registry::set('acl', $acl, array(), null); } return $acl; }
function init() { parent::init(); $acl = Zend_Registry::get('acl'); if (!$acl->has($this)) { $acl->add($this); } try { $t = new Unites(); $racines = $t->findRacines(); foreach ($racines as $racine) { $acl->allow($racine->getRoleId('chef'), $this); } } catch (Strass_Db_Table_NotFound $e) { } }
public function initView($view) { foreach (self::$menu as $item) { $acl = array_key_exists('acl', $item) ? $item['acl'] : array(); $this->append($item['metas'], $item['url'], $acl, true); } $t = new Unites(); $racines = $t->findRacines(); foreach ($racines as $i => $u) { if (!$i) { continue; } // On saute l'unité racine par défaut $this->append($u->getFullName(), array('unite' => $u->slug), array(), true); } parent::initView($view); $view->parent = $view->document->footer->current(); }
function initPage() { /* On préserve la page entre les appels à init, cela permet de préserver les liens, branches, etc. en cas d'erreur. */ try { return Zend_Registry::get('page'); } catch (Exception $e) { $config = Zend_Registry::get('config'); $t = new Unites(); $racine = $t->findRacines()->current(); /* instanciation de la page courante */ $metas = $config->metas; $site = Strass::getSiteTitle(); $page = new Strass_Page(new Wtk_Metas(array('DC.Title' => $metas->title, 'DC.Title.alternative' => $metas->title, 'DC.Subject' => $metas->subject, 'DC.Language' => $metas->language, 'DC.Creator' => $metas->author, 'DC.Date.created' => $metas->creation, 'DC.Date.available' => strftime('%Y-%m-%d'), 'organization' => $metas->organization, 'site' => $site))); Zend_Registry::set('page', $page); $this->branche = $page->addon(new Strass_Addon_Branche()); $this->connexes = $page->addon(new Strass_Addon_Liens('connexes', 'Pages connexes')); $page->addon(new Strass_Addon_Formats()); $label = 'Administrer'; if ($this->assert(null, 'site', 'admin')) { $label = new Wtk_Link($this->_helper->Url('index', 'admin', null, null, true), $label); } $this->actions = $page->addon(new Strass_Addon_Liens('admin', $label)); $page->addon(new Strass_Addon_Console($this->_helper->Auth)); $page->addon(new Strass_Addon_Citation()); $page->addon(new Strass_Addon_Menu()); if ($config->system->short_title) { $this->branche->append($config->system->short_title, array(), array(), true); } if ($this->_afficherMenuUniteRacine && $racine) { $this->_helper->Unite->liensConnexes($racine, $action = 'index', $controller = 'unites'); } if (!$this instanceof Strass_Controller_ErrorController && $this->_titreBranche) { $this->branche->append($this->_titreBranche, array('controller' => strtolower($this->_request->getControllerName())), array(), true); } return $page; } }
function indexAction() { $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $viewRenderer->setView($this->initView()); $pages = array(array('uri' => '/'), array('controller' => 'liens'), array('controller' => 'citation')); /* Les unités */ $t = new Unites(); foreach ($t->findRacines() as $u) { $spages = array(); foreach ($u->findSousUnites(true, true) as $su) { array_push($spages, array('controller' => 'unites', 'action' => 'index', 'params' => array('unite' => $su->slug))); array_push($spages, array('controller' => 'documents', 'action' => 'index', 'params' => array('unite' => $su->slug))); array_push($spages, array('controller' => 'unites', 'action' => 'archives', 'params' => array('unite' => $su->slug))); } array_push($pages, array('controller' => 'unites', 'action' => 'index', 'params' => array('unite' => $u->slug), 'pages' => $spages)); array_push($pages, array('controller' => 'unites', 'action' => 'archives', 'params' => array('unite' => $u->slug))); array_push($pages, array('controller' => 'documents', 'action' => 'index', 'params' => array('unite' => $u->slug))); } /* Journaux */ $t = new Journaux(); foreach ($t->fetchAll() as $j) { $articles = array(); foreach ($j->findArticles('article.public IS NOT NULL OR article.public != 0') as $a) { array_push($articles, array('controller' => 'journaux', 'action' => 'consulter', 'params' => array('article' => $a->slug))); } array_push($pages, array('controller' => 'journaux', 'action' => 'lire', 'params' => array('journal' => $j->slug), 'pages' => $articles)); } /* Photos promues */ $t = new Photos(); $s = $t->select()->where('promotion > 0'); foreach ($t->fetchAll($s) as $p) { array_push($pages, array('controller' => 'photos', 'action' => 'voir', 'params' => array('photo' => $p->slug))); } $this->view->nav = new Zend_Navigation($pages); $this->getResponse()->setheader('Content-Type', 'text/xml'); $this->render(); }