From b6ca9b6020e2eae0b5389148ce45bc2f7a81f999 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 16 Oct 2020 10:32:07 +0000 Subject: make acl selector work correctly if we provide a cid in mod network --- Zotlabs/Module/Network.php | 25 ++++++++++++++----------- boot.php | 2 +- include/text.php | 8 +++++++- view/js/acl.js | 26 +++++++++++++++++++++----- view/tpl/jot.tpl | 2 +- 5 files changed, 44 insertions(+), 19 deletions(-) diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index fe1aa4386..df60fb9a3 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -133,8 +133,6 @@ class Network extends \Zotlabs\Web\Controller { $pf = ((x($_GET,'pf')) ? $_GET['pf'] : ''); $unseen = ((x($_GET,'unseen')) ? $_GET['unseen'] : ''); - $deftag = ''; - if (Apps::system_app_installed(local_channel(),'Affinity Tool')) { $affinity_locked = intval(get_pconfig(local_channel(),'affinity','lock',1)); if ($affinity_locked) { @@ -160,10 +158,7 @@ class Network extends \Zotlabs\Web\Controller { goaway(z_root() . '/network'); // NOTREACHED } - if($pf) - $deftag = '!{' . (($cid_r[0]['xchan_addr']) ? $cid_r[0]['xchan_addr'] : $cid_r[0]['xchan_url']) . '}'; - else - $def_acl = [ 'allow_cid' => '<' . $cid_r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; + $def_acl = [ 'allow_cid' => '<' . $cid_r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } if(! $update) { @@ -177,6 +172,17 @@ class Network extends \Zotlabs\Web\Controller { nav_set_selected('Network'); + $bang = '!'; + + if($cid_r) { + $forums = get_forum_channels($channel['channel_id']); + if($forums) { + $forum_xchans = ids_to_array($forums, 'xchan_hash'); + if(in_array($cid_r[0]['abook_xchan'], $forum_xchans)) + $bang = $cid_r[0]['abook_xchan']; + } + } + $channel_acl = array( 'allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], @@ -184,7 +190,7 @@ class Network extends \Zotlabs\Web\Controller { 'deny_gid' => $channel['channel_deny_gid'] ); - $private_editing = ((($group || $cid) && (! intval($_GET['pf']))) ? true : false); + $private_editing = (($group || $cid) ? true : false); $x = array( 'is_owner' => true, @@ -194,7 +200,7 @@ class Network extends \Zotlabs\Web\Controller { 'lockstate' => (($private_editing || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), 'acl' => populate_acl((($private_editing) ? $def_acl : $channel_acl), true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'), 'permissions' => (($private_editing) ? $def_acl : $channel_acl), - 'bang' => (($private_editing) ? '!' : ''), + 'bang' => (($private_editing) ? $bang : ''), 'visitor' => true, 'profile_uid' => local_channel(), 'editor_autocomplete' => true, @@ -203,9 +209,6 @@ class Network extends \Zotlabs\Web\Controller { 'jotnets' => true, 'reset' => t('Reset form') ); - if($deftag) - $x['pretext'] = $deftag; - $status_editor = status_editor($a,$x,false,'Network'); $o .= $status_editor; diff --git a/boot.php b/boot.php index b722048a9..e77a5260c 100755 --- a/boot.php +++ b/boot.php @@ -50,7 +50,7 @@ require_once('include/attach.php'); require_once('include/bbcode.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); -define ( 'STD_VERSION', '5.1' ); +define ( 'STD_VERSION', '5.1.1' ); define ( 'ZOT_REVISION', '6.0' ); define ( 'DB_UPDATE_VERSION', 1238 ); diff --git a/include/text.php b/include/text.php index af1473713..0a54ddd2f 100644 --- a/include/text.php +++ b/include/text.php @@ -3661,11 +3661,15 @@ function get_forum_channels($uid) { if(! $uid) return; - $xf = false; + if(App::$data['forum_channels']) + return App::$data['forum_channels']; + + $xf = ''; $x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = '0'", intval($uid) ); + if($x1) { $xc = ids_to_querystr($x1,'xchan',true); @@ -3702,6 +3706,8 @@ function get_forum_channels($uid) { } } + App::$data['forum_channels'] = $r; + return $r; } diff --git a/view/js/acl.js b/view/js/acl.js index 4151331fb..4597184ea 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -12,10 +12,12 @@ function ACL(backend_url) { that.deny_cid = []; that.deny_gid = []; - that.group_uids = []; - that.group_ids = []; - that.contact_uids = []; - that.contact_ids = []; + that.group_uids = {}; + that.group_ids = {}; + that.contact_uids = {}; + that.contact_ids = {}; + + that.bang = ''; that.selected_id = ''; @@ -81,6 +83,8 @@ ACL.prototype.get_form_data = function(event) { that.deny_cid = (that.form_id.data('deny_cid') || []); that.deny_gid = (that.form_id.data('deny_gid') || []); + that.bang = (that.form_id.data('bang') || ''); + that.update_view(); that.on_submit(); @@ -167,6 +171,7 @@ ACL.prototype.on_showgroup = function(event) { that.allow_gid = [xid]; that.deny_cid = []; that.deny_gid = []; + } else { that.allow_cid = [cid]; @@ -326,10 +331,16 @@ ACL.prototype.update_view = function(value) { $('.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') { + + if(that.bang && that.bang !== that.allow_cid[0]) { + that.update_view('custom'); + return; + } + 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); + 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'); @@ -338,6 +349,7 @@ ACL.prototype.update_view = function(value) { } else { + that.list.show(); //show acl-list datasrc2src('#acl-list-content .list-group-item img[data-src]'); that.info.hide(); //hide acl-info @@ -459,9 +471,13 @@ ACL.prototype.populate = function(data) { that.group_uids[this.xid] = this.uids; that.group_ids[this.xid] = this.id; } + else { + that.contact_ids[this.xid] = this.id; + } if (this.self === 'abook-self') { that.self[0] = this.xid; } + that.list_content.append(html); }); }; diff --git a/view/tpl/jot.tpl b/view/tpl/jot.tpl index 4e496b511..36543ccfa 100755 --- a/view/tpl/jot.tpl +++ b/view/tpl/jot.tpl @@ -1,6 +1,6 @@ -
+ {{$mimeselect}} {{$layoutselect}} {{if $id_select}} -- cgit v1.2.3