/** 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); } } } }
/** * 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; }
/** * * @param sfWebRequest $request * @param ProfileForm $form */ protected function processEdit(sfWebRequest $request, ProfileForm $form) { $form->bind($request->getParameter('profile')); if ($form->isValid()) { $values = $form->getValues(); $user = $this->getUser()->getGuardUser(); if ($user->checkPassword($values['current_password'])) { // Set new password into sfGuardUser table if (!empty($values['new_password']) && $values['new_password'] == $values['confirm_new_password']) { $user->setPassword($values['new_password']); } $user->setFirstName($values['first_name']); $user->setLastName($values['last_name']); $user->setEmailAddress($values['email']); $user->save(); // Set referer $this->getUser()->setReferer($request->getUri()); // Redirect to referer $this->redirect($this->getUser()->getReferer()); } } }
/** * Edit action, Allow the User to update his profil * @author EL GUENNUNI Sohaib s.elguennuni@gmail.com * @param <empty> * @return <empty> */ public function editAction() { $this->title = 'Edit your account'; $form = new ProfileForm(); if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getPost())) { $data = $form->getValues(); $value_id = $this->_rvCityModel->searchCity($form->getValue('name')); if ($value_id) { $data['rv_city_id'] = $value_id; } else { $data['rv_city_id'] = $this->_rvCityModel->addCity($form->getValue('name')); } $this->_memberModel->updateMember($data); $this->_redirect($this->view->url(array('module' => 'frontend', 'controller' => 'account', 'action' => 'display'), 'default', true)); } } else { $row = $this->_memberModel->getMember($this->_idMember); $form->populate($row->toArray()); $this->view->item = $row; } $this->view->form = $form; }