public function executeEmail(sfWebRequest $request) { $this->user = PcUserPeer::getLoggedInUser(); $this->form = new EditEmailForm(); $fields = array(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('email')); if ($this->form->isValid()) { $fields = $request->getParameter('email'); if (PcUserPeer::emailExist($fields['email1'])) { $loginLink = sfContext::getInstance()->getController()->genUrl('@login'); $forgottenPasswordLink = sfContext::getInstance()->getController()->genUrl('@forgotten-password'); $this->getUser()->setFlash('email_wrong', __('ACCOUNT_SETTINGS_EMAIL_EXISTS_ERROR')); } else { $user = PcUserPeer::getLoggedInUser(); // logging this change $emailChange = new PcEmailChangeHistory(); $emailChange->setUserId($user->getId()); $emailChange->setOldEmail($user->getEmail()); $emailChange->setNewEmail($fields['email1']); $emailChange->save(); $user->setEmail($fields['email1']); $user->save(); sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent('userSetEmail', 'user.set_email', array('user' => $user))); $this->getUser()->setFlash('settingSuccess', __('ACCOUNT_SETTINGS_EMAIL_RESET_SUCCESS')); $this->forward('settings', 'index'); } } } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param PcEmailChangeHistory $value A PcEmailChangeHistory object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(PcEmailChangeHistory $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = serialize(array((string) $obj->getId(), (string) $obj->getUserId())); } // if key === null self::$instances[$key] = $obj; } }