/** * Executes Edit action for user private data. */ public function executeEditPrivateData() { $user_id = $this->getUser()->getId(); // logged user id if (!($user_private_data = UserPrivateData::find($user_id))) { $this->setNotFoundAndRedirect(); } if ($this->getRequest()->getMethod() == sfRequest::POST) { // user private data update $email = trim($this->getRequestParameter('email')); $password = trim($this->getRequestParameter('password')); $nickname = trim($this->getRequestParameter('edit_nickname')); $nickname = preg_replace('#\\s+#', ' ', $nickname); $toponame = trim($this->getRequestParameter('edit_topo_name')); $toponame = preg_replace('#\\s+#', ' ', $toponame); $is_profile_public = $this->getRequestParameter('is_profile_public'); $conn = sfDoctrine::Connection(); try { if (!empty($password)) { $user_private_data->setPassword($password); // since the password has been changed, we remove all the remember me keys // attached to this user. RememberKey::deleteUserKeys($user_id); } if (!is_null($email)) { $old_email = $user_private_data->getEmail(); if ($old_email != $email) { Sympa::updateEmail($old_email, $email); $user_private_data->setEmail($email); } } if ($nickname != $user_private_data->getUsername()) { $user_private_data->setUsername($nickname); } if ($toponame != $user_private_data->getTopoName()) { $user_private_data->setTopoName($toponame); } $user_private_data->setIsProfilePublic(!empty($is_profile_public)); $user_private_data->save(); $conn->commit(); $this->statsdIncrement('success'); // update cache $this->clearCache('users', $user_id, false, 'view'); } catch (Exception $e) { $conn->rollback(); $this->statsdIncrement('failure'); } // update user session $this->getUser()->setAttribute('username', $user_private_data->get('topo_name')); // little js update if ($this->isAjaxCall()) { sfLoader::loadHelpers(array('Javascript', 'Tag')); // update the name to use (after the welcome) // and be sure to reset password value $js = javascript_tag("\$('#name_to_use').html('" . $user_private_data->get('topo_name') . "');\n \$('#current_password').val('')"); } else { $js = ""; } if (!empty($password)) { // user updated is password. We need to update the login to punbb Punbb::signIn($user_private_data->getId(), $user_private_data->password); } $lang = $this->getUser()->getCulture(); return $this->setNoticeAndRedirect('Your private information have been successfully updated', "@document_by_id_lang?module=users&id={$user_id}&lang={$lang}", null, $js); } else { // display form //$this->user = $user; $this->user_private_data = $user_private_data; $this->setPageTitle($this->__('User account update')); } }