airtime menu now uses ACL with the custom viewscript.

This commit is contained in:
Naomi 2011-02-10 18:03:41 -05:00
parent 27b462d638
commit 36193d2948
4 changed files with 39 additions and 38 deletions

View file

@ -4,9 +4,9 @@ require_once 'Acl_plugin.php';
$ccAcl = new Zend_Acl(); $ccAcl = new Zend_Acl();
$ccAcl->addRole(new Zend_Acl_Role('guest')) $ccAcl->addRole(new Zend_Acl_Role('G'))
->addRole(new Zend_Acl_Role('host'), 'guest') ->addRole(new Zend_Acl_Role('H'), 'G')
->addRole(new Zend_Acl_Role('admin'), 'host'); ->addRole(new Zend_Acl_Role('A'), 'H');
$ccAcl->add(new Zend_Acl_Resource('library')) $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('index')) ->add(new Zend_Acl_Resource('index'))
@ -23,19 +23,19 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('preference')); ->add(new Zend_Acl_Resource('preference'));
/** Creating permissions */ /** Creating permissions */
$ccAcl->allow('guest', 'index') $ccAcl->allow('G', 'index')
->allow('guest', 'login') ->allow('G', 'login')
->allow('guest', 'error') ->allow('G', 'error')
->allow('guest', 'nowplaying') ->allow('G', 'nowplaying')
->allow('guest', 'api') ->allow('G', 'api')
->allow('guest', 'schedule') ->allow('G', 'schedule')
->allow('host', 'library') ->allow('H', 'library')
->allow('host', 'search') ->allow('H', 'search')
->allow('host', 'plupload') ->allow('H', 'plupload')
->allow('host', 'playlist') ->allow('H', 'playlist')
->allow('host', 'sideplaylist') ->allow('H', 'sideplaylist')
->allow('admin', 'user') ->allow('A', 'user')
->allow('admin', 'preference'); ->allow('A', 'preference');
$aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl); $aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl);

View file

@ -13,7 +13,7 @@ $pages = array(
'module' => 'default', 'module' => 'default',
'controller' => 'Nowplaying', 'controller' => 'Nowplaying',
'action' => 'index', 'action' => 'index',
'resource' => 'Nowplaying' 'resource' => 'nowplaying'
), ),
array( array(
'label' => 'Schedule', 'label' => 'Schedule',

View file

@ -24,7 +24,7 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
* @param $roleName * @param $roleName
* @return void * @return void
**/ **/
public function __construct(Zend_Acl $aclData, $roleName = 'guest') public function __construct(Zend_Acl $aclData, $roleName = 'G')
{ {
$this->_errorPage = array('module' => 'default', $this->_errorPage = array('module' => 'default',
'controller' => 'error', 'controller' => 'error',
@ -71,8 +71,7 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
public function setRoleName($type) public function setRoleName($type)
{ {
$roles = array("A" => "admin", "H" => "host", "G" => "guest"); $this->_roleName = $type;
$this->_roleName = $roles[$type];
} }
/** /**

View file

@ -1,22 +1,24 @@
<ul id="nav"> <ul id="nav">
<?php foreach ($this->container as $page) : ?> <?php foreach ($this->container as $page) : ?>
<li class="top"> <?php if($this->navigation()->accept($page)) : ?>
<?php if($page->hasPages()) : ?> <li class="top">
<a class="top_link" href="<?php echo $page->getHref(); ?>"> <?php if($page->hasPages()) : ?>
<span class="down"><?php echo $page->getLabel(); ?></span> <a class="top_link" href="<?php echo $page->getHref(); ?>">
</a> <span class="down"><?php echo $page->getLabel(); ?></span>
<ul class="sub"> </a>
<?php foreach ($page->getPages() as $sub) : ?> <ul class="sub">
<li> <?php foreach ($page->getPages() as $sub) : ?>
<a href="<?php echo $sub->getHref(); ?>"><?php echo $sub->getLabel(); ?></a> <li>
</li> <a href="<?php echo $sub->getHref(); ?>"><?php echo $sub->getLabel(); ?></a>
<?php endforeach; ?> </li>
</ul> <?php endforeach; ?>
<?php else: ?> </ul>
<a class="top_link" href="<?php echo $page->getHref(); ?>"> <?php else: ?>
<span><?php echo $page->getLabel(); ?></span> <a class="top_link" href="<?php echo $page->getHref(); ?>">
</a> <span><?php echo $page->getLabel(); ?></span>
<?php endif; ?> </a>
</li> <?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>