X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations.inc.php;h=b00fef36175a05380524b14dcd72592ef915a2ab;hb=315fa6ae2cbee21fec0ad56bda592a184860737a;hp=6af52e8454829c0408907a58082b0df10363b69e;hpb=917c4d112628836500785b42deceb5d03a822ab0;p=platal.git diff --git a/include/validations.inc.php b/include/validations.inc.php index 6af52e8..b00fef3 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -1,6 +1,6 @@ unique = $_unique; $this->type = $_type; $res = XDB::query( - "SELECT u.prenom, u.nom, u.promo, a.alias, b.alias + "SELECT u.prenom, u.nom, u.promo, FIND_IN_SET('femme', u.flags) AS sexe, a.alias, b.alias FROM auth_user_md5 AS u INNER JOIN aliases AS a ON ( u.user_id=a.id AND a.type='a_vie' ) INNER JOIN aliases AS b ON ( u.user_id=b.id AND b.type!='homonyme' AND FIND_IN_SET('bestalias', b.flags) ) WHERE u.user_id={?}", $_uid); - list($this->prenom, $this->nom, $this->promo, $this->forlife, $this->bestalias) = $res->fetchOneRow(); + list($this->prenom, $this->nom, $this->promo, $this->sexe, $this->forlife, $this->bestalias) = $res->fetchOneRow(); } // }}} @@ -177,12 +178,14 @@ class Validate return true; } } + if (!strlen(trim(Env::v('comm')))) { + return true; + } $this->comments[] = Array(S::v('bestalias'), Env::v('comm'), $formid); // envoi d'un mail à hotliners global $globals; - require_once('diogenes/diogenes.hermes.inc.php'); - $mailer = new HermesMailer; + $mailer = new PlMailer; $mailer->setSubject("Commentaires de validation {$this->type}"); $mailer->setFrom("validation+{$this->type}@{$globals->mail->domain}"); $mailer->addTo("hotliners@staff.polytechnique.org"); @@ -232,14 +235,13 @@ class Validate function sendmail($isok) { global $globals; - require_once('diogenes/diogenes.hermes.inc.php'); - $mailer = new HermesMailer; + $mailer = new PlMailer(); $mailer->setSubject($this->_mail_subj()); $mailer->setFrom("validation+{$this->type}@{$globals->mail->domain}"); $mailer->addTo("\"{$this->prenom} {$this->nom}\" <{$this->bestalias}@{$globals->mail->domain}>"); $mailer->addCc("validation+{$this->type}@{$globals->mail->domain}"); - $body = "Cher(e) camarade,\n\n" + $body = ($this->sexe ? "Chère camarade,\n\n" : "Cher camarade,\n\n") . $this->_mail_body($isok) . (Env::has('comm') ? "\n\n".Env::v('comm') : '') . "\n\nCordialement,\nL'équipe Polytechnique.org\n"; @@ -257,7 +259,7 @@ class Validate } // }}} - // {{{ function get_request() + // {{{ function get_typed_request() /** fonction statique qui renvoie la requête de l'utilisateur d'id $uidau timestamp $t * @param $uid l'id de l'utilisateur concerné @@ -265,9 +267,9 @@ class Validate * @param $stamp le timestamp de la requête * * XXX fonction "statique" XXX - * à utiliser uniquement pour récupérer un objet dans la BD avec Validate::get_request(...) + * à utiliser uniquement pour récupérer un objet dans la BD avec Validate::get_typed_request(...) */ - function get_request($uid, $type, $stamp = -1) + static function get_typed_request($uid, $type, $stamp = -1) { if ($stamp == -1) { $res = XDB::query('SELECT data FROM requests WHERE user_id={?} and type={?}', $uid, $type); @@ -283,6 +285,21 @@ class Validate } // }}} + // {{{ function get_typed_requests() + + /** same as get_typed_request() but return an array of objects + */ + static function get_typed_requests($uid, $type) + { + $res = XDB::iterRow('SELECT data FROM requests WHERE user_id={?} and type={?}', $uid, $type); + $array = array(); + while (list($data) = $res->next()) { + $array[] = unserialize($data); + } + return $array; + } + + // }}} // {{{ function _mail_body function _mail_body($isok)