示例#1
0
 /**
  * Constructor to enhance the base form to edit a user
  * 
  * @param array $groups
  * @param Admin_Model_DbRow_User $user
  */
 public function __construct(array $groups, Admin_Model_DbRow_User $user)
 {
     parent::__construct($groups);
     $this->addElement(new Zend_Form_Element_Hidden('id', array('value' => $user->get('id'), 'validators' => array('Int'))));
     $this->getElement('name')->setValue($user->get('name'));
     $this->getElement('username')->setValue($user->get('username'));
     $this->getElement('mail')->setValue($user->get('email'));
     $this->getElement('active')->setChecked($user->get('enabled') == 1 ? TRUE : FALSE);
     $this->getElement('group')->setValue($user->get('groupid'));
 }
 /**
  * Create form, so that the admin can change the users password
  *
  * @param Admin_Model_DbRow_User $user
  */
 public function __construct(Admin_Model_DbRow_User $user)
 {
     $this->addElements(array(new Zend_Form_Element_Password('pass1', array('required' => true, 'label' => 'Password:'******'attribs' => array('class' => 'text span-5'), 'validators' => array('notEmpty', array('StringLength', false, array(8, 64))))), new Zend_Form_Element_Password('pass2', array('required' => true, 'label' => 'Repeat Password:'******'attribs' => array('class' => 'text span-5'), 'validators' => array('notEmpty', array('StringLength', false, array(8, 64))))), new Zend_Form_Element_Hidden('id', array('required' => true, 'value' => $user->get('id'))), new Zend_Form_Element_Submit('changepass', array('label' => 'Save'))));
     parent::__construct();
 }
 /**
  * Load all roles for roles listing
  *
  * @return array
  */
 public function loadRoleRolesAction()
 {
     $return = array();
     $roleModel = new Admin_Model_DbTable_Acl_Role();
     $roleMemberModel = new Admin_Model_DbTable_Acl_RoleMember();
     $roleInheritModel = new Admin_Model_DbTable_Acl_RoleInherit();
     $roles = $roleModel->fetchAll();
     foreach ($roles as $roleRow) {
         $users = $groups = $inherits = array();
         $role = new Admin_Model_DbRow_Role($roleRow);
         foreach ($roleMemberModel->getRoleUsers($roleRow['uar_id']) as $userRow) {
             $user = new Admin_Model_DbRow_User($userRow);
             $users[] = $user->toJsonArray();
         }
         foreach ($roleMemberModel->getRoleGroups($roleRow['uar_id']) as $groupRow) {
             $group = new Admin_Model_DbRow_Group($groupRow);
             $groups[] = $group->toJsonArray();
         }
         foreach ($roleInheritModel->getRoleInheritance($roleRow['uar_id']) as $inheritRow) {
             $inherit = new Admin_Model_DbRow_Role($inheritRow);
             $inherits[] = $inherit->toJsonArray();
         }
         $return[] = array_merge($role->toJsonArray(), array('users' => $users, 'groups' => $groups, 'inherits' => $inherits));
     }
     return $this->responseSuccess(array('roles' => $return));
 }
 /**
  * Change the password of an user
  *
  * @view /views/scripts/user/changepassword.phtml
  * @access public
  */
 public function changepasswordAction()
 {
     $userRow = new Admin_Model_DbRow_User($this->dbUser->find($this->checkUserIdParam()));
     $form = new Admin_Form_User_Changepassword($userRow);
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getParams()) && $this->getRequest()->getParam('pass1') === $this->getRequest()->getParam('pass2')) {
             $salt = Zend_Registry::get('password_salt');
             $hashpass = md5($this->getRequest()->getParam('pass1') . $salt);
             // do the update
             $this->dbUser->updatePassword($hashpass, $userRow->get('id'));
             $this->_redirect('admin/user/index');
         } else {
             $form->setDescription('Please fill both fields and ensure, that both passwords are equal');
         }
     }
     $this->view->form = $form;
 }