Notifies when a action has been done throught a reminder box.
authorStéphane Jacob <sj@m4x.org>
Tue, 14 Jul 2009 11:16:41 +0000 (13:16 +0200)
committerStéphane Jacob <sj@m4x.org>
Tue, 14 Jul 2009 11:16:41 +0000 (13:16 +0200)
include/reminder.inc.php
modules/reminder.php
templates/reminder/base.tpl
templates/reminder/notification.tpl [new file with mode: 0644]

index a28d839..bc1334b 100644 (file)
@@ -101,13 +101,25 @@ abstract class Reminder
     // method below).
     abstract public function HandleAction($action);
 
+    // Displays a reduced version of the reminder and notifies that the action
+    // has been taken into account.
+    public function NotifiesAction(&$page)
+    {
+        header('Content-Type: text/html; charset=utf-8');
+        $page->changeTpl('reminder/notification.tpl', NO_SKIN);
+        $page->assign('previous_reminder', $this->title());
+    }
+
     // Displays the reminder as a standalone html snippet. It should be used
     // when the reminder is the only output of a page.
-    public function DisplayStandalone(&$page)
+    public function DisplayStandalone(&$page, $previous_reminder = null)
     {
         header('Content-Type: text/html; charset=utf-8');
         $page->changeTpl('reminder/base.tpl', NO_SKIN);
         $this->Prepare($page);
+        if ($previous_reminder) {
+            $page->assign('previous_reminder', $previous_reminder);
+        }
     }
 
     // Prepares the display by assigning template variables.
index d35ef0c..2d68ef0 100644 (file)
@@ -44,10 +44,12 @@ class ReminderModule extends PLModule
         // displayed.
         $reminder->HandleAction($action);
 
+        $previous_reminder = $reminder->title();
+
         if (($new_reminder = Reminder::GetCandidateReminder($user))) {
-            $new_reminder->DisplayStandalone($page);
+            $new_reminder->DisplayStandalone($page, $previous_reminder);
         } else {
-            exit;
+            $reminder->NotifiesAction($page);
         }
     }
 }
index 404a306..477cbc8 100644 (file)
 {**************************************************************************}
 
 <div id="reminder">
+  {if $previous_reminder}
+    {include file="reminder/notification.tpl" previous_reminder=$previous_reminder}
+  {/if}
+
   <fieldset class="warnings">
     <legend>
       {if $reminder->warning()}{icon name=error}{else}{icon name=information}{/if}
diff --git a/templates/reminder/notification.tpl b/templates/reminder/notification.tpl
new file mode 100644 (file)
index 0000000..f7fc9b4
--- /dev/null
@@ -0,0 +1,32 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2009 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<div id="reminder">
+  <fieldset class="success">
+    <legend>
+      {icon name=information}&nbsp;{$previous_reminder}
+    </legend>
+    Ta demande a bien été prise en compte.
+  </fieldset>
+</div>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}