tips:cleannotificationscheme
This is an old revision of the document!
Table of Contents
Clean notification scheme
To make the notification system lighter (read: sending less notifications) I modified the notifications to be sent according to the following scheme:
- namespace subscribers get notified for new pages in the current namespace
- page subscribers get notified for major page modifications (they are likely subscribed to namespace as well)
- no one is notified for minor modifications
inc/common.php
2 small changes need to be brought to inc/common.php
1. find
subscriber_addresslist($id);
and change it to
//subscriber_addresslist($id); //replaced to clean notification scheme, more info at http://www.dokuwiki.org/tips:cleannotificationscheme restricted_subscriber_addresslist($id,$rev);
2. add the following function (heavy copy-paste of existing code by Steven Danz), for instance before the function subscriber_addresslist($id) declaration.
/** * Return a string with the email addresses of all the * users subscribed to a page * * if $rev is set, the list of page subscribers is returned (for page update notification) * if $rev is not set, the list of namespace subsribers is returned (for new page notification) * * @author Berteh <berteh@hotmail.com> * @info http://www.dokuwiki.org/tips:cleannotificationscheme */ function subscriber_addresslist($id,$self=true,$rev=''){ global $conf; global $auth; if (!$conf['subscribers']) return ''; $users = array(); $emails = array(); $mlist = array(); if($rev) { //only direct page subscribers // load the page mlist file content $file=metaFN($id,'.mlist'); if (@file_exists($file)) { $mlist = file($file); foreach ($mlist as $who) { $who = rtrim($who); if(!$self && $who == $_SERVER['REMOTE_USER']) continue; $users[$who] = true; } } } else { //rev not set - only namespace subscribers // load also the namespace mlist file content $ns = getNS($id); while ($ns) { $nsfile = metaFN($ns,'/.mlist'); if (@file_exists($nsfile)) { $mlist = file($nsfile); foreach ($mlist as $who) { $who = rtrim($who); if(!$self && $who == $_SERVER['REMOTE_USER']) continue; $users[$who] = true; } } $ns = getNS($ns); } // root namespace $nsfile = metaFN('','.mlist'); if (@file_exists($nsfile)) { $mlist = file($nsfile); foreach ($mlist as $who) { $who = rtrim($who); if(!$self && $who == $_SERVER['REMOTE_USER']) continue; $users[$who] = true; } } } if(!empty($users)) { foreach (array_keys($users) as $who) { $info = $auth->getUserData($who); if($info === false) continue; $level = auth_aclcheck($id,$who,$info['grps']); if ($level >= AUTH_READ) { if (strcasecmp($info['mail'],$conf['notify']) != 0) { $emails[] = $info['mail']; } } } } return implode(',',$emails); }
This hack has been tested on dokuwiki-2009-02-14, and nicely combines with the betteremailnotifications tip. An older version was working on dokuwiki-2008-05-05.
Comments - feedback
Please give comments / feedback!
tips/cleannotificationscheme.1251196769.txt.gz · Last modified: 2009-08-25 12:39 by 158.64.4.15