aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-10-17 20:52:02 -0700
committerzotlabs <mike@macgirvin.com>2016-10-17 20:52:02 -0700
commitf31ef3420db5ed600a988dc300f2d2f56b31acc6 (patch)
tree311833670e6798d16a425f8551b1d0f2b6f9f03b
parentb37184ae5758e1a93efb0c2334edae848dbb148a (diff)
downloadvolse-hubzilla-f31ef3420db5ed600a988dc300f2d2f56b31acc6.tar.gz
volse-hubzilla-f31ef3420db5ed600a988dc300f2d2f56b31acc6.tar.bz2
volse-hubzilla-f31ef3420db5ed600a988dc300f2d2f56b31acc6.zip
issue #549, ACL has 'public' selected even when restrictive ACL is being used.
-rw-r--r--include/acl_selectors.php30
-rwxr-xr-xview/tpl/acl_selector.tpl6
2 files changed, 31 insertions, 5 deletions
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index 80d1f1216..dcf0fe9a2 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -152,13 +152,36 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
array_walk($deny_gid,'fixacl');
}
+
+ $channel = ((local_channel()) ? \App::get_channel() : '');
+ $has_acl = false;
+ $single_group = false;
+ $just_me = false;
+ $custom = false;
+
+ if($allow_cid || $allow_gid || $deny_gid || $deny_cid) {
+ $has_acl = true;
+ $custom = true;
+ }
+
+ if(count($allow_gid) === 1 && (! $allow_cid) && (! $deny_gid) && (! $deny_cid)) {
+ $single_group = true;
+ $custom = false;
+ }
+
+ if(count($allow_cid) === 1 && $channel && $allow_cid[0] = $channel['channel_hash'] && (! $allow_gid) && (! $deny_gid) && (! $deny_cid)) {
+ $just_me = true;
+ $custom = false;
+ }
+
$r = q("SELECT id, hash, gname FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval(local_channel())
);
if($r) {
foreach($r as $rr) {
- $groups .= '<option id="' . $rr['id'] . '" value="' . $rr['hash'] . '">' . $rr['gname'] . '</option>' . "\r\n";
+ $selected = (($single_group && $rr['hash'] === $allow_gid[0]) ? ' selected = "selected" ' : '');
+ $groups .= '<option id="' . $rr['id'] . '" value="' . $rr['hash'] . '"' . $selected . '>' . $rr['gname'] . '</option>' . "\r\n";
}
}
@@ -166,7 +189,10 @@ 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?'),
diff --git a/view/tpl/acl_selector.tpl b/view/tpl/acl_selector.tpl
index dbdbd6a56..c23840c16 100755
--- a/view/tpl/acl_selector.tpl
+++ b/view/tpl/acl_selector.tpl
@@ -15,10 +15,10 @@
{{/if}}
<label for="acl-select">{{$select_label}}</label>
<select id="acl-select" name="optionsRadios" class="form-control form-group">
- <option id="acl-showall" value="public" selected>{{$showall}}</option>
+ <option id="acl-showall" value="public" {{$public_selected}}>{{$showall}}</option>
{{$groups}}
- <option id="acl-onlyme" value="onlyme">{{$onlyme}}</option>
- <option id="acl-custom" value="custom">{{$custom}}</option>
+ <option id="acl-onlyme" value="onlyme" {{$justme_selected}}>{{$onlyme}}</option>
+ <option id="acl-custom" value="custom" {{$custom_selected}}>{{$custom}}</option>
</select>
{{if $showallOrigin}}