Prev | Current Page 189 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

Sounds easy enough! Let??™s look at that in a bit more detail,
starting with a diagram of all related Zend_Acl classes as shown in figure 6.3.
Figure 6.3: Zend_Acl classes.
Zend_Acl_Role
A role is a responsibility that a user has within the system. A typical role would be ???news editor??? or
???member???. This is encapsulated with Zend_Acl_Role which is a very simple class that just holds the name of
the role. The code to create a role is:
$roleMember = new Zend_Acl_Role('member');
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
Once a role is created, its name cannot be changed. Note also, that within the context of the ACL, each
role name must be unique. We can assign a role to the Zend_Acl instance using:
$acl = new Zend_Acl();
$acl->addRole($roleMember);
A given role may have a parent which means that the new role can do everything the parent role can do. A
typical situation may be a forum moderator role, which would be coded like this:
$acl = new Zend_Acl();
$acl->addRole(new Zend_Acl_Role('member'));
$acl->addRole(new Zend_Acl_Role('moderator'), 'member');
In this situation, the moderator role has a parent of member and so a moderator can do everything that a
member can do in addition to any other permissions that have been set.


Pages:
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
muzyka Zbiorniki ciśnieniowe komputerowe forum dyskusyjne forum pokerowe GPW