summaryrefslogtreecommitdiff
path: root/inc/subscription.php
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2013-01-26 15:09:43 +0100
committerMichael Hamann <michael@content-space.de>2013-01-26 16:18:25 +0100
commit10eac6731852014bcef1a0d16c59a4f6f77d8e31 (patch)
treeef1e87dfe50828bf332a49d3a44136bfc5de847e /inc/subscription.php
parentdfbe4adfd080433f91409f028935b9f9879fceca (diff)
downloadrpg-10eac6731852014bcef1a0d16c59a4f6f77d8e31.tar.gz
rpg-10eac6731852014bcef1a0d16c59a4f6f77d8e31.tar.bz2
Add threading headers to change notification mails as proposed in PR #120
Diffstat (limited to 'inc/subscription.php')
-rw-r--r--inc/subscription.php37
1 files changed, 35 insertions, 2 deletions
diff --git a/inc/subscription.php b/inc/subscription.php
index 62cfd1509..31e3e08e1 100644
--- a/inc/subscription.php
+++ b/inc/subscription.php
@@ -424,9 +424,14 @@ class Subscription {
$trep['DIFF'] = $tdiff;
$hrep['DIFF'] = $hdiff;
+ $headers = array('Message-Id' => $this->getMessageID($id));
+ if ($rev) {
+ $headers['In-Reply-To'] = $this->getMessageID($id, $rev);
+ }
+
return $this->send(
$subscriber_mail, $subject, $id,
- $template, $trep, $hrep
+ $template, $trep, $hrep, $headers
);
}
@@ -542,9 +547,10 @@ class Subscription {
* template (in text format)
* @param array $hrep Predefined parameters used to parse the
* template (in HTML format), null to default to $trep
+ * @param array $headers Additional mail headers in the form 'name' => 'value'
* @return bool
*/
- protected function send($subscriber_mail, $subject, $context, $template, $trep, $hrep = null) {
+ protected function send($subscriber_mail, $subject, $context, $template, $trep, $hrep = null, $headers = array()) {
global $lang;
global $conf;
@@ -560,10 +566,37 @@ class Subscription {
if(isset($trep['SUBSCRIBE'])) {
$mail->setHeader('List-Unsubscribe', '<'.$trep['SUBSCRIBE'].'>', false);
}
+
+ foreach ($headers as $header => $value) {
+ $mail->setHeader($header, $value);
+ }
+
return $mail->send();
}
/**
+ * Get a valid message id for a certain $id and revision (or the current revision)
+ * @param string $id The id of the page (or media file) the message id should be for
+ * @param string $rev The revision of the page, set to the current revision of the page $id if not set
+ * @return string
+ */
+ protected function getMessageID($id, $rev = NULL) {
+ static $listid = null;
+ if (is_null($listid)) {
+ $server = parse_url(DOKU_URL, PHP_URL_HOST);
+ $listid = join('.', array_reverse(explode('/', DOKU_BASE))).$server;
+ $listid = urlencode($listid);
+ $listid = strtolower(trim($listid, '.'));
+ }
+
+ if (is_null($rev)) {
+ $rev = @filemtime(wikiFN($id));
+ }
+
+ return "<$id?rev=$rev@$listid>";
+ }
+
+ /**
* Default callback for COMMON_NOTIFY_ADDRESSLIST
*
* Aggregates all email addresses of user who have subscribed the given page with 'every' style