Пример #1
0
 public function editAction()
 {
     $model = new Default_Model_User();
     $form = new Default_Form_User();
     $form->removeElement('handle');
     $request = $this->getRequest();
     $id = $request->getParam('id');
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $data = $form->getValues();
             if ($data['password'] !== $data['password_again']) {
                 $this->addErrorMessage('Passwords do not match, please try again.');
                 $this->_redirect('/user/edit/id/' . $data['id']);
             }
             // Save data
             $model->update($data, $id);
             $this->addMessage('User updated.');
             $this->_redirect('/user/edit/id/' . $id);
         }
     } else {
         $user = $model->getUser($id);
         $this->view->handle = isset($user['handle']) ? $user['handle'] : false;
     }
     $this->view->form = $form;
 }
Пример #2
0
 public function editAction()
 {
     $model = new Default_Model_User();
     $form = new Default_Form_User();
     $form->removeElement('handle');
     $request = $this->getRequest();
     $id = $request->getParam('id');
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $data = $form->getValues();
             if ($data['password'] !== $data['password_again']) {
                 $this->addErrorMessage($this->tr->_('USER_PASSWORD_MISMATCH'));
                 $this->view->form = $form;
                 return;
             }
             // Save data
             $model->update($data, $id);
             $this->addMessage($this->tr->_('USER_UPDATE_SUCCESS'));
             $this->_redirect('/user');
         }
     } else {
         $user = $model->getUser($id);
         $this->view->handle = isset($user['handle']) ? $user['handle'] : false;
     }
     $this->view->form = $form;
 }
 /** Displays the edit profile form and posts the edited data to database.
  * 
  * @return NULL
  */
 public function indexAction()
 {
     $request = $this->getRequest();
     $form = new Default_Form_Editprofileform();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $user = new Default_Model_User();
             $session = new Zend_Session_Namespace('user');
             $user->getUserDetails();
             $data['username'] = $request->username;
             $data['password'] = $request->password;
             $data['firstname'] = $request->firstname;
             $data['lastname'] = $request->lastname;
             $data['place'] = $request->place;
             $user->setUserDetails($data);
             $user->update();
             $this->view->entries = 1;
         } else {
             $this->view->form = $form;
         }
     }
     $this->view->form = $form;
 }