Mage_Adminhtml_Block_Permissions_Tab_Rolesedit Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Permissions_Tab_Rolesedit:

Mage_Adminhtml_Block_Widget_Form Mage_Adminhtml_Block_Widget_Tab_Interface Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 getTabLabel ()
 getTabTitle ()
 canShowTab ()
 isHidden ()
 __construct ()
 getEverythingAllowed ()
 getResTreeJson ()

Protected Member Functions

 _sortTree ($a, $b)
 _getNodeJson ($node, $level=0)


Detailed Description

Definition at line 27 of file Rolesedit.php.


Constructor & Destructor Documentation

__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     }


Member Function Documentation

_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

Returns:
bool

Implements Mage_Adminhtml_Block_Widget_Tab_Interface.

Definition at line 54 of file Rolesedit.php.

00055     {
00056         return true;
00057     }

getEverythingAllowed (  ) 

Definition at line 95 of file Rolesedit.php.

00096     {
00097         return in_array('all', $this->getSelectedResources());
00098     }

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

Returns:
string

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

Returns:
string

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

Returns:
bool

Implements Mage_Adminhtml_Block_Widget_Tab_Interface.

Definition at line 64 of file Rolesedit.php.

00065     {
00066         return false;
00067     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:22:53 2009 for Magento by  doxygen 1.5.8