* 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
* @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
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;
}
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) {
$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: ;
}
{if $is_mail}
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}>
{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}
</div>
<div class="foot2">
[<a href="https://www.polytechnique.org/ax">archives</a> |
- <a href="https://www.polytechnique.org/ax/out{if $hash}/{$hash}{/if}">ne plus recevoir</a>]
+ <a href="https://www.polytechnique.org/ax/out/{if $hash}{$hash}{else}nohash{/if}/{$issue->id}">ne plus recevoir</a>]
</div>
</div>
{if $is_mail}
{if $is_mail}
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}>
{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}
</pre>
<div class="foot2">
[<a href="https://www.polytechnique.org/nl">archives</a> |
<a href="https://www.polytechnique.org/nl/submit">écrire dans la NL</a> |
- <a href="https://www.polytechnique.org/nl/out">ne plus recevoir</a>]
+ <a href="https://www.polytechnique.org/nl/out/nohash/{$issue->id}">ne plus recevoir</a>]
</div>
</div>
{if $is_mail}
--- /dev/null
+ALTER TABLE newsletter_issues ADD COLUMN unsubscribe INT(5) NOT NULL DEFAULT 0;
+
+-- vim:set syntax=mysql: