Public Member Functions | |
getTabLabel () | |
getTabTitle () | |
canShowTab () | |
isHidden () | |
__construct () | |
getEverythingAllowed () | |
getResTreeJson () | |
Protected Member Functions | |
_sortTree ($a, $b) | |
_getNodeJson ($node, $level=0) |
Definition at line 27 of file Rolesedit.php.
__construct | ( | ) |
Class constructor
Reimplemented from Mage_Adminhtml_Block_Widget_Form.
Definition at line 69 of file Rolesedit.php.
00070 { 00071 parent::__construct(); 00072 00073 $rid = Mage::app()->getRequest()->getParam('rid', false); 00074 00075 $resources = Mage::getModel('admin/roles')->getResourcesList(); 00076 00077 $rules_set = Mage::getResourceModel('admin/rules_collection')->getByRoles($rid)->load(); 00078 00079 $selrids = array(); 00080 00081 foreach ($rules_set->getItems() as $item) { 00082 if (array_key_exists(strtolower($item->getResource_id()), $resources) && $item->getPermission() == 'allow') { 00083 $resources[$item->getResource_id()]['checked'] = true; 00084 array_push($selrids, $item->getResource_id()); 00085 } 00086 } 00087 00088 $this->setSelectedResources($selrids); 00089 00090 $this->setTemplate('permissions/rolesedit.phtml'); 00091 //->assign('resources', $resources); 00092 //->assign('checkedResources', join(',', $selrids)); 00093 }
_getNodeJson | ( | $ | node, | |
$ | level = 0 | |||
) | [protected] |
Definition at line 118 of file Rolesedit.php.
00119 { 00120 $item = array(); 00121 $selres = $this->getSelectedResources(); 00122 00123 if ($level != 0) { 00124 $item['text']= (string)$node->title; 00125 $item['sort_order']= isset($node->sort_order) ? (string)$node->sort_order : 0; 00126 $item['id'] = (string)$node->attributes()->aclpath; 00127 00128 if (in_array($item['id'], $selres)) 00129 $item['checked'] = true; 00130 } 00131 if (isset($node->children)) { 00132 $children = $node->children->children(); 00133 } else { 00134 $children = $node->children(); 00135 } 00136 if (empty($children)) { 00137 return $item; 00138 } 00139 00140 if ($children) { 00141 $item['children'] = array(); 00142 //$item['cls'] = 'fiche-node'; 00143 foreach ($children as $child) { 00144 if ($child->getName()!='title' && $child->getName()!='sort_order') { 00145 if (!(string)$child->title) { 00146 continue; 00147 } 00148 if ($level != 0) { 00149 $item['children'][] = $this->_getNodeJson($child, $level+1); 00150 } else { 00151 $item = $this->_getNodeJson($child, $level+1); 00152 } 00153 } 00154 } 00155 if (!empty($item['children'])) { 00156 usort($item['children'], array($this, '_sortTree')); 00157 } 00158 } 00159 return $item; 00160 }
_sortTree | ( | $ | a, | |
$ | b | |||
) | [protected] |
Definition at line 112 of file Rolesedit.php.
00113 { 00114 return $a['sort_order']<$b['sort_order'] ? -1 : ($a['sort_order']>$b['sort_order'] ? 1 : 0); 00115 }
canShowTab | ( | ) |
Whether tab is available
Implements Mage_Adminhtml_Block_Widget_Tab_Interface.
Definition at line 54 of file Rolesedit.php.
getEverythingAllowed | ( | ) |
getResTreeJson | ( | ) |
Definition at line 100 of file Rolesedit.php.
00101 { 00102 $rid = Mage::app()->getRequest()->getParam('rid', false); 00103 $resources = Mage::getModel('admin/roles')->getResourcesTree(); 00104 00105 $rootArray = $this->_getNodeJson($resources->admin, 1); 00106 00107 $json = Zend_Json::encode(isset($rootArray['children']) ? $rootArray['children'] : array()); 00108 00109 return $json; 00110 }
getTabLabel | ( | ) |
Get tab label
Implements Mage_Adminhtml_Block_Widget_Tab_Interface.
Definition at line 34 of file Rolesedit.php.
00035 { 00036 return Mage::helper('adminhtml')->__('Role Resources'); 00037 }
getTabTitle | ( | ) |
Get tab title
Implements Mage_Adminhtml_Block_Widget_Tab_Interface.
Definition at line 44 of file Rolesedit.php.
00045 { 00046 return $this->getTabLabel(); 00047 }
isHidden | ( | ) |
Whether tab is visible
Implements Mage_Adminhtml_Block_Widget_Tab_Interface.
Definition at line 64 of file Rolesedit.php.