X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Freminder%2Fpromotion_ml.inc.php;h=a49e4e78fda9e3adcd0c37d91d124948057ba97d;hb=f336915bd25f046ed90b4d7e144384d7242adc97;hp=ec1b0c5c1dda96a925b75195b639cf48aa55a6ee;hpb=5660032ac785d410f90e3f5b0d6948dc90b0cfea;p=platal.git diff --git a/include/reminder/promotion_ml.inc.php b/include/reminder/promotion_ml.inc.php index ec1b0c5..a49e4e7 100644 --- a/include/reminder/promotion_ml.inc.php +++ b/include/reminder/promotion_ml.inc.php @@ -1,6 +1,6 @@ fetchOneCell(); - XDB::execute('REPLACE INTO #groupex#.membres (uid, asso_id) - VALUES ({?}, {?})', - S::v('uid'), $asso_id); - $mmlist = new MMList(S::v('uid'), S::v('password')); - $mmlist->subscribe('promo' . S::v('promo')); + XDB::execute('INSERT IGNORE INTO group_members (uid, asso_id) + SELECT {?}, id + FROM groups + WHERE diminutif = {?}', + $user->id(), $user->profile()->yearPromo()); + $mmlist = new MMList($user); + $mmlist->subscribe('promo' . $user->profile()->yearPromo()); $this->UpdateOnYes(); break; @@ -64,15 +62,19 @@ class ReminderPromotionMl extends Reminder public static function IsCandidate(User &$user, $candidate) { + $profile = $user->profile(); + if (!$profile) { + return false; + } + // 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')); - + $user->id(), $user->profile()->yearPromo()); $mlCount = $res->fetchOneCell(); if ($mlCount) { Reminder::MarkCandidateAsAccepted($user->id(), $candidate);