Exemplo n.º 1
0
 /**
  * Allows the users to update their profiles
  *
  * @access public
  * @return void
  */
 public function editAction()
 {
     $this->title = 'Edit your profile';
     $form = new ProfileForm();
     $userModel = new BackofficeUser();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $userModel->updateProfile($form->getValues());
             $this->_helper->FlashMessenger(array('msg-success' => 'Your profile was successfully updated.'));
             $this->_redirect('/profile/edit/');
         }
     } else {
         $user = Zend_Auth::getInstance()->getIdentity();
         $row = $userModel->findById($user->id);
         $form->populate($row->toArray());
         $this->view->item = $row;
     }
     $this->view->form = $form;
 }
Exemplo n.º 2
0
 /**
  * Reload the data of the user in the session
  *
  * @return void
  */
 public static function reloadSession()
 {
     $auth = Zend_Auth::getInstance();
     switch (CURRENT_MODULE) {
         case 'frontend':
             $userModel = new User();
             $user = $userModel->findById(self::getSession()->id);
             $user->get('group');
             break;
         case 'backoffice':
             $userModel = new BackofficeUser();
             $user = $userModel->findById(self::getSession()->id);
             $user->groups = $user->findManyToManyRowset('Group', 'BackofficeUserGroup');
             $user->group = $user->groups[0];
             break;
     }
     $session = new stdClass();
     foreach ($user as $k => $v) {
         $session->{$k} = $v;
     }
     $session->group->name = $user->get('group')->name;
     $auth->getStorage()->write($session);
 }
 /**
  * Allows users to logically delete other users
  * (should be reserved for administrators)
  *
  * @access public
  * @return void
  */
 public function deleteAction()
 {
     $this->title = 'Delete this user';
     $form = new DeleteForm();
     $userModel = new BackofficeUser();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $userModel->deleteById($form->getValue('id'));
             $this->_helper->FlashMessenger(array('msg-success' => 'The item was successfully deleted.'));
             App_FlagFlippers_Manager::save();
             $this->_redirect('/users/');
         }
     } else {
         $id = $this->_getParam('id');
         if (!is_numeric($id)) {
             $this->_helper->FlashMessenger(array('msg-error' => 'The id you provided is invalid.'));
             $this->_redirect('/users/');
         }
         if ($id == 1) {
             $this->_helper->FlashMessenger(array('msg-error' => 'It is forbidden to mess with the admin account in this release.'));
             $this->_redirect('/users/');
         }
         $row = $userModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-error' => 'The requested item cannot be found.'));
             $this->_redirect('/users/');
         }
         $this->view->item = $row;
         $form->populate($row->toArray());
     }
     $this->view->form = $form;
 }