Merge branch 'xorg/maint' into xorg/master
[platal.git] / include / reminder / gapps.inc.php
index 8df4c46..f82a407 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2009 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -25,7 +25,7 @@ class ReminderGapps extends Reminder
     {
         switch ($action) {
           case 'yes':
-            $this->UpdateOnYes();
+            $this->UpdateOnDismiss();
             pl_redirect('googleapps');
             break;
 
@@ -39,22 +39,30 @@ class ReminderGapps extends Reminder
         }
     }
 
-    public function text()
+    public function template()
     {
-        return "Polytechnique.org te fournit un compte Google Apps qui te permet
-            de disposer des applications web de Google (GMail, Google Calendar,
-            Google Docs, et bien d'autres) sur ton adresse Polytechnique.org
-            habituelle (en savoir plus).";
+        return 'reminder/gapps.tpl';
     }
     public function title()
     {
         return "Création d'un compte Google Apps";
     }
+    public function info()
+    {
+        return 'Xorg/GoogleApps';
+    }
 
-    public static function IsCandidate(User &$user, $candidate)
+    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') {
+            $isSubscribed = false;
+        }
         if ($isSubscribed) {
             Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
         }