Exemplo n.º 1
0
 public function settingsAction()
 {
     $this->view->headTitle()->append('Edit user settings');
     $this->__getCrumbs()->add('Edit user settings', [], 'admin-user-settings');
     /** @var Application_Model_User_Profile $user */
     $user = $this->_getItemById($this->getParam('id'));
     if (!$this->_user->getRole()->isSubordinate($user->getUser()->getRole())) {
         $this->redirect(RM_View_Top::getInstance()->getBreadcrumbs()->getBack());
     }
     $this->view->email = $user->getEmail();
     if ($this->getRequest()->isPost()) {
         try {
             $data = (object) $this->getRequest()->getPost();
             $user->setStatus($data->user_status);
             $role = RM_User_Role::getById($data->user_type);
             if (!$this->_user->getRole()->isSubordinate($role)) {
                 throw new Exception('Permission denied');
             }
             $user->getUser()->setRole($role);
             $user->save();
             $this->__goBack();
         } catch (Exception $e) {
             $this->view->showMessage($e);
         }
     } else {
         $_POST['user_status'] = $user->getStatus();
         $_POST['user_type'] = $user->getUser()->getRole()->getId();
     }
     $this->_entity = $user;
 }
Exemplo n.º 2
0
 public function GetUserRoles()
 {
     $data = array();
     $user = RM_User_Session::getInstance()->getUser();
     foreach (RM_User_Role::getList() as $role) {
         /* @var RM_User_Role $role */
         if ($user->getRole()->isSubordinate($role)) {
             $data[$role->getId()] = $role->getShortDesc();
         }
     }
     return $data;
 }
Exemplo n.º 3
0
 public function moreRole(RM_User_Role $role)
 {
     $this->_select->where('roles.hierarchy < ?', $role->getHierarchy());
 }