Alex Tech Adventures The webs best tutorials!

Welcome, Guest
Please Login or Register.    Lost Password?

Site navigation based on logon permissions
(1 viewing) (1) Guest
Go to bottomPage: 1234
TOPIC: Site navigation based on logon permissions
#39
Site navigation based on logon permissions 2 Years, 5 Months ago Karma: 16
** This thread discusses the content article: Site navigation based on logon permissions **

alexanderrv
Administrator
Posts: 279
graph
User Offline Click here to see the profile of this user
Gender: Male tmthv2 alexchatonly@hotmail.com Location: Freeport, Bahamas Birthdate: 1989-04-14
The administrator has disabled public write access.
 
#67
Re:Site navigation based on logon permissions 2 Years, 4 Months ago Karma: 0
Hi, I have an issue, my Navigation shows perfect, however when I add <resource>default:auth</resource> for example it fails. Any link fails it has this, even if the user is guest. Seems like the Resource doesnt link correctly, because wherever I go where I'm not authorized I get thrown to the login page, so acl and auth is working.
Oldek
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#70
Re:Site navigation based on logon permissions 2 Years, 4 Months ago Karma: 16
May need to see your ACL file to begin solving this.
alexanderrv
Administrator
Posts: 279
graph
User Offline Click here to see the profile of this user
Gender: Male tmthv2 alexchatonly@hotmail.com Location: Freeport, Bahamas Birthdate: 1989-04-14
The administrator has disabled public write access.
 
#72
Re:Site navigation based on logon permissions 2 Years, 4 Months ago Karma: 0
Hi Alex!
I'm beginner to ZF.
So I've encountered first problem with this tutorial and have few question to ask
Everything works fine. But it throws 2 errors:
One I've fixed with if statements, but one is still alive
Here it is:
Notice: Trying to get property of non-object in C:\Program Files\Zend\Apache2\htdocs\acl2\application\Bootstrap.php on line xx
It says, that in $view->navigation($navigation)->setAcl($this->_acl)->setRole($this->_auth->getStorage()->read()->role);
rolehas empty property... and this code doesn't helped:
if($this->_auth->hasIdentity()) {
$role = $identity->role;
}
else {
$role = 'user';
}
$view->navigation($navigation)->setAcl($this->_acl)->setRole($this->_auth->getStorage()->read()->role);
Could you help me with this?
And last question, where I can find more information about resource work in menus? I don't realise how it works with ACL together, which tasks it perform.
Thank you!
01Kuzma
Fresh Boarder
Posts: 14
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#74
Re:Site navigation based on logon permissions 2 Years, 4 Months ago Karma: 0
I had the same notice.
I fixed it by using this in my function _initViewHelpers():
// navigation
$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$navContainer = new Zend_Navigation($navContainerConfig);

$view->navigation($navContainer)->setAcl($this->_acl)->setRole(Zend_Registry::get('role'));


I have this in my function _initAutoload():
// acl
if(Zend_Auth::getInstance()->hasIdentity()) {
Zend_Registry::set('role', Zend_Auth::getInstance()->getStorage()->read()->role);
} else {
Zend_Registry::set('role', 'guest');
}

$this->_acl = new Model_LibraryAcl;
$this->_auth = Zend_Auth::getInstance();

$fc = Zend_Controller_Front::getInstance();
$fc->registerPlugin(new Plugin_AccessCheck($this->_acl));
//---

Hope that helps
ericp
Fresh Boarder
Posts: 18
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
Eric P.
 
#76
Re:Site navigation based on logon permissions 2 Years, 4 Months ago Karma: 0
On the same topic of Site "navigation based on logon permissions", i'm having a problem using it with modules.
I tried modifying the xml but it shows no links now when logged in as admin.

Here is my navigation.xml:
Code:

<?xml version="1.0" encoding="utf-8"?>
<config>
<nav>

<home>
<label>Home</label>
<module>ez</module>
<controller>index</controller>
<action>index</action>
<resource>ez:index</resource>
</home>

<clients>
<label>Clients</label>
<module>ez</module>
<controller>clients</controller>
<action>index</action>
<resource>ez:index</resource>
</clients>


</nav>
</config>



Here is my LibraryAcl.php:
Code:

class Model_LibraryAcl extends Zend_Acl {

    public function __construct() {

// resources ---------------------->

// default module
$this->add(new Zend_Acl_Resource('default'));
$this->add(new Zend_Acl_Resource('default:authentication'), 'default');
$this->add(new Zend_Acl_Resource('default:index'), 'default');

// ez module
$this->add(new Zend_Acl_Resource('ez'));
$this->add(new Zend_Acl_Resource('ez:index'), 'ez');
$this->add(new Zend_Acl_Resource('ez:clients'), 'ez');
 
 // end: resources --------------->
 
// roles ---------------------------------------------->
$this->addRole(new Zend_Acl_Role('guest'));
$this->addRole(new Zend_Acl_Role('user'), 'guest');
$this->addRole(new Zend_Acl_Role('admin'), 'user');
// end: roles ---------------------------------------------->
 
// permissions. Extend as necessery --------------------->

// default module
$this->allow(null, 'default:authentication', 'login');
$this->allow('guest', 'default:authentication', 'login');
$this->allow('user', 'default:authentication', 'logout');
$this->allow('guest', 'default:index');

// ez module
$this->allow('user', 'ez:index', 'index');
$this->allow('user', 'ez:index', 'index');
$this->allow('admin', 'ez:clients', 'index');
$this->allow('admin', 'ez:index', 'index');
// end: permissions. ------------------------------------>  


    }

}



The permissions work perfectly for accessing/denying pages, but the navigation is not displaying at all now.

thanks for any help.
P.S. I just got back from CodeWorks here in Miami. Mathew Weier O'Phinney gave a very nice speach about Zend Framework!
ericp
Fresh Boarder
Posts: 18
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
Eric P.
 
Go to topPage: 1234
Moderators: alexanderrv
You are here: Home Forum

Statistics

Members : 1401
Content : 42
Web Links : 1
Content View Hits : 191197

Poll

Interested in TinyBrowser and TinyMce plugin for ZF?
 

Who's Online

We have 48 guests online