00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Admin_Model_Acl_Role_Registry extends Zend_Acl_Role_Registry
00036 {
00037
00038
00039
00040
00041
00042
00043
00044 function addParent($role, $parents)
00045 {
00046 try {
00047 if ($role instanceof Zend_Acl_Role_Interface) {
00048 $roleId = $role->getRoleId();
00049 } else {
00050 $roleId = $role;
00051 $role = $this->get($role);
00052 }
00053 } catch (Zend_Acl_Role_Registry_Exception $e) {
00054 throw new Zend_Acl_Role_Registry_Exception("Child Role id '$roleId' does not exist");
00055 }
00056
00057 if (!is_array($parents)) {
00058 $parents = array($parents);
00059 }
00060 foreach ($parents as $parent) {
00061 try {
00062 if ($parent instanceof Zend_Acl_Role_Interface) {
00063 $roleParentId = $parent->getRoleId();
00064 } else {
00065 $roleParentId = $parent;
00066 }
00067 $roleParent = $this->get($roleParentId);
00068 } catch (Zend_Acl_Role_Registry_Exception $e) {
00069 throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist");
00070 }
00071 $this->_roles[$roleId]['parents'][$roleParentId] = $roleParent;
00072 $this->_roles[$roleParentId]['children'][$roleId] = $role;
00073 }
00074 return $this;
00075 }
00076 }