Public Member Functions | |
__construct () | |
getGridUrl () | |
Protected Member Functions | |
_addColumnFilterToCollection ($column) | |
_prepareCollection () | |
_prepareColumns () | |
_getUsers ($json=false) |
Definition at line 34 of file User.php.
__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 37 of file User.php.
00038 { 00039 parent::__construct(); 00040 $this->setDefaultSort('role_user_id'); 00041 $this->setDefaultDir('asc'); 00042 $this->setId('roleUserGrid'); 00043 $this->setDefaultFilter(array('in_role_users'=>1)); 00044 $this->setUseAjax(true); 00045 }
_addColumnFilterToCollection | ( | $ | column | ) | [protected] |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 47 of file User.php.
00048 { 00049 if ($column->getId() == 'in_role_users') { 00050 $inRoleIds = $this->_getUsers(); 00051 if (empty($inRoleIds)) { 00052 $inRoleIds = 0; 00053 } 00054 if ($column->getFilter()->getValue()) { 00055 $this->getCollection()->addFieldToFilter('user_id', array('in'=>$inRoleIds)); 00056 } 00057 else { 00058 if($inRoleIds) { 00059 $this->getCollection()->addFieldToFilter('user_id', array('nin'=>$inRoleIds)); 00060 } 00061 } 00062 } 00063 else { 00064 parent::_addColumnFilterToCollection($column); 00065 } 00066 return $this; 00067 }
_getUsers | ( | $ | json = false |
) | [protected] |
Definition at line 157 of file User.php.
00158 { 00159 if ( $this->getRequest()->getParam('in_role_user') != "" ) { 00160 return $this->getRequest()->getParam('in_role_user'); 00161 } 00162 $roleId = ( $this->getRequest()->getParam('rid') > 0 ) ? $this->getRequest()->getParam('rid') : Mage::registry('RID'); 00163 $users = Mage::getModel('admin/roles')->setId($roleId)->getRoleUsers(); 00164 if (sizeof($users) > 0) { 00165 if ( $json ) { 00166 $jsonUsers = Array(); 00167 foreach($users as $usrid) $jsonUsers[$usrid] = 0; 00168 return Zend_Json::encode((object)$jsonUsers); 00169 } else { 00170 return array_values($users); 00171 } 00172 } else { 00173 if ( $json ) { 00174 return '{}'; 00175 } else { 00176 return array(); 00177 } 00178 } 00179 }
_prepareCollection | ( | ) | [protected] |
Prepare grid collection object
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 69 of file User.php.
00070 { 00071 $roleId = $this->getRequest()->getParam('rid'); 00072 Mage::register('RID', $roleId); 00073 $collection = Mage::getModel('admin/roles')->getUsersCollection(); 00074 $this->setCollection($collection); 00075 return parent::_prepareCollection(); 00076 }
_prepareColumns | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 78 of file User.php.
00079 { 00080 $this->addColumn('in_role_users', array( 00081 'header_css_class' => 'a-center', 00082 'type' => 'checkbox', 00083 'name' => 'in_role_users', 00084 'values' => $this->_getUsers(), 00085 'align' => 'center', 00086 'index' => 'user_id' 00087 )); 00088 00089 $this->addColumn('role_user_id', array( 00090 'header' =>Mage::helper('adminhtml')->__('User ID'), 00091 'width' =>5, 00092 'align' =>'left', 00093 'sortable' =>true, 00094 'index' =>'user_id' 00095 )); 00096 00097 $this->addColumn('role_user_username', array( 00098 'header' =>Mage::helper('adminhtml')->__('User Name'), 00099 'align' =>'left', 00100 'index' =>'username' 00101 )); 00102 00103 $this->addColumn('role_user_firstname', array( 00104 'header' =>Mage::helper('adminhtml')->__('First Name'), 00105 'align' =>'left', 00106 'index' =>'firstname' 00107 )); 00108 00109 $this->addColumn('role_user_lastname', array( 00110 'header' =>Mage::helper('adminhtml')->__('Last Name'), 00111 'align' =>'left', 00112 'index' =>'lastname' 00113 )); 00114 00115 $this->addColumn('role_user_email', array( 00116 'header' =>Mage::helper('adminhtml')->__('Email'), 00117 'width' =>40, 00118 'align' =>'left', 00119 'index' =>'email' 00120 )); 00121 00122 $this->addColumn('role_user_is_active', array( 00123 'header' => Mage::helper('adminhtml')->__('Status'), 00124 'index' => 'is_active', 00125 'align' =>'left', 00126 'type' => 'options', 00127 'options' => array('1' => Mage::helper('adminhtml')->__('Active'), '0' => Mage::helper('adminhtml')->__('Inactive')), 00128 )); 00129 00130 /* 00131 $this->addColumn('grid_actions', 00132 array( 00133 'header'=>Mage::helper('adminhtml')->__('Actions'), 00134 'width'=>5, 00135 'sortable'=>false, 00136 'filter' =>false, 00137 'type' => 'action', 00138 'actions' => array( 00139 array( 00140 'caption' => Mage::helper('adminhtml')->__('Remove'), 00141 'onClick' => 'role.deleteFromRole($role_id);' 00142 ) 00143 ) 00144 ) 00145 ); 00146 */ 00147 00148 return parent::_prepareColumns(); 00149 }
getGridUrl | ( | ) |
Reimplemented from Mage_Adminhtml_Block_Widget_Grid.
Definition at line 151 of file User.php.
00152 { 00153 $roleId = $this->getRequest()->getParam('rid'); 00154 return $this->getUrl('*/*/editrolegrid', array('rid' => $roleId)); 00155 }