示例#1
0
 /**
  * Set permissions to given role as defined in config. If no permissions
  * are given, the role's permissions are not changed at all.
  *  
  * @param Mage_Admin_Model_Rules $rules
  * @param Mage_Admin_Model_Role $role
  */
 public function createPermissions(Mage_Admin_Model_Rules $rules, Mage_Admin_Model_Role $role)
 {
     if (null === $this->resources) {
         return null;
     }
     return $rules->setResources($this->resources)->setRoleId($role->getId())->saveRel()->save();
 }
示例#2
0
 /**
  * Add a user to a group.
  * 
  * @param Mage_Admin_Model_Role $role
  * @param Mage_Admin_Model_Role $parentRole
  * @param Mage_Admin_Model_User $user
  */
 public function createUserRole(Mage_Admin_Model_Role $role, Mage_Admin_Model_Role $parentRole, Mage_Admin_Model_User $user)
 {
     return $role->setRoleName($parentRole->getRoleName())->setUserId($user->getId())->setRoleType(self::TYPE_USER)->setTreeLevel(self::TREE_LEVEL_USER)->setParentId($parentRole->getId())->save();
 }