Fixes NL unsubscription when not loggued on the site (Closes #1524).
authorStéphane Jacob <sj@m4x.org>
Thu, 21 Jul 2011 08:01:47 +0000 (10:01 +0200)
committerStéphane Jacob <sj@m4x.org>
Thu, 21 Jul 2011 08:01:47 +0000 (10:01 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
ChangeLog
modules/newsletter.php

index bbfdf16..8d7e925 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,9 @@ Bug/Wish:
 
 From 1.1.2 branch:
 
+    * Newsletter:
+        - #1524: Fixes NL unsubscription when not loggued on the site      -JAC
+
     * Search:
         - #1520: Fixes deltaten                                            -XEL
 
index a975ba3..6603bc8 100644 (file)
@@ -55,16 +55,26 @@ class NewsletterModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $page->changeTpl('newsletter/index.tpl');
-        $page->setTitle('Lettres mensuelles');
-
         $hash = ($hash == 'nohash') ? null : $hash;
         switch ($action) {
-          case 'out': $nl->unsubscribe($issue_id, $hash, $hash != null); break;
+          case 'out':
+            $success = $nl->unsubscribe($issue_id, $hash, $hash != null);
+            if (!is_null($hash)) {
+                if ($success) {
+                    $page->trigSuccess('La désinscription a été effectuée avec succès.');
+                } else {
+                    $page->trigError("La désinscription n'a été pas pu être effectuée.");
+                }
+                return;
+            }
+            break;
           case 'in':  $nl->subscribe(); break;
           default: ;
         }
 
+        $page->changeTpl('newsletter/index.tpl');
+        $page->setTitle('Lettres mensuelles');
+
         $page->assign_by_ref('nl', $nl);
         $page->assign('nls', $nl->subscriptionState());
         $page->assign('nl_list', $nl->listSentIssues(true));