aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-10-15 10:51:58 +0000
committerMario <mario@mariovavti.com>2020-10-15 10:51:58 +0000
commit3b252d98b89b884be995f6f90e31d7e6612cf522 (patch)
treef2ec4933fbcb4f3016d60951caf4cc9ac739c5af
parentf5315ed6a2bf0ac3fa4e6e5dac8671ec7abafd76 (diff)
downloadvolse-hubzilla-3b252d98b89b884be995f6f90e31d7e6612cf522.tar.gz
volse-hubzilla-3b252d98b89b884be995f6f90e31d7e6612cf522.tar.bz2
volse-hubzilla-3b252d98b89b884be995f6f90e31d7e6612cf522.zip
add forums to acl selector where appropriate
-rw-r--r--include/acl_selectors.php47
-rw-r--r--include/xchan.php2
-rw-r--r--view/js/acl.js54
-rwxr-xr-xview/tpl/acl_selector.tpl8
4 files changed, 89 insertions, 22 deletions
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index 35e385058..30219a476 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -79,24 +79,44 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
$custom = false;
}
- $r = q("SELECT id, profile_guid, profile_name from profile where is_default = 0 and uid = %d order by profile_name",
+ $r = q("SELECT id, hash, gname FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval(local_channel())
);
+
if($r) {
- foreach($r as $rv) {
- $selected = (($single_group && 'vp.' . $rv['profile_guid'] === $allow_gid[0]) ? ' selected = "selected" ' : '');
- $groups .= '<option id="' . 'vp' . $rv['id'] . '" value="' . 'vp.' . $rv['profile_guid'] . '"' . $selected . '>' . t('Profile','acl') . ' ' . $rv['profile_name'] . '</option>' . "\r\n";
+ $groups .= '<optgroup label = "' . t('Privacy Groups').'">';
+ foreach($r as $rr) {
+ $selected = (($single_group && $rr['hash'] === $allow_gid[0]) ? ' selected = "selected" ' : '');
+ $groups .= '<option id="' . $rr['id'] . '" value="' . $rr['hash'] . '"' . $selected . '>' . $rr['gname'] . '</option>' . "\r\n";
}
+ $groups .= '</optgroup>';
}
- $r = q("SELECT id, hash, gname FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
+ $r = q("SELECT id, profile_guid, profile_name from profile where is_default = 0 and uid = %d order by profile_name",
intval(local_channel())
);
if($r) {
- foreach($r as $rr) {
- $selected = (($single_group && $rr['hash'] === $allow_gid[0]) ? ' selected = "selected" ' : '');
- $groups .= '<option id="' . $rr['id'] . '" value="' . $rr['hash'] . '"' . $selected . '>' . $rr['gname'] . '</option>' . "\r\n";
+ $groups .= '<optgroup label = "' . t('Profile-Based Privacy Groups').'">';
+ foreach($r as $rv) {
+ $selected = (($single_group && 'vp.' . $rv['profile_guid'] === $allow_gid[0]) ? ' selected = "selected" ' : '');
+ $groups .= '<option id="' . 'vp' . $rv['id'] . '" value="' . 'vp.' . $rv['profile_guid'] . '"' . $selected . '>' . $rv['profile_name'] . '</option>' . "\r\n";
+ }
+ $groups .= '</optgroup>';
+ }
+
+ // $dialog_description is only set in places where we set permissions for a post.
+ // Abuse this fact to decide if forums should be displayed or not.
+ if($dialog_description) {
+ $forums = get_forum_channels(local_channel(),1);
+
+ if($forums) {
+ $groups .= '<optgroup label = "' . t('Forums').'">';
+ foreach($forums as $f) {
+ $selected = (($single_group && $f['hash'] === $allow_cid[0]) ? ' selected = "selected" ' : '');
+ $groups .= '<option id="^' . $f['abook_id'] . '" value="^' . $f['xchan_hash'] . '"' . $selected . '>' . $f['xchan_name'] . '</option>' . "\r\n";
+ }
+ $groups .= '</optgroup>';
}
}
@@ -104,17 +124,18 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
$o = replace_macros($tpl, array(
'$showall' => $showall_caption,
'$onlyme' => t('Only me'),
- '$groups' => $groups,
+ '$groups' => $groups,
'$public_selected' => (($has_acl) ? false : true),
'$justme_selected' => $just_me,
'$custom_selected' => $custom,
'$showallOrigin' => $showall_origin,
'$showallIcon' => $showall_icon,
- '$select_label' => t('Who can see this?'),
+ '$select_label' => t('Share with'),
'$custom' => t('Custom selection'),
- '$showlimitedDesc' => t('Select "Show" to allow viewing. "Don\'t show" lets you override and limit the scope of "Show".'),
- '$show' => t('Show'),
- '$hide' => t("Don't show"),
+ '$custom_label' => t('Advanced'),
+ '$showlimitedDesc' => t('Select "Allow" to allow viewing. "Don\'t allow" lets you override and limit the scope of "Allow".'),
+ '$show' => t('Allow'),
+ '$hide' => t("Don't allow"),
'$search' => t('Search'),
'$allowcid' => json_encode($allow_cid),
'$allowgid' => json_encode($allow_gid),
diff --git a/include/xchan.php b/include/xchan.php
index d69d707aa..8032dae2f 100644
--- a/include/xchan.php
+++ b/include/xchan.php
@@ -264,4 +264,4 @@ function xchan_change_key($oldx,$newx,$data) {
foreach($acls as $k => $v) {
xchan_keychange_acl($k,$v,$oldx,$newx);
}
-} \ No newline at end of file
+}
diff --git a/view/js/acl.js b/view/js/acl.js
index 9415113dd..4151331fb 100644
--- a/view/js/acl.js
+++ b/view/js/acl.js
@@ -14,6 +14,9 @@ function ACL(backend_url) {
that.group_uids = [];
that.group_ids = [];
+ that.contact_uids = [];
+ that.contact_ids = [];
+
that.selected_id = '';
that.info = $("#acl-info");
@@ -147,15 +150,30 @@ ACL.prototype.on_showall = function(event) {
};
ACL.prototype.on_showgroup = function(event) {
- var xid = that.acl_select.children(":selected").val();
+
+ var xid = that.acl_select.val();
+ var cid = '';
+
+ if(xid.length && xid.substr(0,1) == '^') {
+ cid = xid.slice(1);
+ xid = '';
+ }
// preventDefault() isn't called here as we want state changes from update_view() to be applied to the radiobutton
event.stopPropagation();
- that.allow_cid = [];
- that.allow_gid = [xid];
- that.deny_cid = [];
- that.deny_gid = [];
+ if (xid.length) {
+ that.allow_cid = [];
+ that.allow_gid = [xid];
+ that.deny_cid = [];
+ that.deny_gid = [];
+ }
+ else {
+ that.allow_cid = [cid];
+ that.allow_gid = [];
+ that.deny_cid = [];
+ that.deny_gid = [];
+ }
that.update_view();
that.on_submit();
@@ -307,6 +325,17 @@ ACL.prototype.update_view = function(value) {
$('#dbtn-jotnets').hide();
$('.profile-jot-net input').attr('disabled', 'disabled');
}
+ else if (that.allow_gid.length === 0 && that.allow_cid.length === 1 && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value !== 'custom') {
+ that.list.hide(); //hide acl-list
+ that.info.hide(); //show acl-info
+ that.selected_id = that.contact_ids[that.allow_cid[0]];
+ that.update_select(that.selected_id);
+
+ /* jot acl */
+ $('#jot-perms-icon, #dialog-perms-icon, #' + that.form_id[0].id + ' .jot-perms-icon').removeClass('fa-unlock').addClass('fa-lock');
+ $('#dbtn-jotnets').hide();
+ $('.profile-jot-net input').attr('disabled', 'disabled');
+ }
else {
that.list.show(); //show acl-list
@@ -382,6 +411,21 @@ ACL.prototype.update_view = function(value) {
bthide.removeClass("btn-outline-danger").addClass("btn-danger");
$(this).removeClass("groupshow");
}
+ $(that.contact_uids[id]).each(function(i, v) {
+ if(uclass == "grouphide")
+ // we need attr selection here because the id can include an @ (diaspora/friendica xchans)
+ $('[id="g' + v + '"]').removeClass("groupshow");
+ if(uclass !== "") {
+ var cls = $('[id="g' + v + '"]').attr('class');
+ if( cls === undefined)
+ return true;
+ var hiding = cls.indexOf('grouphide');
+ if(hiding == -1)
+ $('[id="g' + v + '"]').addClass(uclass);
+ }
+ });
+ break;
+
}
});
}
diff --git a/view/tpl/acl_selector.tpl b/view/tpl/acl_selector.tpl
index 3d05cb455..7447644a9 100755
--- a/view/tpl/acl_selector.tpl
+++ b/view/tpl/acl_selector.tpl
@@ -15,12 +15,14 @@
{{if $aclModalDesc}}
<div id="acl-dialog-description" class="section-content-info-wrapper">{{$aclModalDesc}}</div>
{{/if}}
- <label for="acl-select">{{$select_label}}</label>
+ <label for="acl-select">{{if $aclModalDesc}}<i class="fa fa-send-o"></i> {{/if}}{{$select_label}}</label>
<select id="acl-select" name="optionsRadios" class="form-control form-group">
<option id="acl-showall" value="public" {{$public_selected}}>{{$showall}}</option>
- {{$groups}}
<option id="acl-onlyme" value="onlyme" {{$justme_selected}}>{{$onlyme}}</option>
- <option id="acl-custom" value="custom" {{$custom_selected}}>{{$custom}}</option>
+ {{$groups}}
+ <optgroup label = "{{$custom_label}}">;
+ <option id="acl-custom" value="custom" {{$custom_selected}}>{{$custom}}</option>
+ </optgroup>;
</select>
{{if $showallOrigin}}