public function save(Doctrine_Connection $conn = null) { if (is_null($this->_get('username')) && is_null($this->_get('email_address'))) { return; //throw new sfException('Cannot save User with null username and email!'); } if ($this->isNew() && sfGuardUserTable::getIfValidatedUserHasUsername($this->_get('username'))) { throw new sfException('Cannot save user. This username has already been validated with another user.'); } if (!$this->isNew() && in_array('is_validated', $this->_modified) && !$this->_get('is_validated')) { /* The user has been un-validated, probably due to changing their * Reddit validation key by username or password. We need to send * them an email about it. */ $parameters = array('user_id' => $this->getIncremented()); $prefer_html = $this->getPreferHtml(); $address = $this->getEmailAddress(); $name = $this->getPreferredName() ? $this->getPreferredName() : $this->getFullName(); $email = EmailTable::getInstance()->getFirstByEmailTypeAndLanguage('ChangeRedditKey', $this->getPreferredLanguage()); $subject = $email->generateSubject($parameters); $body = $email->generateBodyText($parameters, $prefer_html); $from = sfConfig::get('app_email_address', ProjectConfiguration::getApplicationName() . ' <' . ProjectConfiguration::getApplicationEmailAddress() . '>'); AppMail::sendMail($address, $from, $subject, $body, $prefer_html ? $body : null); $this->addLoginMessage('You have changed information relating to your Reddit user and will need to validate your Reddit username again. Please see your email for more information.'); } parent::save($conn); }