From d08c43d80ceb5fa6c96c328b8b36b59f4bb8e6f6 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 9 Jun 2015 18:50:11 -0700 Subject: toggle diaspora protocol on a per-channel level in addition to the existing per site setting. Default is enabled if the site setting is enabled. --- include/diaspora.php | 19 +++++++++++++++++++ include/follow.php | 9 +++++++++ 2 files changed, 28 insertions(+) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 25e0027b2..33ad4211b 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -64,6 +64,15 @@ function diaspora_dispatch($importer,$msg) { return; } + $allowed = get_pconfig($importer['channel_id'],'system','diaspora_allowed'); + if($allowed === false) + $allowed = 1; + + if(! intval($allowed)) { + logger('mod-diaspora: disallowed for channel ' . $importer['channel_name']); + return; + } + // php doesn't like dashes in variable names $msg['message'] = str_replace( @@ -169,6 +178,16 @@ function diaspora_process_outbound($arr) { */ + $allowed = get_pconfig($arr['channel']['channel_id'],'system','diaspora_allowed'); + if($allowed === false) + $allowed = 1; + + if(! intval($allowed)) { + logger('mod-diaspora: disallowed for channel ' . $arr['channel']['channel_name']); + return; + } + + if($arr['location']) return; diff --git a/include/follow.php b/include/follow.php index fd4e1597a..1e5df4cd5 100644 --- a/include/follow.php +++ b/include/follow.php @@ -135,6 +135,15 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) $result['message'] = t('Protocol disabled.'); return $result; } + + $allowed = get_pconfig($uid,'system','diaspora_allowed'); + if($allowed === false) + $allowed = 1; + + if(! intval($allowed)) { + $result['message'] = t('Protocol blocked for this channel.'); + return $result; + } } $their_perms = 0; -- cgit v1.2.3