Disable mail-related reminders when the user has an account without email.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 29 Sep 2010 13:51:01 +0000 (15:51 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 29 Sep 2010 13:55:00 +0000 (15:55 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/reminder/email_backup.inc.php
include/reminder/email_warning.inc.php
include/reminder/gapps.inc.php
include/reminder/no_redirection.inc.php
include/reminder/promotion_ml.inc.php
modules/events.php

index 957422a..353e0ef 100644 (file)
@@ -57,6 +57,10 @@ class ReminderEmailBackup extends Reminder
 
     public static function IsCandidate(User &$user, $candidate)
     {
+        if (!$user->checkPerms(User::PERM_MAIL)) {
+            return false;
+        }
+
         require_once 'emails.inc.php';
         $storage  = new EmailStorage($user, 'imap');
         if ($storage->active) {
index e1534cc..887f5a9 100644 (file)
@@ -43,6 +43,10 @@ class ReminderEmailWarning extends Reminder
 
     public static function IsCandidate(User &$user, $candidate)
     {
+        if (!$user->checkPerms(User::PERM_MAIL)) {
+            return false;
+        }
+
         return count(S::v('mx_failures', array())) > 0;
     }
 }
index 815f315..23fd7c4 100644 (file)
@@ -54,6 +54,10 @@ class ReminderGapps extends Reminder
 
     public static function IsCandidate(User &$user, $candidate)
     {
+        if (!$user->checkPerms(User::PERM_MAIL)) {
+            return false;
+        }
+
         require_once 'googleapps.inc.php';
         $isSubscribed = GoogleAppsAccount::account_status($user->id());
         if ($isSubscribed == 'disabled') {
index 863119f..b6211d4 100644 (file)
@@ -47,6 +47,9 @@ class ReminderNoRedirection extends Reminder
 
     public static function IsCandidate(User &$user, $candidate)
     {
+        if (!$user->checkPerms(User::PERM_MAIL)) {
+            return false;
+        }
         return S::v('no_redirect');
     }
 }
index 987785e..ffc33b2 100644 (file)
@@ -65,6 +65,11 @@ 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(*)
index 6a02b23..4888268 100644 (file)
@@ -108,26 +108,27 @@ class EventsModule extends PLModule
         $user = S::user();
 
         /** XXX: Tips and reminder only for user with 'email' permission.
-         * We can do better in the future by storing the required permission(s)
-         * with teh tip/reminder.
+         * We can do better in the future by storing a userfilter
+         * with the tip/reminder.
          */
         if ($user->checkPerms(User::PERM_MAIL)) {
             $page->assign('tips', $this->get_tips());
 
-            // Adds a reminder onebox to the page.
-            require_once 'reminder.inc.php';
-            if (($reminder = Reminder::GetCandidateReminder($user))) {
-                $reminder->Prepare($page);
-            }
+        }
 
-            // Wishes "Happy birthday" when required
-            $profile = $user->profile();
-            if (!is_null($profile)) {
-                if ($profile->next_birthday == date('Y-m-d')) {
-                    $birthyear = (int)date('Y', strtotime($profile->birthdate));
-                    $curyear   = (int)date('Y');
-                    $page->assign('birthday', $curyear - $birthyear);
-                }
+        // Adds a reminder onebox to the page.
+        require_once 'reminder.inc.php';
+        if (($reminder = Reminder::GetCandidateReminder($user))) {
+            $reminder->Prepare($page);
+        }
+
+        // Wishes "Happy birthday" when required
+        $profile = $user->profile();
+        if (!is_null($profile)) {
+            if ($profile->next_birthday == date('Y-m-d')) {
+                $birthyear = (int)date('Y', strtotime($profile->birthdate));
+                $curyear   = (int)date('Y');
+                $page->assign('birthday', $curyear - $birthyear);
             }
         }