From 602119a260d65a6a9d146e01d43bc21358d706d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Fri, 29 Apr 2011 11:45:23 +0200 Subject: [PATCH] Links nl unsubscribtions to the issues that caused them (Closes #1394). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- ChangeLog | 3 +++ include/newsletter.inc.php | 8 +++++++- modules/newsletter.php | 5 +++-- templates/newsletter/nl.AX.mail.tpl | 6 +++--- templates/newsletter/nl.Polytechnique.org.mail.tpl | 6 +++--- upgrade/1.1.1/12_nl.sql | 3 +++ 6 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 upgrade/1.1.1/12_nl.sql diff --git a/ChangeLog b/ChangeLog index 7913578..9a99433 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,9 @@ Bug/Wish: * Events: - #1475: Fixes date storage for next reminder -JAC + * Newsletter: + - #1394: Links nl unsubscribtions to the issues that caused them -JAC + * Profile: - #1445: Add job entry year -JAC - #1478: Uses user's visibility limitations to display vcards -JAC diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 623121f..2faf993 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -321,7 +321,7 @@ class NewsLetter * @p $hash True if the uid is actually a hash. * @return True if the user was successfully unsubscribed. */ - public function unsubscribe($uid = null, $hash = false) + public function unsubscribe($issue_id = null, $uid = null, $hash = false) { if (is_null($uid) && $hash) { // Unable to unsubscribe from an empty hash @@ -342,6 +342,12 @@ class NewsLetter XDB::execute('DELETE FROM newsletter_ins WHERE nlid = {?} AND uid = {?}', $this->id, $user); + if (!is_null($issue_id)) { + XDB::execute('UPDATE newsletter_issues + SET unsubscribe = unsubscribe + 1 + WHERE id = {?}', + $id); + } return true; } diff --git a/modules/newsletter.php b/modules/newsletter.php index 9dd9240..3accf5f 100644 --- a/modules/newsletter.php +++ b/modules/newsletter.php @@ -48,7 +48,7 @@ class NewsletterModule extends PLModule return NewsLetter::forGroup(NewsLetter::GROUP_XORG); } - function handler_nl($page, $action = null, $hash = null) + function handler_nl($page, $action = null, $hash = null, $issue_id = null) { $nl = $this->getNl(); if (!$nl) { @@ -58,8 +58,9 @@ class NewsletterModule extends PLModule $page->changeTpl('newsletter/index.tpl'); $page->setTitle('Lettres mensuelles'); + $hash = ($hash == 'nohash') ? null : $hash; switch ($action) { - case 'out': $nl->unsubscribe($hash, $hash != null); break; + case 'out': $nl->unsubscribe($issue_id, $hash, $hash != null); break; case 'in': $nl->subscribe(); break; default: ; } diff --git a/templates/newsletter/nl.AX.mail.tpl b/templates/newsletter/nl.AX.mail.tpl index 5a8b0b8..9898404 100644 --- a/templates/newsletter/nl.AX.mail.tpl +++ b/templates/newsletter/nl.AX.mail.tpl @@ -43,10 +43,10 @@ Cette lettre est envoyée par l'AX grâce aux outils de Polytechnique.org. {if $is_mail} archives : -ne plus recevoir : +ne plus recevoir : id}> {else} archives : <https://www.polytechnique.org/ax> -ne plus recevoir : <https://www.polytechnique.org/ax/out{if $hash}/{$hash}{/if}> +ne plus recevoir : <https://www.polytechnique.org/ax/out/{if $hash}{$hash}{else}nohash{/if}/issue/{$issue->id}> {/if} {if !$is_mail} @@ -80,7 +80,7 @@ ne plus recevoir : <https://www.polytechnique.org/ax/out{if $hash}/{$hash}{/i {if $is_mail} diff --git a/templates/newsletter/nl.Polytechnique.org.mail.tpl b/templates/newsletter/nl.Polytechnique.org.mail.tpl index 43ddf9f..84472e4 100644 --- a/templates/newsletter/nl.Polytechnique.org.mail.tpl +++ b/templates/newsletter/nl.Polytechnique.org.mail.tpl @@ -63,11 +63,11 @@ l'intermédiaire de Polytechnique.org. {if $is_mail} archives : écrire : -ne plus recevoir : +ne plus recevoir : id}> {else} archives : <https://www.polytechnique.org/nl> écrire : <https://www.polytechnique.org/nl/submit> -ne plus recevoir : <https://www.polytechnique.org/nl/out> +ne plus recevoir : <https://www.polytechnique.org/nl/out/nohash/{$issue->id}> {/if} {if !$is_mail} @@ -119,7 +119,7 @@ ne plus recevoir : <https://www.polytechnique.org/nl/out> {if $is_mail} diff --git a/upgrade/1.1.1/12_nl.sql b/upgrade/1.1.1/12_nl.sql new file mode 100644 index 0000000..08ee9b6 --- /dev/null +++ b/upgrade/1.1.1/12_nl.sql @@ -0,0 +1,3 @@ +ALTER TABLE newsletter_issues ADD COLUMN unsubscribe INT(5) NOT NULL DEFAULT 0; + +-- vim:set syntax=mysql: -- 2.1.4