Exemplo n.º 1
0
 /**
  * @task internal
  */
 private function willAddEmail(PhabricatorUserEmail $email)
 {
     // Hard check before write to prevent creation of disallowed email
     // addresses. Normally, the application does checks and raises more
     // user friendly errors for us, but we omit the courtesy checks on some
     // pathways like administrative scripts for simplicity.
     if (!PhabricatorUserEmail::isAllowedAddress($email->getAddress())) {
         throw new Exception(PhabricatorUserEmail::describeAllowedAddresses());
     }
 }
 private function loadUserForEmail(PhabricatorUserEmail $email)
 {
     $user = id(new PhabricatorHandleQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs(array($email->getUserPHID()))->executeOne();
     if (!$user) {
         throw new Exception(pht('Email record ("%s") has bad associated user PHID ("%s").', $email->getAddress(), $email->getUserPHID()));
     }
     return $user;
 }
Exemplo n.º 3
0
    /**
     * Send a notification email from $user to this address, informing the
     * recipient that this is no longer their account's primary address.
     *
     * @param PhabricatorUser The user sending the notification.
     * @param PhabricatorUserEmail New primary email address.
     * @return this
     * @task email
     */
    public function sendOldPrimaryEmail(PhabricatorUser $user, PhabricatorUserEmail $new)
    {
        $username = $user->getUsername();
        $old_address = $this->getAddress();
        $new_address = $new->getAddress();
        $body = <<<EOBODY
Hi {$username},

This email address ({$old_address}) is no longer your primary email address.
Going forward, Phabricator will send all email to your new primary email
address ({$new_address}).

EOBODY;
        id(new PhabricatorMetaMTAMail())->addRawTos(array($old_address))->setForceDelivery(true)->setSubject('[Phabricator] Primary Address Changed')->setBody($body)->setFrom($user->getPHID())->setRelatedPHID($user->getPHID())->saveAndSend();
    }
Exemplo n.º 4
0
 /**
  * Send a notification email from $user to this address, informing the
  * recipient that this is no longer their account's primary address.
  *
  * @param PhabricatorUser The user sending the notification.
  * @param PhabricatorUserEmail New primary email address.
  * @return this
  * @task email
  */
 public function sendOldPrimaryEmail(PhabricatorUser $user, PhabricatorUserEmail $new)
 {
     $username = $user->getUsername();
     $old_address = $this->getAddress();
     $new_address = $new->getAddress();
     $body = sprintf("%s\n\n%s\n", pht('Hi %s', $username), pht('This email address (%s) is no longer your primary email address. ' . 'Going forward, Phabricator will send all email to your new primary ' . 'email address (%s).', $old_address, $new_address));
     id(new PhabricatorMetaMTAMail())->addRawTos(array($old_address))->setForceDelivery(true)->setSubject(pht('[Phabricator] Primary Address Changed'))->setBody($body)->setFrom($user->getPHID())->setRelatedPHID($user->getPHID())->saveAndSend();
 }
 /**
  * @task internal
  */
 private function willAddEmail(PhabricatorUserEmail $email)
 {
     // Hard check before write to prevent creation of disallowed email
     // addresses. Normally, the application does checks and raises more
     // user friendly errors for us, but we omit the courtesy checks on some
     // pathways like administrative scripts for simplicity.
     if (!PhabricatorUserEmail::isValidAddress($email->getAddress())) {
         throw new Exception(PhabricatorUserEmail::describeValidAddresses());
     }
     if (!PhabricatorUserEmail::isAllowedAddress($email->getAddress())) {
         throw new Exception(PhabricatorUserEmail::describeAllowedAddresses());
     }
     $application_email = id(new PhabricatorMetaMTAApplicationEmailQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withAddresses(array($email->getAddress()))->executeOne();
     if ($application_email) {
         throw new Exception($application_email->getInUseMessage());
     }
 }