From 5daf68f6846682e439570b5245a6109ada8d9304 Mon Sep 17 00:00:00 2001 From: Vincent Zanotti Date: Sun, 24 Aug 2008 16:02:15 +0200 Subject: [PATCH] Migrates the validation architecture to an User-based model, instead of the deprecated uid-model. Please note that this commit invalidates existing requests. Signed-off-by: Vincent Zanotti --- bin/cron/homonymes.php | 8 ++-- bin/lists.create_promo.php | 10 ++++- include/googleapps.inc.php | 2 +- include/marketing.inc.php | 15 ++++--- include/validations.inc.php | 47 +++++++------------- include/validations/aliases.inc.php | 28 +++++++----- include/validations/broken.inc.php | 71 ++++++++++++------------------ include/validations/evts.inc.php | 8 ++-- include/validations/googleapps.inc.php | 8 ++-- include/validations/homonymes.inc.php | 28 ++++++------ include/validations/listes.inc.php | 6 +-- include/validations/marketing.inc.php | 31 +++++-------- include/validations/medals.inc.php | 10 ++--- include/validations/nl.inc.php | 6 +-- include/validations/nomusage.inc.php | 20 +++++---- include/validations/orange.inc.php | 10 ++--- include/validations/paiements.inc.php | 7 ++- include/validations/photos.inc.php | 10 ++--- include/validations/surveys.inc.php | 6 +-- modules/admin.php | 2 +- modules/email.php | 2 +- modules/events.php | 2 +- modules/lists.php | 2 +- modules/marketing.php | 30 ++++++------- modules/newsletter.php | 2 +- modules/profile.php | 9 ++-- modules/profile/decos.inc.php | 2 +- modules/survey/survey.inc.php | 2 +- modules/xnetevents.php | 2 +- modules/xnetgrp.php | 4 +- templates/admin/valider.tpl | 10 ++--- templates/include/form.valid.broken.tpl | 2 +- templates/include/form.valid.homonymes.tpl | 2 +- templates/include/form.valid.mark.tpl | 2 +- templates/include/form.valid.orange.tpl | 4 +- templates/include/form.valid.paiements.tpl | 2 +- templates/include/form.valid.photos.tpl | 4 +- templates/marketing/broken.tpl | 25 +++++------ 38 files changed, 209 insertions(+), 232 deletions(-) diff --git a/bin/cron/homonymes.php b/bin/cron/homonymes.php index 9cfc622..90e106a 100755 --- a/bin/cron/homonymes.php +++ b/bin/cron/homonymes.php @@ -33,9 +33,11 @@ $resRobot = XDB::iterator("SELECT id, alias, expire FROM aliases WHERE (expire = if ($resRobot->total()) { require_once('validations/homonymes.inc.php'); while ($old = $resRobot->next()) { - $res = XDB::query("SELECT alias AS forlife FROM homonymes INNER JOIN aliases ON(user_id = id) WHERE homonyme_id = {?} AND type='a_vie'", $old['id']); - $forlifes = $res->fetchColumn(); - $req = new HomonymeReq($old['id'], $old['alias'], $forlifes, $old['expire'] > date("Y-m-d")); + $res = XDB::query("SELECT alias AS forlife FROM homonymes INNER JOIN aliases ON(user_id = id) WHERE homonyme_id = {?} AND type='a_vie'", $old['id']); + $forlifes = $res->fetchColumn(); + + $user = User::getSilent($old['id']); + $req = new HomonymeReq($user, $old['alias'], $forlifes, $old['expire'] > date("Y-m-d")); $req->submit(); } } diff --git a/bin/lists.create_promo.php b/bin/lists.create_promo.php index 34eb213..35a1200 100755 --- a/bin/lists.create_promo.php +++ b/bin/lists.create_promo.php @@ -17,10 +17,18 @@ EOF; exit; } +// Retrieves list parameters. $promo = intval($opt['p']); $owner = $opt['o']; -$req = new ListeReq(0, false, "promo$promo", $globals->mail->domain, "Liste de la promotion $promo", +$owner_user = User::getSilent($owner); +if (!$owner_user) { + echo "Supplied owner is not valid, aborting.\n"; + exit 1; +} + +// Creates the list. +$req = new ListeReq($owner_user, false, "promo$promo", $globals->mail->domain, "Liste de la promotion $promo", 1 /*private*/, 2 /*moderate*/, 0 /*free subscription*/, array($owner), array()); $req->submit(); diff --git a/include/googleapps.inc.php b/include/googleapps.inc.php index 45337d4..c0a944e 100644 --- a/include/googleapps.inc.php +++ b/include/googleapps.inc.php @@ -336,7 +336,7 @@ class GoogleAppsAccount if (!$this->pending_update_suspension && !$this->pending_validation_unsuspend) { require_once('validations.inc.php'); - $unsuspend = new GoogleAppsUnsuspendReq($this->user->id()); + $unsuspend = new GoogleAppsUnsuspendReq($this->user); $unsuspend->submit(); $this->pending_validation_unsuspend = true; } diff --git a/include/marketing.inc.php b/include/marketing.inc.php index 52988c2..d488843 100644 --- a/include/marketing.inc.php +++ b/include/marketing.inc.php @@ -60,12 +60,13 @@ class Marketing global $globals; return array( - 'id' => $user->id(), - 'sexe' => $user->isFemale(), - 'mail' => $email, - 'forlife_email' => $user->login() . '@' . $globals->mail->domain, + 'user' => $user, + 'id' => $user->id(), + 'sexe' => $user->isFemale(), + 'mail' => $email, + 'to' => '"' . $user->fullName() . '" <' . $email . '>', + 'forlife_email' => $user->login() . '@' . $globals->mail->domain, 'forlife_email2' => $user->login() . '@' . $globals->mail->domain2, - 'to' => '"' . $user->fullName() . '" <' . $email . '>', ); } @@ -76,7 +77,7 @@ class Marketing if ($from == 'staff' || !($user = User::getSilent($sender))) { return '"L\'équipe de Polytechnique.org" mail->domain . '>'; } - return sprintf('"%s" <%s>', $user->fullName(), $user->bestEmail()); + return '"' . $user->fullName() . '" <' . $user->bestEmail() . '>'; } private function &getEngine($type, $data, $from) @@ -134,7 +135,7 @@ class Marketing $this->engine->process($this->user); if ($valid) { require_once 'validations.inc.php'; - $valid = new MarkReq($this->sender, $this->user['id'], $this->user['mail'], + $valid = new MarkReq(User::getSilent($this->sender), $this->user['user'], $this->user['mail'], $this->from == 'user', $this->type, $this->data); $valid->submit(); } diff --git a/include/validations.inc.php b/include/validations.inc.php index d5cd9e0..c0c60e6 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -59,13 +59,7 @@ abstract class Validate { // {{{ properties - public $uid; - public $prenom; - public $nom; - public $promo; - public $sexe; - public $bestalias; - public $forlife; + public $user; public $stamp; public $unique; @@ -81,23 +75,16 @@ abstract class Validate // {{{ constructor /** constructeur - * @param $_uid user id + * @param $_user user object * @param $_unique requête pouvant être multiple ou non * @param $_type type de la donnée comme dans le champ type de x4dat.requests */ - public function __construct($_uid, $_unique, $_type) + public function __construct(User $_user, $_unique, $_type) { - $this->uid = $_uid; + $this->user = $_user; $this->stamp = date('YmdHis'); $this->unique = $_unique; $this->type = $_type; - $res = XDB::query( - "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->sexe, $this->forlife, $this->bestalias) = $res->fetchOneRow(); } // }}} @@ -109,12 +96,12 @@ abstract class Validate public function submit() { if ($this->unique) { - XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}', $this->uid, $this->type); + XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}', $this->user->id(), $this->type); } $this->stamp = date('YmdHis'); XDB::execute('INSERT INTO requests (user_id, type, data, stamp) VALUES ({?}, {?}, {?}, {?})', - $this->uid, $this->type, $this, $this->stamp); + $this->user->id(), $this->type, $this, $this->stamp); global $globals; $globals->updateNbValid(); @@ -128,7 +115,7 @@ abstract class Validate { XDB::execute('UPDATE requests SET data={?}, stamp=stamp WHERE user_id={?} AND type={?} AND stamp={?}', - $this, $this->uid, $this->type, $this->stamp); + $this, $this->user->id(), $this->type, $this->stamp); return true; } @@ -144,10 +131,10 @@ abstract class Validate if ($this->unique) { $success = XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}', - $this->uid, $this->type); + $this->user->id(), $this->type); } else { $success = XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?} AND stamp={?}', - $this->uid, $this->type, $this->stamp); + $this->user->id(), $this->type, $this->stamp); } $globals->updateNbValid(); return $success; @@ -187,7 +174,7 @@ abstract class Validate if (!strlen(trim(Env::v('comm')))) { return true; } - $this->comments[] = Array(S::v('bestalias'), Env::v('comm'), $formid); + $this->comments[] = Array(S::user()->login(), Env::v('comm'), $formid); // envoi d'un mail à hotliners global $globals; @@ -196,10 +183,10 @@ abstract class Validate $mailer->setFrom("validation+{$this->type}@{$globals->mail->domain}"); $mailer->addTo($globals->core->admin_email); - $body = "Validation {$this->type} pour {$this->prenom} {$this->nom}\n\n" - . S::v('bestalias')." a ajouté le commentaire :\n\n" - . Env::v('comm')."\n\n" - . "cf la discussion sur : ".$globals->baseurl."/admin/validate"; + $body = "Validation {$this->type} pour {$this->user->id()}\n\n" + . S::user()->login() . " a ajouté le commentaire :\n\n" + . Env::v('comm') . "\n\n" + . "cf la discussion sur : " . $globals->baseurl . "/admin/validate"; $mailer->setTxtBody(wordwrap($body)); $mailer->send(); @@ -244,10 +231,10 @@ abstract class Validate $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->addTo("\"{$this->user->fullName()}\" <{$this->user->bestEmail()}>"); $mailer->addCc("validation+{$this->type}@{$globals->mail->domain}"); - $body = ($this->sexe ? "Chère camarade,\n\n" : "Cher camarade,\n\n") + $body = ($this->user->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\n-- \nL'équipe de Polytechnique.org\n"; @@ -386,7 +373,7 @@ abstract class Validate public function id() { - return $this->uid . '_' . $this->type . '_' . $this->stamp; + return $this->user->id() . '_' . $this->type . '_' . $this->stamp; } // }}} diff --git a/include/validations/aliases.inc.php b/include/validations/aliases.inc.php index 44f5af7..9827253 100644 --- a/include/validations/aliases.inc.php +++ b/include/validations/aliases.inc.php @@ -39,10 +39,10 @@ class AliasReq extends Validate // }}} // {{{ constructor - public function __construct($_uid, $_alias, $_raison, $_public, $_stamp=0) + public function __construct(User $_user, $_alias, $_raison, $_public, $_stamp=0) { global $globals; - parent::__construct($_uid, true, 'alias', $_stamp); + parent::__construct($_user, true, 'alias', $_stamp); $this->alias = $_alias.'@'.$globals->mail->alias_dom; $this->raison = $_raison; $this->public = $_public; @@ -51,10 +51,15 @@ class AliasReq extends Validate SELECT v.alias FROM virtual_redirect AS vr INNER JOIN virtual AS v ON (v.vid=vr.vid AND v.alias LIKE '%@{$globals->mail->alias_dom}') - WHERE vr.redirect={?} OR vr.redirect={?}", - "{$this->forlife}@{$globals->mail->domain}", "{$this->forlife}@{$globals->mail->domain2}"); + WHERE vr.redirect = {?} OR vr.redirect = {?}", + $this->user->forlifeEmail(), + // TODO: remove this über-ugly hack. The issue is that you need + // to remove all @m4x.org addresses in virtual_redirect first. + $this->user->login() . '@' . $globals->mail->domain2); $this->old = $res->fetchOneCell(); - if (empty($this->old)) { unset($this->old); } + if (empty($this->old)) { + unset($this->old); + } } // }}} @@ -62,7 +67,7 @@ class AliasReq extends Validate static public function get_request($uid) { - return parent::get_typed_request($uid,'alias'); + return parent::get_typed_request($uid, 'alias'); } // }}} @@ -115,17 +120,16 @@ class AliasReq extends Validate public function commit () { XDB::execute("UPDATE auth_user_quick SET emails_alias_pub = {?} WHERE user_id = {?}", - $this->public, $this->uid); + $this->public, $this->user->id()); if ($this->old) { - return XDB::execute('UPDATE virtual SET alias={?} WHERE alias={?}', + return XDB::execute("UPDATE virtual SET alias = {?} WHERE alias = {?}", $this->alias, $this->old); } else { - XDB::execute('INSERT INTO virtual SET alias={?},type="user"', $this->alias); + XDB::execute("INSERT INTO virtual SET alias = {?},type='user'", $this->alias); $vid = XDB::insertId(); - $dom = $this->shorter_domain(); - return XDB::query('INSERT INTO virtual_redirect (vid,redirect) VALUES ({?}, {?})', - $vid, $this->forlife.'@'.$dom); + return XDB::query("INSERT INTO virtual_redirect (vid,redirect) VALUES ({?}, {?})", + $vid, $this->user->forlifeEmail()); } } diff --git a/include/validations/broken.inc.php b/include/validations/broken.inc.php index cd64eb5..31e3fc6 100644 --- a/include/validations/broken.inc.php +++ b/include/validations/broken.inc.php @@ -24,15 +24,9 @@ class BrokenReq extends Validate { // {{{ properties - public $m_forlife; - public $m_bestalias; - public $m_prenom; - public $m_nom; - public $m_promo; - public $m_sexe; - public $m_email; - public $old_email; + public $m_user; public $m_comment; + public $m_email; private $m_reactive = false; @@ -43,18 +37,12 @@ class BrokenReq extends Validate // }}} // {{{ constructor - public function __construct($sender, $user, $email, $comment = null) + public function __construct(User $sender, User $user, $email, $comment = null) { parent::__construct($sender, false, 'broken'); - $this->m_email = $email; + $this->m_user = $user; $this->m_comment = trim($comment); - $this->m_forlife = $user['forlife']; - $this->m_bestalias = $user['bestalias']; - $this->m_prenom = $user['prenom']; - $this->m_nom = $user['nom']; - $this->m_promo = $user['promo']; - $this->m_sexe = $user['sexe']; - $this->old_email = $user['email']; + $this->m_email = $email; } // }}} @@ -70,7 +58,7 @@ class BrokenReq extends Validate protected function _mail_subj() { - return "[Polytechnique.org] Récupération de {$this->m_prenom} {$this->m_nom} ({$this->m_promo})"; + return "[Polytechnique.org] Récupération de {$this->m_user->fullName()} ({$this->m_user->promo()})"; } // }}} @@ -79,16 +67,16 @@ class BrokenReq extends Validate protected function _mail_body($isok) { if ($isok && !$this->m_reactive) { - return " Un email de contact vient d'être envoyé" - ." à {$this->m_prenom} {$this->m_nom} ({$this->m_promo}) pour confirmer sa volonté de" - ." mettre à jour sa redirection Polytechnique.org !\n\n" - ."Merci de ta participation !\n"; + return " Un email de contact vient d'être envoyé à {$this->m_user->fullName()}" + . " ({$this->m_user->promo()}) pour confirmer sa volonté de" + . " mettre à jour sa redirection Polytechnique.org !\n\n" + . "Merci de ta participation !\n"; } elseif ($isok) { - return " L'adresse de redirection {$this->m_email} de {$this->m_prenom} {$this->m_nom} ({$this->m_promo}) " + return " L'adresse de redirection {$this->m_email} de {$this->m_user->fullName()} ({$this->m_user->promo()}) " ."vient d'être réactivée. Un email lui a été envoyé pour l'en informer.\n\n" ."Merci de ta participation !\n"; } else { - return " Nous n'utiliserons pas cette adresse pour contacter {$this->m_prenom} {$this->m_nom} ({$this->m_promo})."; + return " Nous n'utiliserons pas cette adresse pour contacter {$this->m_user->fullName()} ({$this->m_user->promo()})."; } } @@ -98,39 +86,34 @@ class BrokenReq extends Validate public function commit() { global $globals; - $email = $this->m_bestalias . '@' . $globals->mail->domain; + $email = $this->m_user->bestEmail(); - XDB::execute("UPDATE emails AS e - INNER JOIN aliases AS a ON (a.id = e.uid) - SET e.flags = 'active', panne_level = 2 - WHERE a.alias = {?} AND e.email = {?}", $this->m_forlife, $this->m_email); + XDB::execute("UPDATE emails + SET flags = 'active', panne_level = 2 + WHERE uid = {?} AND email = {?}", $this->m_user->id(), $this->m_email); if (XDB::affectedRows() > 0) { $this->m_reactive = true; $mailer = new PlMailer(); $mailer->setFrom('"Association Polytechnique.org" mail->domain . '>'); $mailer->addTo($email); - $mailer->setSubject("Mise à jour de ton adresse $email"); + $mailer->setSubject("Mise à jour de ton adresse {$email}"); $mailer->setTxtBody(wordwrap("Cher Camarade,\n\n" - . "Ton adresse $email étant en panne et ayant été informés que ta redirection {$this->m_email}, jusqu'à présent inactive, " - . "est fonctionnelle, nous venons de réactiver cette adresse.\n\n" - . "N'hésite pas à aller gérer toi-même tes redirections en te rendant à la page :\n" - . "https://www.polytechnique.org/emails/redirect\n" - . "Si tu as perdu ton mot de passe d'accès au site, tu peux également effectuer la procédure de récupération à l'adresse :\n" - . "https://www.polytechnique.org/recovery\n\n" - . "-- \nTrès Cordialement,\nL'Équipe de Polytechnique.org\n")); + . "Ton adresse {$email} étant en panne et ayant été informés que ta redirection {$this->m_email}, jusqu'à présent inactive, " + . "est fonctionnelle, nous venons de réactiver cette adresse.\n\n" + . "N'hésite pas à aller gérer toi-même tes redirections en te rendant à la page :\n" + . "https://www.polytechnique.org/emails/redirect\n" + . "Si tu as perdu ton mot de passe d'accès au site, tu peux également effectuer la procédure de récupération à l'adresse :\n" + . "https://www.polytechnique.org/recovery\n\n" + . "-- \nTrès Cordialement,\nL'Équipe de Polytechnique.org\n")); $mailer->send(); return true; } - $email = $this->m_bestalias . '@' . $globals->mail->domain; - if ($this->old_email) { + if ($this->m_user->email) { $subject = "Ton adresse $email semble ne plus fonctionner"; $reason = "Nous avons été informés que ton adresse $email ne fonctionne plus correctement par un camarade"; } else { - $res = XDB::iterRow("SELECT email - FROM emails AS e - INNER JOIN aliases AS a ON (a.id = e.uid) - WHERE a.alias = {?} AND e.flags = 'panne'", $this->m_forlife); + $res = XDB::iterRow("SELECT email FROM emails WHERE uid = {?} AND flags = 'panne'", $this->m_user->id()); $redirect = array(); while (list($red) = $res->next()) { list(, $redirect[]) = explode('@', $red); @@ -146,7 +129,7 @@ class BrokenReq extends Validate . ' sont hors-services depuis plusieurs mois.'; } } - $body = ($this->m_sexe ? 'Chère ' : 'Cher ') . $this->m_prenom . ",\n\n" + $body = ($this->m_user->isFemale() ? 'Chère ' : 'Cher ') . $this->m_user->displayName() . ",\n\n" . $reason . "\n\n" . "L'adresse {$this->m_email} nous a été communiquée, veux-tu que cette adresse devienne ta nouvelle " . "adresse de redirection ? Si oui, envoie nous des informations qui " diff --git a/include/validations/evts.inc.php b/include/validations/evts.inc.php index a75fab3..fbc3e81 100644 --- a/include/validations/evts.inc.php +++ b/include/validations/evts.inc.php @@ -41,9 +41,9 @@ class EvtReq extends Validate // }}} // {{{ constructor - public function __construct($_titre, $_texte, $_pmin, $_pmax, $_peremption, $_comment, $_uid, PlUpload &$upload = null) + public function __construct($_titre, $_texte, $_pmin, $_pmax, $_peremption, $_comment, User $_user, PlUpload &$upload = null) { - parent::__construct($_uid, false, 'evts'); + parent::__construct($_user, false, 'evts'); $this->titre = $_titre; $this->texte = $_texte; $this->pmin = $_pmin; @@ -137,7 +137,7 @@ class EvtReq extends Validate if (XDB::execute("INSERT INTO evenements SET user_id = {?}, creation_date=NOW(), titre={?}, texte={?}, peremption={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide,wiki')", - $this->uid, $this->titre, $this->texte, + $this->user->id(), $this->titre, $this->texte, $this->peremption, $this->pmin, $this->pmax)) { $eid = XDB::insertId(); if ($this->img) { @@ -148,7 +148,7 @@ class EvtReq extends Validate global $globals; if ($globals->banana->event_forum) { require_once 'banana/forum.inc.php'; - $banana = new ForumsBanana(User::getSilent($this->uid)); + $banana = new ForumsBanana($this->user); $post = $banana->post($globals->banana->event_forum, $globals->banana->event_reply, $this->titre, MiniWiki::wikiToText($this->texte, false, 0, 80)); diff --git a/include/validations/googleapps.inc.php b/include/validations/googleapps.inc.php index 52a008f..9dc33a3 100644 --- a/include/validations/googleapps.inc.php +++ b/include/validations/googleapps.inc.php @@ -26,9 +26,9 @@ class GoogleAppsUnsuspendReq extends Validate alors la raison s'affichera (mais seulement 24-48h après la suspension). Si l'utilisateur a désactivé lui-même son compte, la raison sera toujours vierge."; - public function __construct($_uid) + public function __construct(User $_user) { - parent::__construct($_uid, true, 'gapps-unsuspend'); + parent::__construct($_user, true, 'gapps-unsuspend'); } public function sendmail($isok) @@ -61,7 +61,7 @@ class GoogleAppsUnsuspendReq extends Validate public function commit() { require_once dirname(__FILE__) . '/../googleapps.inc.php'; - $account = new GoogleAppsAccount(User::get($this->forlife)); + $account = new GoogleAppsAccount($this->user); return $account->do_unsuspend(); } @@ -71,7 +71,7 @@ class GoogleAppsUnsuspendReq extends Validate "SELECT g_suspension FROM gapps_accounts WHERE g_account_name = {?}", - $this->forlife); + $this->user->login()); return $res->fetchOneCell(); } } diff --git a/include/validations/homonymes.inc.php b/include/validations/homonymes.inc.php index 88ddcf7..bf7c52d 100644 --- a/include/validations/homonymes.inc.php +++ b/include/validations/homonymes.inc.php @@ -37,11 +37,11 @@ class HomonymeReq extends Validate // }}} // {{{ constructor - public function __construct($_uid, $_loginbis, $_homonymes_forlife, $warning=true) + public function __construct(User $_user, $_loginbis, $_homonymes_forlife, $warning=true) { $this->warning = $warning; - parent::__construct($_uid, true, $this->title()); + parent::__construct($_user, true, $this->title()); $this->refuse = false; $this->loginbis = $_loginbis; @@ -53,7 +53,7 @@ class HomonymeReq extends Validate private function title() { - return $this->warning?'alerte alias':'robot répondeur'; + return ($this->warning ? 'alerte alias' : 'robot répondeur'); } // }}} @@ -70,7 +70,9 @@ class HomonymeReq extends Validate protected function _mail_subj() { global $globals; - return "[Polytechnique.org/Support] ".($this->warning?"Dans une semaine : suppression de l'alias":"Mise en place du robot")." $loginbis@" . $globals->mail->domain; + return "[Polytechnique.org/Support] " + . ($this->warning ? "Dans une semaine : suppression de l'alias " : "Mise en place du robot") + . " $loginbis@" . $globals->mail->domain; } // }}} @@ -84,7 +86,7 @@ class HomonymeReq extends Validate Comme nous t'en avons informé par email il y a quelques temps, pour respecter nos engagements en terme d'adresses email devinables, tu te verras bientôt retirer l'alias ".$this->loginbis."@".$globals->mail->domain." pour -ne garder que ".$this->forlife."@".$globals->mail->domain.". +ne garder que " . $this->user->forlifeEmail() . ". Toute personne qui écrira à ".$this->loginbis."@".$globals->mail->domain." recevra la réponse d'un robot qui l'informera que ".$this->loginbis."@".$globals->mail->domain." @@ -99,14 +101,14 @@ est ambigu pour des raisons d'homonymie et signalera ton email exact."; if (!$isok) return false; global $globals; $mailer = new PlMailer; - $cc = "support+homonyme@".$globals->mail->domain; - $FROM = "\"Support Polytechnique.org\" <$cc>"; + $cc = "support+homonyme@" . $globals->mail->domain; + $from = "\"Support Polytechnique.org\" <$cc>"; $mailer->setSubject($this->_mail_subj()); - $mailer->setFrom($FROM); - $mailer->addTo("\"{$this->prenom} {$this->nom}\" <{$this->bestalias}@{$globals->mail->domain}>"); + $mailer->setFrom($from); + $mailer->addTo("\"{$this->user->fullName()}\" <{$this->user->bestEmail()}>"); $mailer->addCc($cc); - $body = $this->prenom.",\n\n" + $body = $this->user->displayName() . ",\n\n" . $this->_mail_body($isok) . (Env::has('comm') ? "\n\n".Env::v('comm') : '') . "\n\nCordialement,\n\n-- \nL'équipe de Polytechnique.org\n"; @@ -121,10 +123,10 @@ est ambigu pour des raisons d'homonymie et signalera ton email exact."; { require_once('homonymes.inc.php'); - switch_bestalias($this->uid, $this->loginbis); + switch_bestalias($this->user->id(), $this->loginbis); if (!$this->warning) { - XDB::execute("UPDATE aliases SET type='homonyme',expire=NOW() WHERE alias={?}", $this->loginbis); - XDB::execute("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $this->uid, $this->uid); + XDB::execute("UPDATE aliases SET type = 'homonyme', expire = NOW() WHERE alias = {?}", $this->loginbis); + XDB::execute("REPLACE INTO homonymes (homonyme_id, user_id) VALUES({?}, {?})", $this->user->id(), $this->user->id()); } return true; diff --git a/include/validations/listes.inc.php b/include/validations/listes.inc.php index 35b79de..af02bfe 100644 --- a/include/validations/listes.inc.php +++ b/include/validations/listes.inc.php @@ -42,10 +42,10 @@ class ListeReq extends Validate // }}} // {{{ constructor - public function __construct($_uid, $_asso, $_liste, $_domain, $_desc, $_advertise, + public function __construct(User $_user, $_asso, $_liste, $_domain, $_desc, $_advertise, $_modlevel, $_inslevel, $_owners, $_members, $_stamp=0) { - parent::__construct($_uid, false, 'liste', $_stamp); + parent::__construct($_user, false, 'liste', $_stamp); $this->asso = $_asso; $this->liste = $_liste; @@ -143,7 +143,7 @@ class ListeReq extends Validate return 1; } - $list = new MMList(S::v('uid'), S::v('password'), $this->domain); + $list = new MMList(S::user()->id(), S::v('password'), $this->domain); $ret = $list->create_list($this->liste, utf8_decode($this->desc), $this->advertise, $this->modlevel, $this->inslevel, $this->owners, $this->members); diff --git a/include/validations/marketing.inc.php b/include/validations/marketing.inc.php index 2f62845..53a5e75 100644 --- a/include/validations/marketing.inc.php +++ b/include/validations/marketing.inc.php @@ -26,11 +26,8 @@ class MarkReq extends Validate public $perso; - public $m_id; + public $m_user; public $m_email; - public $m_nom; - public $m_prenom; - public $m_promo; public $m_relance; public $m_type; public $m_data; @@ -42,20 +39,14 @@ class MarkReq extends Validate // }}} // {{{ constructor - public function __construct($sender, $mark_id, $email, $perso, $type, $data) + public function __construct(User $sender, User $mark, $email, $perso, $type, $data) { parent::__construct($sender, false, 'marketing'); - $this->m_id = $mark_id; + $this->m_user = $mark; $this->m_email = $email; $this->perso = $perso; $this->m_type = $type; $this->m_data = $data; - - $res = XDB::query('SELECT u.nom, u.prenom, u.promo - FROM auth_user_md5 AS u - WHERE user_id = {?} - GROUP BY u.user_id', $mark_id); - list ($this->m_nom, $this->m_prenom, $this->m_promo) = $res->fetchOneRow(); } // }}} @@ -68,7 +59,7 @@ class MarkReq extends Validate LEFT JOIN register_pending AS p ON p.uid = u.user_id LEFT JOIN register_marketing AS m ON m.uid = u.user_id WHERE user_id = {?}', - $this->m_id); + $this->m_user->id()); $this->m_relance = $res->fetchOneCell(); return 'include/form.valid.mark.tpl'; } @@ -78,7 +69,7 @@ class MarkReq extends Validate protected function _mail_subj() { - return "[Polytechnique.org] Marketing de {$this->m_prenom} {$this->m_nom} ({$this->m_promo})"; + return "[Polytechnique.org] Marketing de {$this->m_user->fullName()} ({$this->m_user->promo()})"; } // }}} @@ -88,11 +79,13 @@ class MarkReq extends Validate { if ($isok) { return " Un email de marketing vient d'être envoyé " - .($this->perso ? 'en ton nom' : 'en notre nom') - ." à {$this->m_prenom} {$this->m_nom} ({$this->m_promo}) pour l'encourager à s'inscrire !\n\n" - ."Merci de ta participation !\n"; + . ($this->perso ? 'en ton nom' : 'en notre nom') + . " à {$this->m_user->fullName()} ({$this->m_user->promo()}) " + . "pour l'encourager à s'inscrire !\n\n" + . "Merci de ta participation !\n"; } else { - return " Nous n'avons pas jugé bon d'envoyer d'email de marketing à {$this->m_prenom} {$this->m_nom} ({$this->m_promo})."; + return " Nous n'avons pas jugé bon d'envoyer d'email de marketing à " + . "{$this->m_user->fullName()} ({$this->m_user->promo()})."; } } @@ -101,7 +94,7 @@ class MarkReq extends Validate public function commit() { - $market = Marketing::get($this->m_id, $this->m_email); + $market = Marketing::get($this->m_user->id(), $this->m_email); if ($market == null) { return false; } diff --git a/include/validations/medals.inc.php b/include/validations/medals.inc.php index 98d14d2..441a7b9 100644 --- a/include/validations/medals.inc.php +++ b/include/validations/medals.inc.php @@ -31,10 +31,10 @@ class MedalReq extends Validate // }}} // {{{ constructor - public function __construct($_uid, $_idmedal, $_subidmedal, $_stamp=0) + public function __construct(User $_user, $_idmedal, $_subidmedal, $_stamp=0) { - parent::__construct($_uid, false, 'medal', $_stamp); - $this->mid = $_idmedal; + parent::__construct($_user, false, 'medal', $_stamp); + $this->mid = $_idmedal; $this->gid = $_subidmedal; } @@ -101,10 +101,10 @@ class MedalReq extends Validate public function commit () { require_once 'notifs.inc.php'; - register_watch_op($this->uid, WATCH_FICHE, 'medals'); + register_watch_op($this->user->id(), WATCH_FICHE, 'medals'); return XDB::execute('REPLACE INTO profile_medals_sub VALUES ({?}, {?}, {?})', - $this->uid, $this->mid, $this->gid); + $this->user->id(), $this->mid, $this->gid); } // }}} diff --git a/include/validations/nl.inc.php b/include/validations/nl.inc.php index 74ff546..9b24549 100644 --- a/include/validations/nl.inc.php +++ b/include/validations/nl.inc.php @@ -33,10 +33,10 @@ class NLReq extends Validate // }}} // {{{ constructor - public function __construct($uid, $title, $body, $append) + public function __construct(User $_user, $_title, $_body, $_append) { - parent::__construct($uid, false, 'nl'); - $this->art = new NLArticle($title, $body, $append); + parent::__construct($_user, false, 'nl'); + $this->art = new NLArticle($_title, $_body, $_append); } // }}} diff --git a/include/validations/nomusage.inc.php b/include/validations/nomusage.inc.php index b69fb43..b4471b0 100644 --- a/include/validations/nomusage.inc.php +++ b/include/validations/nomusage.inc.php @@ -44,13 +44,17 @@ class UsageReq extends Validate // }}} // {{{ constructor - public function __construct($_uid, $_usage, $_reason) + public function __construct(User $_user, $_usage, $_reason) { - parent::__construct($_uid, true, 'usage'); - $this->nom_usage = $_usage; + parent::__construct($_user, true, 'usage'); + $this->nom_usage = $_usage; $this->reason = $_reason; - $this->alias = make_username($this->prenom, $this->nom_usage); - if (!$this->nom_usage) $this->alias = ""; + + $res = XDB::query("SELECT prenom FROM auth_user_md5 WHERE user_id = {?}", $this->user->id()); + $this->alias = make_username($res->fetchOneCell(), $this->nom_usage); + if (!$this->nom_usage) { + $this->alias = ""; + } $res = XDB::query(" SELECT e.alias, u.nom_usage, a.id @@ -93,7 +97,7 @@ class UsageReq extends Validate } if ($globals->mailstorage->googleapps_domain) { require_once 'googleapps.inc.php'; - $account = new GoogleAppsAccount(User::get($this->uid)); + $account = new GoogleAppsAccount($this->user); if ($account->active()) { $res .= "\n\n Si tu utilises Google Apps, tu peux changer ton nom d'usage sur https://mail.google.com/a/polytechnique.org/#settings/accounts"; } @@ -110,9 +114,9 @@ class UsageReq extends Validate public function commit() { require_once 'notifs.inc.php'; - register_watch_op($this->uid, WATCH_FICHE, 'nom'); + register_watch_op($this->user->id(), WATCH_FICHE, 'nom'); require_once('user.func.inc.php'); - $this->bestalias = set_new_usage($this->uid, $this->nom_usage, $this->alias); + set_new_usage($this->user->id(), $this->nom_usage, $this->alias); return true; } diff --git a/include/validations/orange.inc.php b/include/validations/orange.inc.php index 1cf625c..a17285c 100644 --- a/include/validations/orange.inc.php +++ b/include/validations/orange.inc.php @@ -27,7 +27,6 @@ class OrangeReq extends Validate public $unique = true; - public $promo; public $promo_sortie; public $rules = "A priori accepter (la validation sert à repousser les @@ -37,12 +36,11 @@ class OrangeReq extends Validate // }}} // {{{ constructor - public function __construct($_uid, $_sortie) + public function __construct(User $_user, $_sortie) { - parent::__construct($_uid, true, 'orange'); + parent::__construct($_user, true, 'orange'); $this->promo_sortie = $_sortie; - $res = XDB::query("SELECT promo FROM auth_user_md5 WHERE user_id = {?}", $_uid); - $this->promo = $res->fetchOneCell(); + $res = XDB::query("SELECT promo FROM auth_user_md5 WHERE user_id = {?}", $_user->id()); } // }}} @@ -79,7 +77,7 @@ class OrangeReq extends Validate public function commit() { - XDB::execute("UPDATE auth_user_md5 set promo_sortie={?} WHERE user_id={?}",$this->promo_sortie ,$this->uid); + XDB::execute("UPDATE auth_user_md5 set promo_sortie = {?} WHERE user_id = {?}",$this->promo_sortie, $this->user->id()); return true; } diff --git a/include/validations/paiements.inc.php b/include/validations/paiements.inc.php index e0eca22..ec12a83 100644 --- a/include/validations/paiements.inc.php +++ b/include/validations/paiements.inc.php @@ -44,11 +44,11 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais // }}} // {{{ constructor - public function __construct($_uid, $_intitule, $_site, $_montant, $_msg, + public function __construct(User $_user, $_intitule, $_site, $_montant, $_msg, $_montantmin=0, $_montantmax=999, $_asso_id = 0, $_evt = 0, $_stamp=0) { - parent::__construct($_uid, false, 'paiements', $_stamp); + parent::__construct($_user, false, 'paiements', $_stamp); $this->titre = $_intitule; $this->site = $_site; @@ -165,7 +165,6 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais public function commit() { - global $globals; $res = XDB::query("SELECT MAX(id) FROM paiement.paiements"); $id = $res->fetchOneCell()+1; $ret = XDB::execute("INSERT INTO paiement.paiements VALUES @@ -175,7 +174,7 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais ", $id, $this->titre, $this->site, $this->montant, $this->montant_min, $this->montant_max, - $this->bestalias."@".$globals->mail->domain, $this->msg_reponse, $this->asso_id); + $this->user->bestEmail(), $this->msg_reponse, $this->asso_id); if ($this->asso_id && $this->evt) { XDB::execute("UPDATE groupex.evenements SET paiement_id = {?} diff --git a/include/validations/photos.inc.php b/include/validations/photos.inc.php index 7ed7d1e..93b0ec9 100644 --- a/include/validations/photos.inc.php +++ b/include/validations/photos.inc.php @@ -43,9 +43,9 @@ class PhotoReq extends Validate // }}} // {{{ constructor - public function __construct($_uid, PlUpload &$upload, $_stamp=0) + public function __construct(User $_user, PlUpload &$upload, $_stamp=0) { - parent::__construct($_uid, true, 'photo', $_stamp); + parent::__construct($_user, true, 'photo', $_stamp); $this->read($upload); } @@ -76,7 +76,7 @@ class PhotoReq extends Validate static public function get_request($uid) { - return parent::get_typed_request($uid,'photo'); + return parent::get_typed_request($uid, 'photo'); } // }}} @@ -140,8 +140,8 @@ class PhotoReq extends Validate require_once 'notifs.inc.php'; XDB::execute('REPLACE INTO photo (uid, attachmime, attach, x, y) VALUES ({?},{?},{?},{?},{?})', - $this->uid, $this->mimetype, $this->data, $this->x, $this->y); - register_watch_op($this->uid, WATCH_FICHE, 'photo'); + $this->user->id(), $this->mimetype, $this->data, $this->x, $this->y); + register_watch_op($this->user->id(), WATCH_FICHE, 'photo'); return true; } diff --git a/include/validations/surveys.inc.php b/include/validations/surveys.inc.php index 5a519b4..4c2fb02 100644 --- a/include/validations/surveys.inc.php +++ b/include/validations/surveys.inc.php @@ -33,9 +33,9 @@ class SurveyReq extends Validate // }}} // {{{ constructor - public function __construct($_title, $_description, $_end, $_mode, $_promos, $_questions, $_uid) + public function __construct($_title, $_description, $_end, $_mode, $_promos, $_questions, User $_user) { - parent::__construct($_uid, false, 'surveys'); + parent::__construct($_user, false, 'surveys'); $this->title = $_title; $this->description = $_description; $this->end = $_end; @@ -99,7 +99,7 @@ class SurveyReq extends Validate end={?}, mode={?}, promos={?}'; - return XDB::execute($sql, serialize($this->questions), $this->title, $this->description, $this->uid, $this->end, $this->mode, $this->promos); + return XDB::execute($sql, serialize($this->questions), $this->title, $this->description, $this->user->id(), $this->end, $this->mode, $this->promos); } // }}} diff --git a/modules/admin.php b/modules/admin.php index 8b16500..96ec608 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -466,7 +466,7 @@ class AdminModule extends PLModule // Eventually adds the alias to the right domain. if ($domain == $globals->mail->alias_dom || $domain == $globals->mail->alias_dom2) { - $req = new AliasReq($user->id(), $alias, 'Admin request', false); + $req = new AliasReq($user, $alias, 'Admin request', false); if ($req->commit()) { $page->trigSuccess("Nouvel alias '$alias@$domain' attribué"); } else { diff --git a/modules/email.php b/modules/email.php index 893ca33..f86c85b 100644 --- a/modules/email.php +++ b/modules/email.php @@ -171,7 +171,7 @@ class EmailModule extends PLModule } //Insertion de la demande dans la base, écrase les requêtes précédente - $myalias = new AliasReq($uid, $alias, $raison, $public); + $myalias = new AliasReq(S::user(), $alias, $raison, $public); $myalias->submit(); $page->assign('success',$alias); return; diff --git a/modules/events.php b/modules/events.php index b8e135e..24b0a4b 100644 --- a/modules/events.php +++ b/modules/events.php @@ -299,7 +299,7 @@ class EventsModule extends PLModule require_once 'validations.inc.php'; $evtreq = new EvtReq($titre, $texte, $promo_min, $promo_max, - $peremption, $valid_mesg, S::v('uid'), $upload); + $peremption, $valid_mesg, S::user(), $upload); $evtreq->submit(); $page->assign('ok', true); } elseif (!Env::v('preview')) { diff --git a/modules/lists.php b/modules/lists.php index 6c52d4b..a3224ea 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -296,7 +296,7 @@ class ListsModule extends PLModule if (!$page->nb_errs()) { $page->assign('created', true); require_once 'validations.inc.php'; - $req = new ListeReq(S::v('uid'), $asso, $liste, $domain, + $req = new ListeReq(S::user(), $asso, $liste, $domain, Post::v('desc'), Post::i('advertise'), Post::i('modlevel'), Post::i('inslevel'), $owners, $members); diff --git a/modules/marketing.php b/modules/marketing.php index 69160fa..9e62667 100644 --- a/modules/marketing.php +++ b/modules/marketing.php @@ -187,20 +187,18 @@ class MarketingModule extends PLModule pl_redirect('emails/redirect'); } - $res = Xdb::query("SELECT u.nom, u.prenom, u.promo, FIND_IN_SET('femme', u.flags) AS sexe, - u.deces = '0000-00-00' AS alive, u.hruid, a.alias AS forlife, b.alias AS bestalias, - IF(e.email IS NOT NULL, e.email, IF(FIND_IN_SET('googleapps', u.mail_storage), 'googleapps', NULL)) AS email, e.last - FROM auth_user_md5 AS u - INNER JOIN aliases AS a ON (a.id = u.user_id AND a.type = 'a_vie') - INNER JOIN aliases AS b ON (b.id = u.user_id AND FIND_IN_SET('bestalias', b.flags)) - LEFT JOIN emails AS e ON (e.flags = 'active' AND e.uid = u.user_id) - WHERE u.hruid = {?} - ORDER BY e.panne_level, e.last", $user->login()); + $res = XDB::query( + "SELECT u.deces = '0000-00-00' AS alive, e.last, + IF(e.email IS NOT NULL, e.email, IF(FIND_IN_SET('googleapps', u.mail_storage), 'googleapps', NULL)) AS email + FROM auth_user_md5 AS u + LEFT JOIN emails AS e ON (e.flags = 'active' AND e.uid = u.user_id) + WHERE u.user_id = {?} + ORDER BY e.panne_level, e.last", $user->id()); if (!$res->numRows()) { return PL_NOT_FOUND; } - $user_data = $res->fetchOneAssoc(); - $page->assign('user', $user_data); + $user->addProperties($res->fetchOneAssoc()); + $page->assign('user', $user); $email = null; require_once 'emails.inc.php'; @@ -217,15 +215,15 @@ class MarketingModule extends PLModule WHERE email = {?} AND uid = {?}", $email, $user->id()); $state = $res->numRows() ? $res->fetchOneCell() : null; if ($state == 'panne') { - $page->trigWarning("L'adresse que tu as fournie est l'adresse actuelle de {$user_data['prenom']} et est en panne."); + $page->trigWarning("L'adresse que tu as fournie est l'adresse actuelle de {$user->fullName()} et est en panne."); } elseif ($state == 'active') { - $page->trigWarning("L'adresse que tu as fournie est l'adresse actuelle de {$user_data['prenom']}"); - } elseif ($user_data['email'] && !trim(Post::v('comment'))) { + $page->trigWarning("L'adresse que tu as fournie est l'adresse actuelle de {$user->fullName()}"); + } elseif ($user->email && !trim(Post::v('comment'))) { $page->trigError("Il faut que tu ajoutes un commentaire à ta proposition pour justifier le " - . "besoin de changer la redirection de " . $user_data['prenom']); + . "besoin de changer la redirection de {$user->fullName()}."); } else { require_once 'validations.inc.php'; - $valid = new BrokenReq(S::i('uid'), $user_data, $email, trim(Post::v('comment'))); + $valid = new BrokenReq(S::user(), $user, $email, trim(Post::v('comment'))); $valid->submit(); $page->assign('sent', true); } diff --git a/modules/newsletter.php b/modules/newsletter.php index cb7b60c..8390eed 100644 --- a/modules/newsletter.php +++ b/modules/newsletter.php @@ -87,7 +87,7 @@ class NewsletterModule extends PLModule $page->assign('art', $art); } elseif (Post::has('valid')) { require_once('validations.inc.php'); - $art = new NLReq(S::v('uid'), Post::v('title'), + $art = new NLReq(S::user(), Post::v('title'), Post::v('body'), Post::v('append')); $art->submit(); $page->assign('submited', true); diff --git a/modules/profile.php b/modules/profile.php index 47fd735..15ea9bc 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -145,7 +145,7 @@ class ProfileModule extends PLModule if (!$upload->upload($_FILES['userfile']) && !$upload->download(Env::v('photo'))) { $page->trigError('Une erreur est survenue lors du téléchargement du fichier'); } else { - $myphoto = new PhotoReq(S::v('uid'), $upload); + $myphoto = new PhotoReq(S::user(), $upload); if ($myphoto->isValid()) { $myphoto->submit(); } @@ -155,7 +155,7 @@ class ProfileModule extends PLModule $upload = new PlUpload(S::user()->login(), 'photo'); if ($upload->copyFrom($trombi_x)) { - $myphoto = new PhotoReq(S::v('uid'), $upload); + $myphoto = new PhotoReq(S::user(), $upload); if ($myphoto->isValid()) { $myphoto->commit(); $myphoto->clean(); @@ -494,8 +494,7 @@ class ProfileModule extends PLModule $page->assign('promo_sortie', $promo_sortie); if (Env::has('submit')) { - $myorange = new OrangeReq(S::v('uid'), - $promo_sortie); + $myorange = new OrangeReq(S::user(), $promo_sortie); $myorange->submit(); $page->assign('myorange', $myorange); } @@ -684,7 +683,7 @@ class ProfileModule extends PLModule if ($reason == 'other') { $reason = Env::v('other_reason'); } - $myusage = new UsageReq(S::v('uid'), $nom_usage, $reason); + $myusage = new UsageReq(S::user(), $nom_usage, $reason); $myusage->submit(); $page->assign('myusage', $myusage); } diff --git a/modules/profile/decos.inc.php b/modules/profile/decos.inc.php index df97147..85d2a86 100644 --- a/modules/profile/decos.inc.php +++ b/modules/profile/decos.inc.php @@ -76,7 +76,7 @@ class ProfileDeco implements ProfileSetting // Add new ones foreach ($value as $id=>&$val) { if (!isset($orig[$id]) || $orig[$id]['grade'] != $val['grade']) { - $req = new MedalReq(S::i('uid'), $id, $val['grade']); + $req = new MedalReq(S::user(), $id, $val['grade']); $req->submit(); } } diff --git a/modules/survey/survey.inc.php b/modules/survey/survey.inc.php index 89d674b..003bbcf 100644 --- a/modules/survey/survey.inc.php +++ b/modules/survey/survey.inc.php @@ -407,7 +407,7 @@ class Survey public function proposeSurvey() { require_once 'validations.inc.php'; - $surveyreq = new SurveyReq($this->title, $this->description, $this->end, $this->mode, $this->promos, $this->questions, S::v('uid')); + $surveyreq = new SurveyReq($this->title, $this->description, $this->end, $this->mode, $this->promos, $this->questions, S::user()); return $surveyreq->submit(); } // }}} diff --git a/modules/xnetevents.php b/modules/xnetevents.php index 10d7259..071ea7d 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -443,7 +443,7 @@ class XnetEventsModule extends PLModule // request for a new payment if (Post::v('paiement_id') == -1 && $money_defaut >= 0) { require_once 'validations.inc.php'; - $p = new PayReq(S::v('uid'), + $p = new PayReq(S::user(), Post::v('intitule')." - ".$globals->asso('nom'), Post::v('site'), $money_defaut, Post::v('confirmation'), 0, 999, diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 0f3c2b7..41555f8 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -1320,7 +1320,7 @@ class XnetGrpModule extends PLModule if ($art['xorg']) { require_once('validations.inc.php'); $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'], $fulltext, - $art['promo_min'], $art['promo_max'], $art['peremption'], "", S::v('uid'), + $art['promo_min'], $art['promo_max'], $art['peremption'], "", S::user(), $upload); $article->submit(); $page->trigWarning("L'affichage sur la page d'accueil de Polytechnique.org est en attente de validation."); @@ -1329,7 +1329,7 @@ class XnetGrpModule extends PLModule } if ($art['nl']) { require_once('validations.inc.php'); - $article = new NLReq(S::v('uid'), $globals->asso('nom') . " : " .$art['titre'], + $article = new NLReq(S::user(), $globals->asso('nom') . " : " .$art['titre'], $art['texte'], $art['contact_html']); $article->submit(); $page->trigWarning("La parution dans la Lettre Mensuelle est en attente de validation."); diff --git a/templates/admin/valider.tpl b/templates/admin/valider.tpl index df42a75..e28ffeb 100644 --- a/templates/admin/valider.tpl +++ b/templates/admin/valider.tpl @@ -46,8 +46,8 @@ function toggleField(name, id, obj) { Demandeur : - - {$valid->prenom} {$valid->nom} (X{$valid->promo}) + + {$valid->user->fullName()} (X{$valid->user->promo()}) @@ -75,7 +75,7 @@ function toggleField(name, id, obj) { {xsrf_token_field}
{include file=$valid->editor()} - +
@@ -108,7 +108,7 @@ function toggleField(name, id, obj) {
{xsrf_token_field}
- + @@ -147,7 +147,7 @@ function toggleField(name, id, obj) { Ajouté dans l'email :

- + diff --git a/templates/include/form.valid.broken.tpl b/templates/include/form.valid.broken.tpl index b7dbd6b..ca61ffc 100644 --- a/templates/include/form.valid.broken.tpl +++ b/templates/include/form.valid.broken.tpl @@ -22,7 +22,7 @@ Récupération de - {$valid->m_prenom} {$valid->m_nom} ({$valid->m_promo}) + {$valid->m_user->fullName()} ({$valid->m_user->promo()}) Email proposé diff --git a/templates/include/form.valid.homonymes.tpl b/templates/include/form.valid.homonymes.tpl index c9ceb0c..7b9a903 100644 --- a/templates/include/form.valid.homonymes.tpl +++ b/templates/include/form.valid.homonymes.tpl @@ -29,7 +29,7 @@ Homonymes : - {foreach from=$valid->homonymes_forlife item=o} + {foreach from=$valid->homonymes_hruid item=o} {$o} {/foreach} diff --git a/templates/include/form.valid.mark.tpl b/templates/include/form.valid.mark.tpl index 30090ea..c45d3da 100644 --- a/templates/include/form.valid.mark.tpl +++ b/templates/include/form.valid.mark.tpl @@ -28,7 +28,7 @@ {/if} Marketing sur - {$valid->m_prenom} {$valid->m_nom} ({$valid->m_promo}) + {$valid->m_user->fullName()} ({$valid->m_user->promo()}) {if $valid->m_type neq 'default'} diff --git a/templates/include/form.valid.orange.tpl b/templates/include/form.valid.orange.tpl index 1cc4d8f..1a47a2f 100644 --- a/templates/include/form.valid.orange.tpl +++ b/templates/include/form.valid.orange.tpl @@ -23,11 +23,11 @@ Promotion : - {$valid->promo} + {$valid->user->promo()} Année de sortie : - {$valid->promo_sortie} au lieu de {math equation="a + b" a=$valid->promo b=3} + {$valid->promo_sortie} au lieu de {math equation="a + b" a=$valid->user->promo() b=3} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/include/form.valid.paiements.tpl b/templates/include/form.valid.paiements.tpl index ef3628c..0262ba2 100644 --- a/templates/include/form.valid.paiements.tpl +++ b/templates/include/form.valid.paiements.tpl @@ -40,7 +40,7 @@ Contact : - {$valid->bestalias}@polytechnique.org + {$valid->user->bestEmail()} diff --git a/templates/include/form.valid.photos.tpl b/templates/include/form.valid.photos.tpl index 88f1bbd..762928d 100644 --- a/templates/include/form.valid.photos.tpl +++ b/templates/include/form.valid.photos.tpl @@ -23,9 +23,9 @@ Photos -  [ PHOTO ] +  [ PHOTO ]      -  [ PHOTO ] +  [ PHOTO ] diff --git a/templates/marketing/broken.tpl b/templates/marketing/broken.tpl index 278030d..54a7f86 100644 --- a/templates/marketing/broken.tpl +++ b/templates/marketing/broken.tpl @@ -20,16 +20,15 @@ {* *} {**************************************************************************} - {if $sent}

Merci de nous avoir communiqué cette information !

-{elseif $user && !$user.alive} +{elseif $user && !$user->alive}

- {$user.prenom} {$user.nom} (X{$user.promo}) est malheureusement décédé{if $user.sexe}e{/if}. + {$user->fullName()} (X{$user->promo()}) est malheureusement décédé{if $user->isFemale()}e{/if}. Nous ne réaliserons maintenance sur son adresse Polytechnique.org qu'à la demande explicite de sa famille. Pour tout renseignement, merci de contacter le support. @@ -37,32 +36,32 @@ {elseif $user}

- Recherche d'adresses pour {$user.nom} {$user.prenom} (X{$user.promo}) + Recherche d'adresses pour {$user->fullName()} (X{$user->promo()}).

-{if !$user.email} +{if !$user->email}

Avec le temps, toutes les adresses de redirection de notre camarade sont devenues invalides et produisent des erreurs lorsqu'on lui envoie un email. Nous sommes donc à la recherche d'adresses valides où nous pourrions contacter ce camarade.

-{elseif $user.last} +{elseif $user->last}

- {$user.prenom} a encore des adresses de redirection actives malgré des pannes détectées sur certaines d'entre elles. Si + {$user->fullName()} a encore des adresses de redirection actives malgré des pannes détectées sur certaines d'entre elles. Si tu es sûr{if $smarty.session.femme}e{/if} que son adresse Polytechnique.org est en panne, tu peux proposer une nouvelle adresse email à ajouter à ses redirections. Merci d'ajouter un commentaire pour nous indiquer la raison de cette proposition.

{else}

- Nous n'avons actuellement enregistré aucune panne sur les adresses de redirection de {$user.prenom}. Si tu es + Nous n'avons actuellement enregistré aucune panne sur les adresses de redirection de {$user->fullName()}. Si tu es sûr{if $smarty.session.femme}e{/if} que son adresse de redirection actuelle est en panne, tu peux nous proposer une nouvelle adresse, accompagnée d'un commentaire nous expliquant les raisons exactes de cette proposition.

{/if}

- Les adresses email que tu pourras nous donner ne seront pas ajoutées directement aux redirections de {$user.prenom}. - Nous allons d'abord prendre contact avec {if $user.sexe}elle{else}lui{/if} pour savoir {if $user.sexe}si elle {else}s'il {/if} - accepte la mise à jour de sa redirection. + Les adresses email que tu pourras nous donner ne seront pas ajoutées directement aux redirections de {$user->fullName()}. + Nous allons d'abord prendre contact avec {if $user->isFemale()}elle{else}lui{/if} pour savoir {if $user->isFemale()}si elle + {else}s'il {/if} accepte la mise à jour de sa redirection.

Merci de ta participation active à l'amélioration de notre qualité de service. @@ -71,14 +70,14 @@ {xsrf_token_field} - + - {if $user.email} + {if $user->email} -- 2.1.4
Proposition d'adresse pour
{$user.nom} {$user.prenom} (X{$user.promo})
Proposition d'adresse pour
{$user->fullName()} (X{$user->promo()})
Adresse email :
Explication :