X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations.inc.php;h=b268fb6863f0c30fe3c97b8d57101d85719abbfb;hb=c67b874fd8d442bfded35295a819e7ce11a2d6dc;hp=c3af12ef82ac931233d3d89e5f69952e299f70a3;hpb=d134ddda91e67ef3e5897e764a6758ba5b2af25d;p=platal.git diff --git a/include/validations.inc.php b/include/validations.inc.php index c3af12e..b268fb6 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -31,7 +31,7 @@ class ValidateIterator extends XOrgDBIterator { // {{{ constuctor - public function __construct () + public function __construct() { parent::__construct('SELECT data, DATE_FORMAT(stamp, "%Y%m%d%H%i%s") FROM requests @@ -437,6 +437,7 @@ abstract class ProfileValidate extends Validate public $profile; public $profileOwner; public $userIsProfileOwner; + public $ownerIsRegistered; // }}} // {{{ constructor @@ -453,11 +454,9 @@ abstract class ProfileValidate extends Validate parent::__construct($_user, $_unique, $_type); $this->profile = &$_profile; $this->profileOwner = $this->profile->owner(); - if (!is_null($this->profileOwner) && $this->profileOwner->id() == $this->user->id()) { - $this->userIsProfileOwner = true; - } else { - $this->userIsProfileOwner = false; - } + $this->userIsProfileOwner = (!is_null($this->profileOwner) + && $this->profileOwner->id() == $this->user->id()); + $this->ownerIsRegistered = $this->profile->isActive(); } // }}} @@ -525,24 +524,23 @@ abstract class ProfileValidate extends Validate protected function sendmail($isok) { - global $globals; - $mailer = new PlMailer(); - $mailer->setSubject($this->_mail_subj()); - $mailer->setFrom("validation+{$this->type}@{$globals->mail->domain}"); - $mailer->addTo("\"{$this->profile->fullName()}\" <{$this->profileOwner->bestEmail()}>"); - if (!$this->userIsProfileOwner) { - $mailer->addCc("\"{$this->user->fullName()}\" <{$this->user->bestEmail()}>"); - } - $mailer->addCc("validation+{$this->type}@{$globals->mail->domain}"); - - $body = ($this->profile->isFemale() ? "Chère camarade,\n\n" : "Cher camarade,\n\n") - . $this->_mail_body($isok) - . (Env::has('comm') ? "\n\n" . Env::v('comm') : '') - . "\n\nCordialement,\n-- \nL'équipe de Polytechnique.org\n" - . $this->_mail_ps($isok); + // Only sends email if the profile's owner exists and is registered. + if ($this->ownerIsRegistered) { + global $globals; - $mailer->setTxtBody(wordwrap($body)); - $mailer->send(); + $mailer = new PlMailer(); + $mailer->setSubject($this->_mail_subj()); + $mailer->setFrom("validation+{$this->type}@{$globals->mail->domain}"); + $mailer->addTo("\"{$this->profile->fullName()}\" <{$this->profileOwner->bestEmail()}>"); + $mailer->addCc("validation+{$this->type}@{$globals->mail->domain}"); + $body = ($this->profile->isFemale() ? "Chère camarade,\n\n" : "Cher camarade,\n\n") + . $this->_mail_body($isok) + . (Env::has('comm') ? "\n\n" . Env::v('comm') : '') + . "\n\nCordialement,\n-- \nL'équipe de Polytechnique.org\n" + . $this->_mail_ps($isok); + $mailer->setTxtBody(wordwrap($body)); + $mailer->send(); + } } // }}}