summaryrefslogtreecommitdiff
path: root/inc/subscription.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-08-12 17:17:34 +0200
committerAndreas Gohr <andi@splitbrain.org>2012-08-12 17:17:34 +0200
commit835242b0f53a72a555ad30543a1677108ce210af (patch)
treec52fb30bc69075419132d3e32be3f0d71107629f /inc/subscription.php
parent8c7bcacde38ed7306d14a7e5769d6d1f2f8b9a21 (diff)
downloadrpg-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.
Diffstat (limited to 'inc/subscription.php')
-rw-r--r--inc/subscription.php57
1 files changed, 24 insertions, 33 deletions
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