DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:subscription

Linked from subscription

It appears this is now included in DokuWiki 2009-02-14 (which confused me after upgrading, cos I initially thought the upgrade had broken subscriptions! LOL ). It's hardcoded to not send subscription emails to the editor of the page. If for some reason you want the old behaviour back (i.e. do get emails for your own edits), modify the call to subscriber_addresslist in inc/common.php so that the second parameter is true (the logic is inverted compared to the old workaround below).

Prevent Email Of Changes to Subscribed Author

You may wish to avoid sending emails to the author of the change, if the author is subscribed. Because- of course the author already knows that he/she made a change. I submit the below code change in order to work around this issue. It may be desirable to add a config flag for this setting. Possibly something each individual user can toggle for him/herself. At this point, it is on for everyone. ~Sherri W (www.start.ofitall.com).

In Detritus (& possibly older?) a change is needed to 'function notify()' in inc/common.php, to set 'self' to 'true':

diff -Naur common.php.orig common.php
--- common.php.orig
+++ common.php
@@ -1318,7 +1318,7 @@
     } elseif($who == 'subscribers') {
         if(!actionOK('subscribe')) return false; //subscribers enabled?
         if($conf['useacl'] && $INPUT->server->str('REMOTE_USER') && $minor) return false; //skip minors
-        $data = array('id' => $id, 'addresslist' => '', 'self' => false, 'replacements' => $replace);
+        $data = array('id' => $id, 'addresslist' => '', 'self' => true, 'replacements' => $replace);
         trigger_event(
             'COMMON_NOTIFY_ADDRESSLIST', $data,
             array(new Subscription(), 'notifyaddresses')

davemidd 2015-09-14 11:32

Implementation Of Work-Around

  • Edit the inc/common.php file.
  • At the end of this file is a function called subscriber_addresslist(…). This function gets the list of subscribers to a page. This function should now have a new parameter ($exclude_current_user). And it checks if the given user is the current user in the foreach loop and skips it. Replace your version with this new version:
/**
 * Return a string with the email addresses of all the
 * users subscribed to a page
 *
 * @param  string     $id					  Page id.
 * @param  boolean    $exclude_current_user   Indicates whether to skip the currently logged in user. To prevent email of your OWN changes to you.
 * 
 * @author Steven Danz <steven-danz@kc.rr.com>
 * @author (Workaround to skip current user) Sherri Wheeler (www.start.ofitall.com)
 */
function subscriber_addresslist($id, $exclude_current_user=false){
  global $conf;
  global $auth;
  global $USERINFO;

  $emails = '';

  if (!$conf['subscribers']) return;

  $mlist = array();
  $file=metaFN($id,'.mlist');
  if (@file_exists($file)) {
    $mlist = file($file);
  }
  foreach ($mlist as $who) {
    $who = rtrim($who);
    $info = $auth->getUserData($who);
    $level = auth_aclcheck($id,$who,$info['grps']);

    if(  $exclude_current_user && ($info['mail'] == $USERINFO['mail'])  ){	    
      continue;
    }

    if ($level >= AUTH_READ) {
      if (strcasecmp($info['mail'],$conf['notify']) != 0) {
        if (empty($emails)) {
          $emails = $info['mail'];
        } else {
          $emails = "$emails,".$info['mail'];
        }
      }
    }
  }

  return $emails;
}
  • Finally, in the same file, the notify(…) function makes a call to the subscriber_addresslist function (around line 841). Change this to the following:
...
$bcc  = subscriber_addresslist($id, true);	// Exclude current user (author of the changes).
...
  • That's it! It may be helpful to, instead of hard-coding the 'true' value into the call to subscriber_addresslist (…), to rather make that into a config variable.
tips/subscription.txt · Last modified: 2015-09-14 11:33 by davemidd

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki