diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-08-12 17:17:34 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-08-12 17:17:34 +0200 |
commit | 835242b0f53a72a555ad30543a1677108ce210af (patch) | |
tree | c52fb30bc69075419132d3e32be3f0d71107629f | |
parent | 8c7bcacde38ed7306d14a7e5769d6d1f2f8b9a21 (diff) | |
download | rpg-835242b0f53a72a555ad30543a1677108ce210af.tar.gz rpg-835242b0f53a72a555ad30543a1677108ce210af.tar.bz2 |
subscription system should work now again
This readds the last part of the subscription system: the normal "every"
subscriptions.
-rw-r--r-- | inc/common.php | 2 | ||||
-rw-r--r-- | inc/subscription.php | 57 |
2 files changed, 25 insertions, 34 deletions
diff --git a/inc/common.php b/inc/common.php index 29940d8a6..3cfeb3092 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1122,7 +1122,7 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = $data = array('id' => $id, 'addresslist' => '', 'self' => false); trigger_event( 'COMMON_NOTIFY_ADDRESSLIST', $data, - 'subscription_addresslist' + array(new Subscription(), 'notifyaddresses') ); $bcc = $data['addresslist']; if(empty($bcc)) return false; diff --git a/inc/subscription.php b/inc/subscription.php index 804776ced..9b02225f9 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -12,7 +12,7 @@ * - subscription_lock * - subscription_unlock * - * @fixme handle $conf['subscribers'] and disable actions + * @fixme handle $conf['subscribers'] and disable actions and $auth == null * * @author Adrian Lang <lang@cosmocode.de> * @author Andreas Gohr <andi@splitbrain.org> @@ -480,26 +480,23 @@ class Subscription { return $mail->send(); } - - - // FIXME no refactoring below, yet - /** - * Return a string with the email addresses of all the - * users subscribed to a page + * Default callback for COMMON_NOTIFY_ADDRESSLIST * - * This is the default action for COMMON_NOTIFY_ADDRESSLIST. + * Aggregates all email addresses of user who have subscribed the given page with 'every' style * * @author Steven Danz <steven-danz@kc.rr.com> * @author Adrian Lang <lang@cosmocode.de> * - * @todo this does NOT return a string but uses a reference to write back, either fix function or docs - * @param array $data Containing $id (the page id), $self (whether the author - * should be notified, $addresslist (current email address - * list) + * @todo move the whole functionality into this class, trigger SUBSCRIPTION_NOTIFY_ADDRESSLIST instead, + * use an array for the addresses within it + * + * @param array &$data Containing $id (the page id), $self (whether the author + * should be notified, $addresslist (current email address + * list) * @return string */ - function subscription_addresslist(&$data) { + public function notifyaddresses(&$data) { global $conf; /** @var auth_basic $auth */ global $auth; @@ -508,30 +505,24 @@ class Subscription { $self = $data['self']; $addresslist = $data['addresslist']; - if(!$conf['subscribers'] || $auth === null) { - return ''; - } - $pres = array('style' => 'every', 'escaped' => true); - if(!$self && isset($_SERVER['REMOTE_USER'])) { - $pres['user'] = '((?!'.preg_quote_cb($_SERVER['REMOTE_USER']). - '(?: |$))\S+)'; - } - $subs = subscription_find($id, $pres); - $emails = array(); - foreach($subs as $by_targets) { - foreach($by_targets as $sub) { - $info = $auth->getUserData($sub[0]); - if($info === false) continue; - $level = auth_aclcheck($id, $sub[0], $info['grps']); + $subscriptions = $this->subscribers($id, null, 'every'); + + $result = array(); + foreach($subscriptions as $target => $users) { + foreach($users as $user => $info) { + $userinfo = $auth->getUserData($user); + if($userinfo === false) continue; + if(!$userinfo['mail']) continue; + if(!$self && $user == $_SERVER['REMOTE_USER']) continue; //skip our own changes + + $level = auth_aclcheck($id, $user, $userinfo['grps']); if($level >= AUTH_READ) { - if(strcasecmp($info['mail'], $conf['notify']) != 0) { - $emails[$sub[0]] = $info['mail']; + if(strcasecmp($userinfo['mail'], $conf['notify']) != 0) { //skip user who get notified elsewhere + $result[$user] = $userinfo['mail']; } } } } - $data['addresslist'] = trim($addresslist.','.implode(',', $emails), ','); + $data['addresslist'] = trim($addresslist.','.implode(',', $result), ','); } - - }
\ No newline at end of file |