diff options
-rwxr-xr-x | include/diaspora.php | 19 | ||||
-rw-r--r-- | include/follow.php | 9 | ||||
-rw-r--r-- | mod/settings.php | 7 | ||||
-rwxr-xr-x | view/tpl/settings_addons.tpl | 1 |
4 files changed, 34 insertions, 2 deletions
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; diff --git a/mod/settings.php b/mod/settings.php index 692668060..b0ba04dfc 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -124,6 +124,7 @@ function settings_post(&$a) { call_hooks('feature_settings_post', $_POST); if($_POST['dspr-submit']) { + set_pconfig(local_channel(),'system','diaspora_allowed',intval($_POST['dspr_allowed'])); set_pconfig(local_channel(),'system','diaspora_public_comments',intval($_POST['dspr_pubcomment'])); set_pconfig(local_channel(),'system','prevent_tag_hijacking',intval($_POST['dspr_hijack'])); info( t('Diaspora Policy Settings updated.') . EOL); @@ -667,12 +668,13 @@ function settings_content(&$a) { $settings_addons = t('No feature settings configured'); if($diaspora_enabled) { + $dspr_allowed = get_pconfig(local_channel(),'system','diaspora_allowed'); + if($dspr_allowed === false) + $dspr_allowed = 1; $pubcomments = get_pconfig(local_channel(),'system','diaspora_public_comments'); if($pubcomments === false) $pubcomments = 1; $hijacking = get_pconfig(local_channel(),'system','prevent_tag_hijacking'); - - } call_hooks('feature_settings', $settings_addons); @@ -684,6 +686,7 @@ function settings_content(&$a) { '$diaspora_enabled' => $diaspora_enabled, '$dsprdesc' => t('Settings for the built-in Diaspora emulator'), '$pubcomments' => array('dspr_pubcomment', t('Allow any Diaspora member to comment on your public posts'), $pubcomments, '', $yes_no), + '$dspr_allowed' => array('dspr_allowed', t('Enable the Diaspora protocol for this channel'), $dspr_allowed, '', $yes_no), '$dsprtitle' => t('Diaspora Policy Settings'), '$hijacking' => array('dspr_hijack', t('Prevent your hashtags from being redirected to other sites'), $hijacking, '', $yes_no), '$dsprsubmit' => t('Submit'), diff --git a/view/tpl/settings_addons.tpl b/view/tpl/settings_addons.tpl index 9297a282a..ae8dac3f8 100755 --- a/view/tpl/settings_addons.tpl +++ b/view/tpl/settings_addons.tpl @@ -17,6 +17,7 @@ <div id="dspr-settings-content" class="panel-collapse collapse" role="tabpanel" aria-labelledby="dspr-settings"> <div class="section-content-tools-wrapper"> + {{include file="field_checkbox.tpl" field=$dspr_allowed}} {{include file="field_checkbox.tpl" field=$pubcomments}} {{include file="field_checkbox.tpl" field=$hijacking}} |