X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations.inc.php;h=390e81bb55dcb9ecba7061eaf526473f17a18e14;hb=e9e97a07a899d7583b0391a16d86fa427104ebcf;hp=1600a1bb2acee772b4ddf282cbb4e8309e8d0d81;hpb=e33b29e5c75ec3dd8ddcc2fac2509f862bb18596;p=platal.git diff --git a/include/validations.inc.php b/include/validations.inc.php index 1600a1b..390e81b 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -1,6 +1,6 @@ user = &$_user; + $this->formal = !$this->user->hasProfile(); $this->stamp = date('YmdHis'); $this->unique = $_unique; $this->type = $_type; @@ -221,8 +223,13 @@ abstract class Validate $mailer->addTo("\"{$this->user->fullName()}\" <{$this->user->bestEmail()}>"); $mailer->addCc("validation+{$this->type}@{$globals->mail->domain}"); - $body = ($this->user->isFemale() ? "Chère camarade,\n\n" : "Cher camarade,\n\n") - . $this->_mail_body($isok) + // If the user has no profile, we should be more formal as if she has one. + if ($this->formal) { + $body = ($this->user->isFemale() ? 'Bonjour Madame' : 'Bonjour Monsieur'); + } else { + $body = ($this->user->isFemale() ? 'Chère camarade' : 'Cher camarade'); + } + $body .= ",\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); @@ -383,7 +390,7 @@ abstract class Validate public function id() { - return $this->user->id() . '_' . $this->type . '_' . $this->stamp; + return str_replace(" ", "_", $this->user->id() . '_' . $this->type . '_' . $this->stamp); } // }}} @@ -463,7 +470,7 @@ abstract class ProfileValidate extends Validate * @param $_unique: set to false if a profile can have multiple requests of this type. * @param $_type: request's type. */ - public function __construct(User &$_user, Profile &$_profile, $_unique, $_type) + public function __construct(User $_user, Profile $_profile, $_unique, $_type) { parent::__construct($_user, $_unique, $_type); $this->profile = &$_profile; @@ -617,6 +624,25 @@ abstract class ProfileValidate extends Validate } // }}} + // {{{ function get_all_typed_requests() + + /** Same as get_typed_request() but return an array of objects. + */ + static public function get_all_typed_requests($type) + { + $res = XDB::iterRow('SELECT data + FROM requests + WHERE type = {?} + ORDER BY stamp', + $type); + $array = array(); + while (list($data) = $res->next()) { + $array[] = Validate::unserialize($data); + } + return $array; + } + + // }}} // {{{ function get_typed_requests_count() /** Same as get_typed_requests() but returns the count of available requests.