From: Florent Bruneau Date: Wed, 29 Sep 2010 13:51:01 +0000 (+0200) Subject: Disable mail-related reminders when the user has an account without email. X-Git-Tag: xorg/1.0.1~136 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=1f64f1a78896aa527b081e5c7526963524f9bf8b;p=platal.git Disable mail-related reminders when the user has an account without email. Signed-off-by: Florent Bruneau --- diff --git a/include/reminder/email_backup.inc.php b/include/reminder/email_backup.inc.php index 957422a..353e0ef 100644 --- a/include/reminder/email_backup.inc.php +++ b/include/reminder/email_backup.inc.php @@ -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) { diff --git a/include/reminder/email_warning.inc.php b/include/reminder/email_warning.inc.php index e1534cc..887f5a9 100644 --- a/include/reminder/email_warning.inc.php +++ b/include/reminder/email_warning.inc.php @@ -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; } } diff --git a/include/reminder/gapps.inc.php b/include/reminder/gapps.inc.php index 815f315..23fd7c4 100644 --- a/include/reminder/gapps.inc.php +++ b/include/reminder/gapps.inc.php @@ -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') { diff --git a/include/reminder/no_redirection.inc.php b/include/reminder/no_redirection.inc.php index 863119f..b6211d4 100644 --- a/include/reminder/no_redirection.inc.php +++ b/include/reminder/no_redirection.inc.php @@ -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'); } } diff --git a/include/reminder/promotion_ml.inc.php b/include/reminder/promotion_ml.inc.php index 987785e..ffc33b2 100644 --- a/include/reminder/promotion_ml.inc.php +++ b/include/reminder/promotion_ml.inc.php @@ -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(*) diff --git a/modules/events.php b/modules/events.php index 6a02b23..4888268 100644 --- a/modules/events.php +++ b/modules/events.php @@ -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); } }