From 84c1127cc070777c8cbcf488f5422bc4b71470a8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 12 Aug 2012 17:30:01 +0200 Subject: correctly check if subscriptions are enabled --- inc/common.php | 2 +- inc/subscription.php | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'inc') 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 @@ -21,6 +21,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 * @@ -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 */ 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']; -- cgit v1.2.3