X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Freminder%2Fpromotion_ml.inc.php;h=987785ebeeca35913fc07a4aa78f433b8d3c7cb3;hb=441e454e351c851a4906b0d1b1eca68aa364baa7;hp=ca36dcac1707e0e39de544557e9bd8f5862f1c8e;hpb=0e4b87b287fc40f2d33be0379980e16d6fa30055;p=platal.git diff --git a/include/reminder/promotion_ml.inc.php b/include/reminder/promotion_ml.inc.php index ca36dca..987785e 100644 --- a/include/reminder/promotion_ml.inc.php +++ b/include/reminder/promotion_ml.inc.php @@ -1,6 +1,6 @@ profile()->yearPromo()); $asso_id = $res->fetchOneCell(); - XDB::execute('REPLACE INTO groupex.membres (uid, asso_id) + XDB::execute('REPLACE INTO group_members (uid, asso_id) VALUES ({?}, {?})', - S::v('uid'), $asso_id); - $mmlist = new MMList(S::v('uid'), S::v('password')); - $mmlist->subscribe('promo' . S::v('promo')); + $user->id(), $asso_id); + $mmlist = new MMList($user); + $mmlist->subscribe('promo' . $user->profile()->yearPromo()); $this->UpdateOnYes(); break; @@ -49,13 +50,17 @@ class ReminderPromotionMl extends Reminder } } - protected function GetDisplayText() + public function text() { return "La liste de diffusion de ta promotion permet de recevoir les informations plus spécifiques de ta promotion pour pouvoir participer plus facilement aux événements qu'elle organise. Tu seras aussi inscrit dans le groupe de la promotion " . - S::user()->promo() . '.'; + $this->user->promo() . '.'; + } + public function title() + { + return "Inscription à la liste de diffusion de ta promotion"; } public static function IsCandidate(User &$user, $candidate) @@ -63,13 +68,16 @@ class ReminderPromotionMl extends Reminder // We only test if the user is in her promotion group for it is too // expensive to check if she is in the corresponding ML as well. $res = XDB::query('SELECT COUNT(*) - FROM groupex.membres + FROM group_members WHERE uid = {?} AND asso_id = (SELECT id - FROM groupex.asso + FROM groups WHERE diminutif = {?})', - $user->id(), S::v('promo')); - - return ($res->fetchOneCell() > 0); + $user->id(), $user->profile()->yearPromo()); + $mlCount = $res->fetchOneCell(); + if ($mlCount) { + Reminder::MarkCandidateAsAccepted($user->id(), $candidate); + } + return ($mlCount == 0); } }