aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-02-17 19:47:36 -0800
committerfriendica <info@friendica.com>2015-02-17 19:47:36 -0800
commite00be4de2353e1ca58570bf37fd247ff99fa549f (patch)
tree19117fb4898603af951732c1c3a3cfd72b72ff6d
parent8c717f910acd0131bd4e0a31bbe47e6f03acffe9 (diff)
downloadvolse-hubzilla-e00be4de2353e1ca58570bf37fd247ff99fa549f.tar.gz
volse-hubzilla-e00be4de2353e1ca58570bf37fd247ff99fa549f.tar.bz2
volse-hubzilla-e00be4de2353e1ca58570bf37fd247ff99fa549f.zip
The Diaspora communications policies allow comments to public posts literally from anybody. Allow this policy model by default for commenters from that network. This policy decision can be set or disabled on the addon/features settings page.
-rwxr-xr-xinclude/diaspora.php52
-rw-r--r--mod/settings.php25
-rw-r--r--view/css/mod_settings.css14
-rwxr-xr-xview/tpl/settings_addons.tpl11
4 files changed, 81 insertions, 21 deletions
diff --git a/include/diaspora.php b/include/diaspora.php
index 559a9d14d..d2e27aafe 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -1271,31 +1271,21 @@ function diaspora_comment($importer,$xml,$msg) {
return;
}
- if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'post_comments'))) {
- logger('diaspora_comment: Ignoring this author.');
- return 202;
- }
- // Friendica is currently truncating guids at 64 chars
+
+ $pubcomment = get_pconfig($importer['channel_id'],'system','diaspora_public_comments');
- $search_guid = $guid;
- if(strlen($guid) == 64)
- $search_guid = $guid . '%';
+ // by default comments on public posts are allowed from anybody on Diaspora. That is their policy.
+ // Once this setting is set to something we'll track your preference and it will over-ride the default.
- $r = q("SELECT * FROM item WHERE uid = %d AND mid like '%s' LIMIT 1",
- intval($importer['channel_id']),
- dbesc($search_guid)
- );
- if($r) {
- logger('diaspora_comment: our comment just got relayed back to us (or there was a guid collision) : ' . $guid);
- return;
- }
+ if($pubcomment === false)
+ $pubcomment = 1;
+ // Friendica is currently truncating guids at 64 chars
$search_guid = $parent_guid;
if(strlen($parent_guid) == 64)
$search_guid = $parent_guid . '%';
-
$r = q("SELECT * FROM item WHERE uid = %d AND mid LIKE '%s' LIMIT 1",
intval($importer['channel_id']),
dbesc($search_guid)
@@ -1304,8 +1294,36 @@ function diaspora_comment($importer,$xml,$msg) {
logger('diaspora_comment: parent item not found: parent: ' . $parent_guid . ' item: ' . $guid);
return;
}
+
$parent_item = $r[0];
+ if(intval($parent_item['item_private']))
+ $pubcomment = 0;
+
+ // So basically if something arrives at the sys channel it's by definition public and we allow it.
+ // If $pubcomment and the parent was public, we allow it.
+ // In all other cases, honour the permissions for this Diaspora connection
+
+ if((! $importer['system']) && (! $pubcomment) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'post_comments'))) {
+ logger('diaspora_comment: Ignoring this author.');
+ return 202;
+ }
+
+ $search_guid = $guid;
+ if(strlen($guid) == 64)
+ $search_guid = $guid . '%';
+
+
+ $r = q("SELECT * FROM item WHERE uid = %d AND mid like '%s' LIMIT 1",
+ intval($importer['channel_id']),
+ dbesc($search_guid)
+ );
+ if($r) {
+ logger('diaspora_comment: our comment just got relayed back to us (or there was a guid collision) : ' . $guid);
+ return;
+ }
+
+
/* How Diaspora performs comment signature checking:
diff --git a/mod/settings.php b/mod/settings.php
index 8c927a97c..2ccedcb7b 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -114,6 +114,12 @@ function settings_post(&$a) {
check_form_security_token_redirectOnErr('/settings/featured', 'settings_featured');
call_hooks('feature_settings_post', $_POST);
+
+ if($_POST['dspr-submit']) {
+ set_pconfig(local_channel(),'system','diaspora_public_comments',intval($_POST['dspr_pubcomment']));
+ info( t('Diaspora Policy Settings updated.') . EOL);
+ }
+
build_sync_packet();
return;
}
@@ -648,18 +654,31 @@ function settings_content(&$a) {
}
if((argc() > 1) && (argv(1) === 'featured')) {
$settings_addons = "";
+
+ $o = '';
+ $diaspora_enabled = get_config('system','diaspora_enabled');
$r = q("SELECT * FROM `hook` WHERE `hook` = 'feature_settings' ");
- if(! count($r))
+ if((! $r) && (! $diaspora_enabled))
$settings_addons = t('No feature settings configured');
+ if($diaspora_enabled) {
+ $pubcomments = get_pconfig(local_channel(),'system','diaspora_public_comments');
+ if($pubcomments === false)
+ $pubcomments = 1;
+ }
+
call_hooks('feature_settings', $settings_addons);
-
-
+
$tpl = get_markup_template("settings_addons.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_featured"),
'$title' => t('Feature Settings'),
+ '$diaspora_enabled' => $diaspora_enabled,
+ '$pubcomments' => $pubcomments,
+ '$dsprtitle' => t('Diaspora Policy Settings'),
+ '$dsprhelp' => t('Allow any Diaspora member to comment on your public posts.'),
+ '$dsprsubmit' => t('Submit Diaspora Policy Settings'),
'$settings_addons' => $settings_addons
));
return $o;
diff --git a/view/css/mod_settings.css b/view/css/mod_settings.css
index cd66684f8..5fb139074 100644
--- a/view/css/mod_settings.css
+++ b/view/css/mod_settings.css
@@ -64,3 +64,17 @@ ul#settings-privacy-macros {
clear: both;
margin-bottom: 15px;
}
+
+#dspr-pubcomment-label {
+ float: left;
+ width: 200px;
+ margin-bottom: 25px;
+}
+
+#dspr-pubcomment-checkbox {
+ float: left;
+}
+
+#settings-dspr-wrapper {
+ margin-top: 15px;
+}
diff --git a/view/tpl/settings_addons.tpl b/view/tpl/settings_addons.tpl
index f0d5195bf..a18f57658 100755
--- a/view/tpl/settings_addons.tpl
+++ b/view/tpl/settings_addons.tpl
@@ -1,10 +1,19 @@
<div class="generic-content-wrapper-styled">
<h1>{{$title}}</h1>
-
<form action="settings/featured" method="post" autocomplete="off">
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
+{{if $diaspora_enabled}}
+<div class="settings-block">
+<button class="btn btn-default" data-target="#settings-dspr-wrapper" data-toggle="collapse" type="button">{{$dsprtitle}}</button>
+<div id="settings-dspr-wrapper" class="collapse well">
+<div id="dspr-settings-wrapper">
+<label id="dspr-pubcomment-label" for="dspr-pubcomment-checkbox">{{$dsprhelp}}</label>
+<input id="dspr-pubcomment-checkbox" type="checkbox" name="dspr_pubcomment" value="1" ' . {{if $pubcomments}} checked="checked" {{/if}} />
+</div><div class="clear"></div>
+<div class="settings-submit-wrapper" ><input type="submit" name="dspr-submit" class="settings-submit" value="{{$dsprsubmit}}" /></div></div></div>
+{{/if}}
{{$settings_addons}}
</form>