Ejemplo n.º 1
0
 /** Edit the user details
  * @access public
  * @return void
  * @throws Pas_Exception
  */
 public function editAction()
 {
     $form = new ProfileForm();
     $form->removeElement('username');
     $form->removeElement('password');
     $this->view->form = $form;
     if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
         if ($form->isValid($form->getValues())) {
             $where = array();
             $where[] = $this->_users->getAdapter()->quoteInto('id = ?', $this->getIdentityForForms());
             $this->_users->update($form->getValues(), $where);
             $this->getFlash()->addMessage('You updated your profile successfully.');
             $this->_redirect('/users/account/');
         } else {
             $form->populate($form->getValues());
             $this->getFlash()->addMessage('You have some errors with your submission.');
         }
     } else {
         $id = (int) $this->getIdentityForForms();
         if ($id > 0) {
             $user = $this->_users->fetchRow('id =' . $this->getIdentityForForms())->toArray();
             if ($user) {
                 $form->populate($user);
             } else {
                 throw new Pas_Exception('No user account found with that id', 500);
             }
         }
     }
 }