Public Member Functions | |
indexAction () | |
newAction () | |
editAction () | |
saveAction () | |
deleteAction () | |
rolesGridAction () | |
roleGridAction () | |
Protected Member Functions | |
_initAction () | |
_isAllowed () |
Definition at line 26 of file UserController.php.
_initAction | ( | ) | [protected] |
Definition at line 29 of file UserController.php.
00030 { 00031 $this->loadLayout() 00032 ->_setActiveMenu('system/acl') 00033 ->_addBreadcrumb($this->__('System'), $this->__('System')) 00034 ->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions')) 00035 ->_addBreadcrumb($this->__('Users'), $this->__('Users')) 00036 ; 00037 return $this; 00038 }
_isAllowed | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Controller_Action.
Definition at line 168 of file UserController.php.
00169 { 00170 return Mage::getSingleton('admin/session')->isAllowed('system/acl/users'); 00171 }
deleteAction | ( | ) |
Definition at line 118 of file UserController.php.
00119 { 00120 $currentUser = Mage::getSingleton('admin/session')->getUser(); 00121 00122 if ($id = $this->getRequest()->getParam('user_id')) { 00123 if ( $currentUser->getId() == $id ) { 00124 Mage::getSingleton('adminhtml/session')->addError($this->__('You cannot delete account of yourself')); 00125 $this->_redirect('*/*/edit', array('user_id' => $id)); 00126 return; 00127 } 00128 try { 00129 $model = Mage::getModel('admin/user'); 00130 $model->setId($id); 00131 $model->delete(); 00132 Mage::getSingleton('adminhtml/session')->addSuccess($this->__('User was successfully deleted')); 00133 $this->_redirect('*/*/'); 00134 return; 00135 } 00136 catch (Exception $e) { 00137 Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); 00138 $this->_redirect('*/*/edit', array('user_id' => $this->getRequest()->getParam('user_id'))); 00139 return; 00140 } 00141 } 00142 Mage::getSingleton('adminhtml/session')->addError($this->__('Unable to find a user to delete')); 00143 $this->_redirect('*/*/'); 00144 }
editAction | ( | ) |
Definition at line 52 of file UserController.php.
00053 { 00054 $id = $this->getRequest()->getParam('user_id'); 00055 $model = Mage::getModel('admin/user'); 00056 00057 if ($id) { 00058 $model->load($id); 00059 if (! $model->getId()) { 00060 Mage::getSingleton('adminhtml/session')->addError($this->__('This user no longer exists')); 00061 $this->_redirect('*/*/'); 00062 return; 00063 } 00064 } 00065 // Restore previously entered form data from session 00066 $data = Mage::getSingleton('adminhtml/session')->getUserData(true); 00067 if (!empty($data)) { 00068 $model->setData($data); 00069 } 00070 00071 Mage::register('permissions_user', $model); 00072 00073 $this->_initAction() 00074 ->_addBreadcrumb($id ? $this->__('Edit User') : $this->__('New User'), $id ? $this->__('Edit User') : $this->__('New User')) 00075 ->_addContent($this->getLayout()->createBlock('adminhtml/permissions_user_edit')->setData('action', $this->getUrl('*/permissions_user/save'))) 00076 ->_addLeft($this->getLayout()->createBlock('adminhtml/permissions_user_edit_tabs')); 00077 00078 $this->_addJs($this->getLayout()->createBlock('adminhtml/template')->setTemplate('permissions/user_roles_grid_js.phtml')); 00079 $this->renderLayout(); 00080 }
indexAction | ( | ) |
Definition at line 40 of file UserController.php.
00041 { 00042 $this->_initAction() 00043 ->_addContent($this->getLayout()->createBlock('adminhtml/permissions_user')) 00044 ->renderLayout(); 00045 }
newAction | ( | ) |
roleGridAction | ( | ) |
Definition at line 159 of file UserController.php.
00160 { 00161 $this->getResponse() 00162 ->setBody($this->getLayout() 00163 ->createBlock('adminhtml/permissions_user_grid') 00164 ->toHtml() 00165 ); 00166 }
rolesGridAction | ( | ) |
Definition at line 146 of file UserController.php.
00147 { 00148 $id = $this->getRequest()->getParam('user_id'); 00149 $model = Mage::getModel('admin/user'); 00150 00151 if ($id) { 00152 $model->load($id); 00153 } 00154 00155 Mage::register('permissions_user', $model); 00156 $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/permissions_user_edit_tab_roles')->toHtml()); 00157 }
saveAction | ( | ) |
Definition at line 82 of file UserController.php.
00083 { 00084 if ($data = $this->getRequest()->getPost()) { 00085 $model = Mage::getModel('admin/user'); 00086 $model->setData($data); 00087 try { 00088 $model->save(); 00089 if ( $uRoles = $this->getRequest()->getParam('roles', false) ) { 00090 /*parse_str($uRoles, $uRoles); 00091 $uRoles = array_keys($uRoles);*/ 00092 if ( 1 == sizeof($uRoles) ) { 00093 $model->setRoleIds($uRoles) 00094 ->setRoleUserId($model->getUserId()) 00095 ->saveRelations(); 00096 } else if ( sizeof($uRoles) > 1 ) { 00097 //@FIXME: stupid fix of previous multi-roles logic. 00098 //@TODO: make proper DB upgrade in the future revisions. 00099 $rs = array(); 00100 $rs[0] = $uRoles[0]; 00101 $model->setRoleIds( $rs )->setRoleUserId( $model->getUserId() )->saveRelations(); 00102 } 00103 } 00104 Mage::getSingleton('adminhtml/session')->addSuccess($this->__('User was successfully saved')); 00105 Mage::getSingleton('adminhtml/session')->setUserData(false); 00106 $this->_redirect('*/*/edit', array('user_id' => $model->getUserId())); 00107 return; 00108 } catch (Exception $e) { 00109 Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); 00110 Mage::getSingleton('adminhtml/session')->setUserData($data); 00111 $this->_redirect('*/*/edit', array('user_id' => $model->getUserId())); 00112 return; 00113 } 00114 } 00115 $this->_redirect('*/*/'); 00116 }