Merge remote branch 'origin/xorg/maint' into xorg/master
[platal.git] / include / reminder / promotion_ml.inc.php
index 1156e2a..c311e13 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -29,7 +29,7 @@ class ReminderPromotionMl extends Reminder
             XDB::execute('INSERT IGNORE INTO  group_members (uid, asso_id)
                                       SELECT  {?}, id
                                         FROM  groups
-                                       WHERE  diminutif = {?}'
+                                       WHERE  diminutif = {?}',
                          $user->id(), $user->profile()->yearPromo());
             $mmlist = new MMList($user);
             $mmlist->subscribe('promo' . $user->profile()->yearPromo());
@@ -60,7 +60,7 @@ class ReminderPromotionMl extends Reminder
         return "Inscription à la liste de diffusion de ta promotion";
     }
 
-    public static function IsCandidate(User &$user, $candidate)
+    public static function IsCandidate(User $user, $candidate)
     {
         $profile = $user->profile();
         if (!$profile) {
@@ -79,7 +79,16 @@ class ReminderPromotionMl extends Reminder
         if ($mlCount) {
             Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
         }
-        return ($mlCount == 0);
+        if ($mlCount == 0) {
+            $mmlist = new MMList($user);
+            try {
+                $mmlist->get_members_limit('promo' + $user->profile()->yearPromo(),
+                                           0, 0);
+            } catch (Exception $e) {
+                return false;
+            }
+        }
+        return false;
     }
 }