/** 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); } } } }
public function editAction($uid) { $user = User::findUserByID($uid); if (!$user) { return $this->forward('errors/show404'); } if ($user->uid != $this->getAuth()["uid"]) { if (!Group::Permission_CanEditAll($this->getAuth()["groupid"])) { return $this->forward('errors/show401'); } } $form = new ProfileForm($user->usercard); if ($this->request->isPost()) { $data = $this->request->getPost(); if (!$form->isValid($data, $user->usercard)) { foreach ($form->getMessages() as $message) { $this->flash->error($message); } } else { if ($user->save() == false) { foreach ($user->getMessages() as $message) { $this->flash->error($message); } } else { $form->clear(); $this->flash->success("Profile was updated successfully"); return $this->forward("profile/view/{$uid}"); } } } $this->view->form = $form; $this->view->user = $user; }
public function executeProfile(sfWebRequest $request) { $user = $this->getUser(); $i18n = $this->getContext()->getI18N(); $form = new ProfileForm($user->getProfile(), array('user' => $user)); if ($request->isMethod('post')) { $config = $request->getParameter('config'); $form->bind($config); if ($form->isValid()) { $form->save(); $culture = $config['language']; if (isset($config['country'])) { $country = $config['country']; } else { $country = null; } if ($country) { $culture .= '_' . $country; } $user->setCulture($culture); $user->info($i18n->__('Your settings were successfully saved.')); $this->redirect('@profile'); } else { $user->error($i18n->__('Settings could not be saved. Please, check entered values and try to correct them.'), false); } } $this->form = $form; }
/** * 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; }