Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Roles Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Roles:

Mage_Adminhtml_Block_Widget_Grid 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

 __construct ()
 getGridUrl ()

Protected Member Functions

 _addColumnFilterToCollection ($column)
 _prepareCollection ()
 _prepareColumns ()
 _getSelectedRoles ($json=false)


Detailed Description

Definition at line 27 of file Roles.php.


Constructor & Destructor Documentation

__construct (  ) 

Constructor

By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes

Reimplemented from Varien_Object.

Definition at line 30 of file Roles.php.

00031     {
00032         parent::__construct();
00033         $this->setId('permissionsUserRolesGrid');
00034         $this->setDefaultSort('sort_order');
00035         $this->setDefaultDir('asc');
00036         //$this->setDefaultFilter(array('assigned_user_role'=>1));
00037         $this->setTitle(Mage::helper('adminhtml')->__('User Roles Information'));
00038         $this->setUseAjax(true);
00039     }


Member Function Documentation

_addColumnFilterToCollection ( column  )  [protected]

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 41 of file Roles.php.

00042     {
00043         if ($column->getId() == 'assigned_user_role') {
00044             $userRoles = $this->_getSelectedRoles();
00045             if (empty($userRoles)) {
00046                 $userRoles = 0;
00047             }
00048             if ($column->getFilter()->getValue()) {
00049                 $this->getCollection()->addFieldToFilter('role_id', array('in'=>$userRoles));
00050             }
00051             else {
00052                 if($userRoles) {
00053                     $this->getCollection()->addFieldToFilter('role_id', array('nin'=>$userRoles));
00054                 }
00055             }
00056         }
00057         else {
00058             parent::_addColumnFilterToCollection($column);
00059         }
00060         return $this;
00061     }

_getSelectedRoles ( json = false  )  [protected]

Definition at line 104 of file Roles.php.

00105     {
00106         if ( $this->getRequest()->getParam('user_roles') != "" ) {
00107             return $this->getRequest()->getParam('user_roles');
00108         }
00109         $uRoles = Mage::registry('permissions_user')->getRoles();
00110         if ($json) {
00111             $jsonRoles = Array();
00112             foreach($uRoles as $urid) $jsonRoles[$urid] = 0;
00113             return Zend_Json::encode((object)$jsonRoles);
00114         } else {
00115             return $uRoles;
00116         }
00117     }

_prepareCollection (  )  [protected]

Prepare grid collection object

Returns:
this

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 63 of file Roles.php.

00064     {
00065         $collection = Mage::getResourceModel('admin/role_collection');
00066         $collection->setRolesFilter();
00067         $this->setCollection($collection);
00068         return parent::_prepareCollection();
00069     }

_prepareColumns (  )  [protected]

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 71 of file Roles.php.

00072     {
00073 
00074         $this->addColumn('assigned_user_role', array(
00075             'header_css_class' => 'a-center',
00076             'header'    => Mage::helper('adminhtml')->__('Assigned'),
00077             'type'      => 'radio',
00078             'html_name' => 'roles[]',
00079             'values'    => $this->_getSelectedRoles(),
00080             'align'     => 'center',
00081             'index'     => 'role_id'
00082         ));
00083 
00084         /*$this->addColumn('role_id', array(
00085             'header'    =>Mage::helper('adminhtml')->__('Role ID'),
00086             'index'     =>'role_id',
00087             'align'     => 'right',
00088             'width'    => '50px'
00089         ));*/
00090 
00091         $this->addColumn('role_name', array(
00092             'header'    =>Mage::helper('adminhtml')->__('Role Name'),
00093             'index'     =>'role_name'
00094         ));
00095 
00096         return parent::_prepareColumns();
00097     }

getGridUrl (  ) 

Reimplemented from Mage_Adminhtml_Block_Widget_Grid.

Definition at line 99 of file Roles.php.

00100     {
00101         return $this->getUrl('*/*/rolesGrid', array('user_id' => Mage::registry('permissions_user')->getUserId()));
00102     }


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