diff options
-rw-r--r-- | Zotlabs/Module/Channel.php | 3 | ||||
-rw-r--r-- | Zotlabs/Module/Events.php | 12 | ||||
-rw-r--r-- | Zotlabs/Module/Filestorage.php | 7 | ||||
-rw-r--r-- | Zotlabs/Module/Network.php | 1 | ||||
-rw-r--r-- | include/conversation.php | 4 | ||||
-rw-r--r-- | include/text.php | 6 | ||||
-rw-r--r-- | view/js/acl.js | 95 | ||||
-rwxr-xr-x | view/tpl/acl_selector.tpl | 6 | ||||
-rw-r--r-- | view/tpl/attach_edit.tpl | 8 | ||||
-rw-r--r-- | view/tpl/chatroom_new.tpl | 6 | ||||
-rw-r--r-- | view/tpl/cloud_actionspanel.tpl | 1 | ||||
-rwxr-xr-x | view/tpl/event_form.tpl | 9 | ||||
-rwxr-xr-x | view/tpl/jot.tpl | 9 |
13 files changed, 117 insertions, 50 deletions
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index c74802ec5..59cb9f06c 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -133,6 +133,7 @@ class Channel extends \Zotlabs\Web\Controller { 'nickname' => \App::$profile['channel_address'], 'lockstate' => (((strlen(\App::$profile['channel_allow_cid'])) || (strlen(\App::$profile['channel_allow_gid'])) || (strlen(\App::$profile['channel_deny_cid'])) || (strlen(\App::$profile['channel_deny_gid']))) ? 'lock' : 'unlock'), 'acl' => (($is_owner) ? populate_acl($channel_acl,true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post') : ''), + 'permissions' => (($is_owner) ? $channel_acl : ''), 'showacl' => (($is_owner) ? 'yes' : ''), 'bang' => '', 'visitor' => (($is_owner || $observer) ? true : false), @@ -363,4 +364,4 @@ class Channel extends \Zotlabs\Web\Controller { return $o; } -}
\ No newline at end of file +} diff --git a/Zotlabs/Module/Events.php b/Zotlabs/Module/Events.php index def5c437b..d27de9989 100644 --- a/Zotlabs/Module/Events.php +++ b/Zotlabs/Module/Events.php @@ -435,6 +435,10 @@ class Events extends \Zotlabs\Web\Controller { $acl = new \Zotlabs\Access\AccessList($channel); $perm_defaults = $acl->get(); + + $permissions = ((x($orig_event)) ? $orig_event : $perm_defaults); + + //print_r(acl2json($permissions['allow_gid'])); killme(); $tpl = get_markup_template('event_form.tpl'); @@ -467,10 +471,16 @@ class Events extends \Zotlabs\Web\Controller { '$sh_checked' => $sh_checked, '$share' => array('share', t('Share this event'), $sh_checked, '', array(t('No'),t('Yes'))), '$preview' => t('Preview'), - '$permissions' => t('Permission settings'), + '$perms_label' => t('Permission settings'), // populating the acl dialog was a permission description from view_stream because Cal.php, which // displays events, says "since we don't currently have an event permission - use the stream permission" '$acl' => (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults), false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'))), + + '$allow_cid' => acl2json($permissions['allow_cid']), + '$allow_gid' => acl2json($permissions['allow_gid']), + '$deny_cid' => acl2json($permissions['deny_cid']), + '$deny_gid' => acl2json($permissions['deny_gid']), + '$submit' => t('Submit'), '$advanced' => t('Advanced Options') diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php index c3ef22e32..c8ad147bb 100644 --- a/Zotlabs/Module/Filestorage.php +++ b/Zotlabs/Module/Filestorage.php @@ -161,7 +161,12 @@ class Filestorage extends \Zotlabs\Web\Controller { '$submit' => t('Submit'), '$attach_btn_title' => t('Share this file'), '$link_btn_title' => t('Show URL to this file'), - '$notify' => array('notify', t('Notify your contacts about this file'), 0, '', array(t('No'), t('Yes'))) + '$notify' => array('notify', t('Notify your contacts about this file'), 0, '', array(t('No'), t('Yes'))), + + '$allow_cid' => json_encode(expand_acl($f['allow_cid'])), + '$allow_gid' => json_encode(expand_acl($f['allow_gid'])), + '$deny_cid' => json_encode(expand_acl($f['deny_cid'])), + '$deny_cid' => json_encode(expand_acl($f['deny_gid'])) )); echo $o; diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 3b88cd8d6..0128adc2c 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -170,6 +170,7 @@ class Network extends \Zotlabs\Web\Controller { 'nickname' => $channel['channel_address'], '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) ? '!' : ''), 'visitor' => true, 'profile_uid' => local_channel(), diff --git a/include/conversation.php b/include/conversation.php index 1efca37f3..6bcd968f4 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1253,6 +1253,10 @@ function status_editor($a, $x, $popup = false) { '$visitor' => $x['visitor'], '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], + '$allow_cid' => acl2json($x['permissions']['allow_cid']), + '$allow_gid' => acl2json($x['permissions']['allow_gid']), + '$deny_cid' => acl2json($x['permissions']['deny_cid']), + '$deny_gid' => acl2json($x['permissions']['deny_gid']), '$mimeselect' => $mimeselect, '$layoutselect' => $layoutselect, '$showacl' => ((array_key_exists('showacl', $x)) ? $x['showacl'] : true), diff --git a/include/text.php b/include/text.php index d508f8ab3..d283bb41f 100644 --- a/include/text.php +++ b/include/text.php @@ -2824,6 +2824,12 @@ function expand_acl($s) { return $ret; } +function acl2json($s) { + $s = expand_acl($s); + $s = json_encode($s); + return $s; +} + // When editing a webpage - a dropdown is needed to select a page layout // On submit, the pdl_select value (which is the mid of an item with item_type = ITEM_TYPE_PDL) is stored in diff --git a/view/js/acl.js b/view/js/acl.js index 79699c589..175462250 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -1,15 +1,17 @@ -function ACL(backend_url, preset) { +function ACL(backend_url) { that = this; that.url = backend_url; that.kp_timer = null; - if (preset === undefined) preset = []; - that.allow_cid = (preset[0] || []); - that.allow_gid = (preset[1] || []); - that.deny_cid = (preset[2] || []); - that.deny_gid = (preset[3] || []); + that.self = []; + + that.allow_cid = []; + that.allow_gid = []; + that.deny_cid = []; + that.deny_gid = []; + that.group_uids = []; that.info = $("#acl-info"); @@ -21,11 +23,8 @@ function ACL(backend_url, preset) { that.showlimited = $("#acl-showlimited"); that.acl_select = $("#acl-select"); - that.preset = preset; - that.self = []; - // set the initial ACL lists in case the enclosing form gets submitted before the ajax loader completes. - that.on_submit(); + //that.on_submit(); /*events*/ @@ -47,32 +46,56 @@ function ACL(backend_url, preset) { } }); + $(document).on('focus', '.acl-form', that.get_form_data); + $(document).on('click', '.acl-form', that.get_form_data); + $(document).on('click','.acl-button-show',that.on_button_show); $(document).on('click','.acl-button-hide',that.on_button_hide); + $(document).on('click','.acl-button-hide',that.on_button_hide); + $("#acl-search").keypress(that.on_search); /* startup! */ that.get(0,15000); - that.on_submit(); + //that.on_submit(); }); } -// no longer called only on submit - call to update whenever a change occurs to the acl list. +ACL.prototype.get_form_data = function(event) { + + form_id = $(this).data('form_id'); + + that.form_id = $('#' + form_id); + + console.log(form_id); + + that.allow_cid = ($(this).data('allow_cid') || []); + that.allow_gid = ($(this).data('allow_gid') || []); + that.deny_cid = ($(this).data('deny_cid') || []); + that.deny_gid = ($(this).data('deny_gid') || []); + + that.update_view(); + that.on_submit(); +} + +// no longer called only on submit - call to update whenever a change occurs to the acl list. ACL.prototype.on_submit = function() { - aclfields = $("#acl-fields").html(""); + + $('.acl-field').remove(); + $(that.allow_gid).each(function(i,v) { - aclfields.append("<input type='hidden' name='group_allow[]' value='"+v+"'>"); + that.form_id.append("<input class='acl-field' type='hidden' name='group_allow[]' value='"+v+"'>"); }); $(that.allow_cid).each(function(i,v) { - aclfields.append("<input type='hidden' name='contact_allow[]' value='"+v+"'>"); + that.form_id.append("<input class='acl-field' type='hidden' name='contact_allow[]' value='"+v+"'>"); }); $(that.deny_gid).each(function(i,v) { - aclfields.append("<input type='hidden' name='group_deny[]' value='"+v+"'>"); + that.form_id.append("<input class='acl-field' type='hidden' name='group_deny[]' value='"+v+"'>"); }); $(that.deny_cid).each(function(i,v) { - aclfields.append("<input type='hidden' name='contact_deny[]' value='"+v+"'>"); + that.form_id.append("<input class='acl-field' type='hidden' name='contact_deny[]' value='"+v+"'>"); }); //areYouSure jquery plugin: recheck the form here @@ -101,6 +124,7 @@ ACL.prototype.on_onlyme = function(event) { that.deny_cid = []; that.deny_gid = []; + that.update_view(event.target.value); that.on_submit(); @@ -126,14 +150,14 @@ ACL.prototype.on_showlimited = function(event) { // preventDefault() isn't called here as we want state changes from update_view() to be applied to the radiobutton event.stopPropagation(); - if(that.preset[0].length === 0 && that.preset[1].length === 0 && that.preset[2].length === 0 && that.preset[3].length === 0) { - that.preset[0] = [that.self[0]]; + if(that.allow_cid.length === 0 && that.allow_gid.length === 0 && that.deny_cid.length === 0 && that.deny_gid.length === 0) { + that.allow_cid = [that.self[0]]; } - that.allow_cid = (that.preset[0] || []); - that.allow_gid = (that.preset[1] || []); - that.deny_cid = (that.preset[2] || []); - that.deny_gid = (that.preset[3] || []); + that.allow_cid = (that.allow_cid || []); + that.allow_gid = (that.allow_gid || []); + that.deny_cid = (that.deny_cid || []); + that.deny_gid = (that.deny_gid || []); that.update_view(event.target.value); that.on_submit(); @@ -239,13 +263,26 @@ ACL.prototype.set_deny = function(itemid) { that.update_view(); }; -ACL.prototype.update_select = function(preset) { - that.showall.prop('selected', preset === 'public'); - that.onlyme.prop('selected', preset === 'onlyme'); - that.showlimited.prop('selected', preset === 'limited'); +ACL.prototype.update_select = function(set) { + that.showall.prop('selected', set === 'public'); + that.onlyme.prop('selected', set === 'onlyme'); + that.showlimited.prop('selected', set === 'limited'); }; ACL.prototype.update_view = function(value) { + if(that.form_id) { + console.log(that.form_id); + + that.form_id.data('allow_cid', that.allow_cid); + that.form_id.data('allow_gid', that.allow_gid); + that.form_id.data('deny_cid', that.deny_cid); + that.form_id.data('deny_gid', that.deny_gid); + + console.log(that.form_id.data('allow_cid')); + console.log(that.form_id.data('allow_gid')); + console.log(that.form_id.data('deny_cid')); + console.log(that.form_id.data('deny_gid')); + } if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0) { that.list.hide(); //hide acl-list @@ -259,8 +296,8 @@ ACL.prototype.update_view = function(value) { } // if value != 'onlyme' we should fall through this one - else if (that.allow_gid.length === 0 && that.allow_cid.length === 1 && that.allow_cid[0] === that.self[0] && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value === 'onlyme') { - that.list.hide(); //hide acl-list if + else if (that.allow_gid.length === 0 && that.allow_cid.length === 1 && that.allow_cid[0] === that.self[0] && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value !== 'limited') { + that.list.hide(); //hide acl-list that.info.hide(); //show acl-info that.update_select('onlyme'); diff --git a/view/tpl/acl_selector.tpl b/view/tpl/acl_selector.tpl index 60fae0a29..ddeb25a39 100755 --- a/view/tpl/acl_selector.tpl +++ b/view/tpl/acl_selector.tpl @@ -1,3 +1,4 @@ +<form> <div class="modal" id="aclModal"> <div class="modal-dialog"> <div class="modal-content"> @@ -59,14 +60,13 @@ </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal --> - +</form> <script> $('[data-toggle="popover"]').popover(); // Init the popover, if present if(typeof acl=="undefined"){ acl = new ACL( - baseurl+"/acl", - [ {{$allowcid}},{{$allowgid}},{{$denycid}},{{$denygid}} ] + baseurl+"/acl" ); } </script> diff --git a/view/tpl/attach_edit.tpl b/view/tpl/attach_edit.tpl index 965fb4819..1098049bf 100644 --- a/view/tpl/attach_edit.tpl +++ b/view/tpl/attach_edit.tpl @@ -1,4 +1,4 @@ -<form action="filestorage/{{$channelnick}}/{{$file.id}}/edit" method="post" > +<form id="attach_edit_form_{{$file.id}}" action="filestorage/{{$channelnick}}/{{$file.id}}/edit" method="post" > <input type="hidden" name="channelnick" value="{{$channelnick}}" /> <input type="hidden" name="filehash" value="{{$file.hash}}" /> <input type="hidden" name="uid" value="{{$uid}}" /> @@ -16,15 +16,13 @@ </button> </div> <div id="attach-edit-perms" class="btn-group pull-right"> - <button id="dbtn-acl" class="btn btn-default btn-xs" data-toggle="modal" data-target="#aclModal" title="{{$permset}}" onclick="return false;"> + <button id="dbtn-acl" class="acl-select btn btn-default btn-xs" data-toggle="modal" data-target="#aclModal" title="{{$permset}}" onclick="return false;" data-formid="attach_edit_form_{{$file.id}}" data-allow_cid="{{$allow_cid}}" data-allow_gid="{{$allow_gid}}" data-deny_cid="{{$deny_cid}}" data-deny_gid="{{$deny_gid}}"> <i id="jot-perms-icon" class="fa fa-{{$lockstate}} jot-icons"></i> </button> - <button id="dbtn-submit" class="btn btn-primary btn-xs" type="submit" name="submit"> + <button id="dbtn-submit" class="acl-submit btn btn-primary btn-xs" type="submit" name="submit" data-formid="attach_edit_form_{{$file.id}}"> {{$submit}} </button> </div> - {{$aclselect}} - <div id="link-code" class="form-group"> <label for="">{{$cpldesc}}</label> <input type="text" class="form-control" id="linkpasteinput" name="cutpasteextlink" value="{{$cloudpath}}" onclick="this.select();"/> diff --git a/view/tpl/chatroom_new.tpl b/view/tpl/chatroom_new.tpl index a40313934..94f694e41 100644 --- a/view/tpl/chatroom_new.tpl +++ b/view/tpl/chatroom_new.tpl @@ -1,12 +1,12 @@ <div id="chatroom-new" class="section-content-tools-wrapper"> - <form action="chat" method="post" > + <form id="chatroom-new-form" action="chat" method="post" > {{include file="field_input.tpl" field=$name}} {{include file="field_input.tpl" field=$chat_expire}} - {{$acl}} <div class="btn-group pull-right"> <button id="dbtn-acl" class="btn btn-default" data-toggle="modal" data-target="#aclModal" title="{{$permissions}}" onclick="return false;" ><i id="jot-perms-icon" class="fa fa-{{$lockstate}}"></i></button> - <button id="dbtn-submit" class="btn btn-primary" type="submit" name="submit" value="{{$submit}}">{{$submit}}</button> + <button id="dbtn-submit" class="acl-submit btn btn-primary" type="submit" name="submit" value="{{$submit}}" data-formid="chatroom-new-form">{{$submit}}</button> </div> <div class="clear"></div> </form> </div> +{{$acl}} diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl index eaa613dc4..2c07f5ea7 100644 --- a/view/tpl/cloud_actionspanel.tpl +++ b/view/tpl/cloud_actionspanel.tpl @@ -18,3 +18,4 @@ </form> <div class="clear"></div> </div> +{{$aclselect}} diff --git a/view/tpl/event_form.tpl b/view/tpl/event_form.tpl index fbeec9aa3..a2bb1f112 100755 --- a/view/tpl/event_form.tpl +++ b/view/tpl/event_form.tpl @@ -1,4 +1,4 @@ -<form id="event-edit-form" action="{{$post}}" method="post" > +<form id="event-edit-form" action="{{$post}}" method="post" class="acl-form" data-form_id="event-edit-form" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'> <input type="hidden" name="event_id" value="{{$eid}}" /> <input type="hidden" name="event_hash" value="{{$event_hash}}" /> @@ -107,7 +107,6 @@ {{if ! $eid}} {{include file="field_checkbox.tpl" field=$share}} - {{$acl}} {{/if}} <div class="clear"></div> @@ -116,8 +115,12 @@ <div class="btn-group pull-right"> <button id="event-edit-preview-btn" class="btn btn-default" type="button" title="{{$preview}}" onclick="doEventPreview();"><i class="fa fa-eye" ></i></button> {{if ! $eid}} - <button id="dbtn-acl" class="btn btn-default" type="button" data-toggle="modal" data-target="#aclModal" title="{{$permissions}}"><i id="jot-perms-icon" class="fa"></i></button> + <button id="dbtn-acl" class="btn btn-default" type="button" data-toggle="modal" data-target="#aclModal" title="{{$perms_label}}"><i id="jot-perms-icon" class="fa"></i></button> {{/if}} <button id="event-submit" class="btn btn-primary" type="submit" name="submit">{{$submit}}</button> </div> </form> + +{{if ! $eid}} + {{$acl}} +{{/if}} diff --git a/view/tpl/jot.tpl b/view/tpl/jot.tpl index 490349a04..661954623 100755 --- a/view/tpl/jot.tpl +++ b/view/tpl/jot.tpl @@ -1,4 +1,4 @@ -<form id="profile-jot-form" action="{{$action}}" method="post"> +<form id="profile-jot-form" action="{{$action}}" method="post" class="acl-form" data-form_id="profile-jot-form" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'> {{$mimeselect}} {{$layoutselect}} {{if $id_select}} @@ -23,7 +23,6 @@ <input type="hidden" name="webpage" value="{{$webpage}}" /> <input type="hidden" name="preview" id="jot-preview" value="0" /> <input type="hidden" id="jot-consensus" name="consensus" value="{{if $consensus}}{{$consensus}}{{else}}0{{/if}}" /> - {{if $showacl}}{{$acl}}{{/if}} {{if $webpage}} <div id="jot-pagetitle-wrap" class="jothidden"> @@ -166,11 +165,11 @@ </button> {{/if}} {{if $showacl}} - <button id="dbtn-acl" class="btn btn-default btn-sm" data-toggle="modal" data-target="#aclModal" title="{{$permset}}" onclick="return false;"> + <button id="dbtn-acl" class="acl-select btn btn-default btn-sm" data-toggle="modal" data-target="#aclModal" title="{{$permset}}" type="button"> <i id="jot-perms-icon" class="fa fa-{{$lockstate}} jot-icons"></i>{{if $bang}} <i class="fa fa-exclamation jot-icons"></i>{{/if}} </button> {{/if}} - <button id="dbtn-submit" class="btn btn-primary btn-sm" type="submit" tabindex=3 name="button-submit" >{{$share}}</button> + <button id="dbtn-submit" class="acl-submit btn btn-primary btn-sm" type="submit" tabindex=3 name="button-submit">{{$share}}</button> </div> <div id="profile-jot-perms-end"></div> <div id="profile-jot-plugin-wrapper"> @@ -184,6 +183,8 @@ <div id="jot-preview-content" style="display:none;"></div> +{{if $showacl}}{{$acl}}{{/if}} + {{if $feature_expire}} <!-- Modal for item expiry--> <div class="modal" id="expiryModal" tabindex="-1" role="dialog" aria-labelledby="expiryModalLabel" aria-hidden="true"> |