diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-08-12 17:30:01 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-08-12 17:30:01 +0200 |
commit | 84c1127cc070777c8cbcf488f5422bc4b71470a8 (patch) | |
tree | 74a3b8f4613110d97e2f7ce0797203c53a0ad1e6 | |
parent | 835242b0f53a72a555ad30543a1677108ce210af (diff) | |
download | rpg-84c1127cc070777c8cbcf488f5422bc4b71470a8.tar.gz rpg-84c1127cc070777c8cbcf488f5422bc4b71470a8.tar.bz2 |
correctly check if subscriptions are enabled
-rw-r--r-- | _test/tests/inc/subscription.test.php | 4 | ||||
-rw-r--r-- | inc/common.php | 2 | ||||
-rw-r--r-- | inc/subscription.php | 26 | ||||
-rw-r--r-- | lib/exe/indexer.php | 2 |
4 files changed, 28 insertions, 6 deletions
diff --git a/_test/tests/inc/subscription.test.php b/_test/tests/inc/subscription.test.php index be2e68b74..80548160a 100644 --- a/_test/tests/inc/subscription.test.php +++ b/_test/tests/inc/subscription.test.php @@ -212,6 +212,10 @@ class MockupSubscription extends Subscription { $this->mails = array(); } + public function isenabled(){ + return true; + } + public function buildregex($user = null, $style = null, $data = null) { return parent::buildregex($user, $style, $data); } diff --git a/inc/common.php b/inc/common.php index 3cfeb3092..b4a57b154 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1117,7 +1117,7 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = $to = $conf['notify']; $bcc = ''; } elseif($who == 'subscribers') { - if(!$conf['subscribers']) return false; //subscribers enabled? + if(!actionOK('subscribe')) return false; //subscribers enabled? if($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) return false; //skip minors $data = array('id' => $id, 'addresslist' => '', 'self' => false); trigger_event( diff --git a/inc/subscription.php b/inc/subscription.php index 9b02225f9..742f5b1a0 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -22,6 +22,15 @@ class Subscription { /** + * Check if subscription system is enabled + * + * @return bool + */ + public function isenabled() { + return actionOK('subscribe'); + } + + /** * Return the subscription meta file for the given ID * * @author Adrian Lang <lang@cosmocode.de> @@ -156,6 +165,8 @@ class Subscription { * @return array */ public function subscribers($page, $user = null, $style = null, $data = null) { + if(!$this->isenabled()) return array(); + // Construct list of files which may contain relevant subscriptions. $files = array(':' => $this->file(':')); do { @@ -201,6 +212,8 @@ class Subscription { * @return bool */ public function add($id, $user, $style, $data = '') { + if(!$this->isenabled()) return false; + // delete any existing subscription $this->remove($id, $user); @@ -234,6 +247,8 @@ class Subscription { * @return bool */ public function remove($id, $user = null, $style = null, $data = null) { + if(!$this->isenabled()) return false; + $file = $this->file($id); if(!file_exists($file)) return true; @@ -254,10 +269,9 @@ class Subscription { * @author Adrian Lang <lang@cosmocode.de> */ function user_subscription($id = '', $user = '') { - global $ID; - global $conf; - if(!$conf['subscribers']) return false; + if(!$this->isenabled()) return false; + global $ID; if(!$id) $id = $ID; if(!$user) $user = $_SERVER['REMOTE_USER']; @@ -288,6 +302,8 @@ class Subscription { * @return int number of sent mails */ public function send_bulk($page) { + if(!$this->isenabled()) return 0; + /** @var auth_basic $auth */ global $auth; global $conf; @@ -497,9 +513,11 @@ class Subscription { * @return string */ public function notifyaddresses(&$data) { - global $conf; + if(!$this->isenabled()) return false; + /** @var auth_basic $auth */ global $auth; + global $conf; $id = $data['id']; $self = $data['self']; diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 270341fe6..bbfd51b39 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -170,7 +170,7 @@ function sendDigest() { global $ID; echo 'sendDigest(): started'.NL; - if (!$conf['subscribers']) { + if(!actionOK('subscribe')) { echo 'sendDigest(): disabled'.NL; return false; } |