diff options
author | zotlabs <mike@macgirvin.com> | 2017-11-08 19:21:20 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-11-08 19:21:20 -0800 |
commit | 75471ba10ff0c9ca3dfdc943c6647fc6ab1332f8 (patch) | |
tree | cf4cc209bec0eb22bafacaa75cdf613a76f42b72 | |
parent | 5e47b767ea6ed92f6f7ea0a3368762827937a5d8 (diff) | |
parent | e7d20efb1b8d579bcb9bdef99205aad19281f6b2 (diff) | |
download | volse-hubzilla-75471ba10ff0c9ca3dfdc943c6647fc6ab1332f8.tar.gz volse-hubzilla-75471ba10ff0c9ca3dfdc943c6647fc6ab1332f8.tar.bz2 volse-hubzilla-75471ba10ff0c9ca3dfdc943c6647fc6ab1332f8.zip |
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
-rwxr-xr-x | .gitignore | 3 | ||||
-rw-r--r-- | Zotlabs/Module/Cal.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Defperms.php | 267 | ||||
-rw-r--r-- | Zotlabs/Widget/Settings_menu.php | 2 | ||||
-rw-r--r-- | include/nav.php | 18 | ||||
-rw-r--r-- | view/css/bootstrap-red.css | 2 | ||||
-rw-r--r-- | view/js/main.js | 14 | ||||
-rw-r--r-- | view/js/mod_defperms.js | 32 | ||||
-rw-r--r-- | view/pdl/mod_defperms.pdl | 6 | ||||
-rw-r--r-- | view/theme/redbasic/css/style.css | 31 | ||||
-rwxr-xr-x | view/tpl/defperms.tpl | 55 | ||||
-rwxr-xr-x | view/tpl/navbar_default.tpl | 15 |
12 files changed, 426 insertions, 21 deletions
diff --git a/.gitignore b/.gitignore index 0e5233eaf..b001b6b27 100755 --- a/.gitignore +++ b/.gitignore @@ -19,10 +19,11 @@ Thumbs.db -## Ignore RedMatrix site specific files and folders +## Ignore site specific files and folders .htconfig.php favicon.* addon/ +widget/ custom/ /store/ # site apps diff --git a/Zotlabs/Module/Cal.php b/Zotlabs/Module/Cal.php index 41676ce02..c8403e979 100644 --- a/Zotlabs/Module/Cal.php +++ b/Zotlabs/Module/Cal.php @@ -69,6 +69,8 @@ class Cal extends \Zotlabs\Web\Controller { notice( t('Permissions denied.') . EOL); return; } + + nav_set_selected('Calendar'); $sql_extra = permissions_sql($channel['channel_id'],get_observer_hash(),'event'); diff --git a/Zotlabs/Module/Defperms.php b/Zotlabs/Module/Defperms.php new file mode 100644 index 000000000..9214331e4 --- /dev/null +++ b/Zotlabs/Module/Defperms.php @@ -0,0 +1,267 @@ +<?php +namespace Zotlabs\Module; + + +require_once('include/socgraph.php'); +require_once('include/selectors.php'); +require_once('include/group.php'); +require_once('include/photos.php'); + + +class Defperms extends \Zotlabs\Web\Controller { + + /* @brief Initialize the connection-editor + * + * + */ + + function init() { + + if(! local_channel()) + return; + + $r = q("SELECT abook.*, xchan.* + FROM abook left join xchan on abook_xchan = xchan_hash + WHERE abook_self = 1 and abook_id = %d LIMIT 1", + intval(local_channel()) + ); + if($r) { + \App::$poi = $r[0]; + } + + $channel = \App::get_channel(); + if($channel) + head_set_icon($channel['xchan_photo_s']); + } + + + /* @brief Evaluate posted values and set changes + * + */ + + function post() { + + if(! local_channel()) + return; + + $contact_id = intval(argv(1)); + if(! $contact_id) + return; + + $channel = \App::get_channel(); + + $orig_record = q("SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1", + intval($contact_id), + intval(local_channel()) + ); + + if(! $orig_record) { + notice( t('Could not access contact record.') . EOL); + goaway(z_root() . '/connections'); + return; // NOTREACHED + } + + + if(intval($orig_record[0]['abook_self'])) { + $autoperms = intval($_POST['autoperms']); + $is_self = true; + } + else { + $autoperms = null; + $is_self = false; + } + + + $all_perms = \Zotlabs\Access\Permissions::Perms(); + + if($all_perms) { + foreach($all_perms as $perm => $desc) { + + $checkinherited = \Zotlabs\Access\PermissionLimits::Get(local_channel(),$perm); + $inherited = (($checkinherited & PERMS_SPECIFIC) ? false : true); + + if(array_key_exists('perms_' . $perm, $_POST)) { + set_abconfig($channel['channel_id'],$orig_record[0]['abook_xchan'],'my_perms',$perm, + intval($_POST['perms_' . $perm])); + if($autoperms) { + set_pconfig($channel['channel_id'],'autoperms',$perm,intval($_POST['perms_' . $perm])); + } + } + else { + set_abconfig($channel['channel_id'],$orig_record[0]['abook_xchan'],'my_perms',$perm,0); + if($autoperms) { + set_pconfig($channel['channel_id'],'autoperms',$perm,0); + } + } + } + } + + if(! is_null($autoperms)) + set_pconfig($channel['channel_id'],'system','autoperms',$autoperms); + + + notice( t('Settings updated.') . EOL); + + + // Refresh the structure in memory with the new data + + $r = q("SELECT abook.*, xchan.* + FROM abook left join xchan on abook_xchan = xchan_hash + WHERE abook_channel = %d and abook_id = %d LIMIT 1", + intval(local_channel()), + intval($contact_id) + ); + if($r) { + \App::$poi = $r[0]; + } + + + $this->defperms_clone($a); + + goaway(z_root() . '/defperms'); + + return; + + } + + /* @brief Clone connection + * + * + */ + + function defperms_clone(&$a) { + + if(! \App::$poi) + return; + + $channel = \App::get_channel(); + + $r = q("SELECT abook.*, xchan.* + FROM abook left join xchan on abook_xchan = xchan_hash + WHERE abook_channel = %d and abook_id = %d LIMIT 1", + intval(local_channel()), + intval(\App::$poi['abook_id']) + ); + if($r) { + \App::$poi = array_shift($r); + } + + $clone = \App::$poi; + + unset($clone['abook_id']); + unset($clone['abook_account']); + unset($clone['abook_channel']); + + $abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']); + if($abconfig) + $clone['abconfig'] = $abconfig; + + build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone))); + } + + /* @brief Generate content of connection default permissions page + * + * + */ + + function get() { + + $sort_type = 0; + $o = ''; + + if(! local_channel()) { + notice( t('Permission denied.') . EOL); + return login(); + } + + $section = ((array_key_exists('section',$_REQUEST)) ? $_REQUEST['section'] : ''); + $channel = \App::get_channel(); + + $yes_no = array(t('No'),t('Yes')); + + $connect_perms = \Zotlabs\Access\Permissions::connect_perms(local_channel()); + + $o .= "<script>function connectDefaultShare() { + \$('.abook-edit-me').each(function() { + if(! $(this).is(':disabled')) + $(this).prop('checked', false); + });\n\n"; + foreach($connect_perms['perms'] as $p => $v) { + if($v) { + $o .= "\$('#me_id_perms_" . $p . "').prop('checked', true); \n"; + } + } + $o .= " }\n</script>\n"; + + if(\App::$poi) { + + $sections = []; + + $self = false; + + $tpl = get_markup_template('defperms.tpl'); + + + $perms = array(); + $channel = \App::get_channel(); + + $contact = \App::$poi; + + $global_perms = \Zotlabs\Access\Permissions::Perms(); + + $existing = get_all_perms(local_channel(),$contact['abook_xchan']); + $hidden_perms = []; + + foreach($global_perms as $k => $v) { + $thisperm = get_abconfig(local_channel(),$contact['abook_xchan'],'my_perms',$k); + + $checkinherited = \Zotlabs\Access\PermissionLimits::Get(local_channel(),$k); + + $inherited = (($checkinherited & PERMS_SPECIFIC) ? false : true); + + $perms[] = [ 'perms_' . $k, $v, intval($thisperm), '', $yes_no, (($inherited) ? ' disabled="disabled" ' : '') ]; + if($inherited) { + $hidden_perms[] = [ 'perms_' . $k, intval($thisperm) ]; + } + } + + $pcat = new \Zotlabs\Lib\Permcat(local_channel()); + $pcatlist = $pcat->listing(); + $permcats = []; + if($pcatlist) { + foreach($pcatlist as $pc) { + $permcats[$pc['name']] = $pc['localname']; + } + } + + $o .= replace_macros($tpl, [ + '$header' => t('Connection Default Permissions'), + '$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), t('If enabled, connection requests will be approved without your interaction'), $yes_no), + '$permcat' => [ 'permcat', t('Permission role'), '', '',$permcats ], + '$permcat_new' => t('Add permission role'), + '$permcat_enable' => feature_enabled(local_channel(),'permcats'), + '$section' => $section, + '$sections' => $sections, + '$autolbl' => t('The permissions indicated on this page will be applied to all new connections.'), + '$autoapprove' => t('Automatic approval settings'), + '$unapproved' => $unapproved, + '$inherited' => t('inherited'), + '$submit' => t('Submit'), + '$me' => t('My Settings'), + '$perms' => $perms, + '$hidden_perms' => $hidden_perms, + '$permlbl' => t('Individual Permissions'), + '$permnote_self' => t('Some individual permissions may have been preset or locked based on your channel type and privacy settings.'), + '$contact_id' => $contact['abook_id'], + '$name' => $contact['xchan_name'], + ]); + + $arr = array('contact' => $contact,'output' => $o); + + call_hooks('contact_edit', $arr); + + return $arr['output']; + + } + } +} diff --git a/Zotlabs/Widget/Settings_menu.php b/Zotlabs/Widget/Settings_menu.php index c15ad0980..e15ed96a5 100644 --- a/Zotlabs/Widget/Settings_menu.php +++ b/Zotlabs/Widget/Settings_menu.php @@ -107,7 +107,7 @@ class Settings_menu { if($role === false || $role === 'custom') { $tabs[] = array( 'label' => t('Connection Default Permissions'), - 'url' => z_root() . '/connedit/' . $abook_self_id, + 'url' => z_root() . '/defperms', 'selected' => '' ); } diff --git a/include/nav.php b/include/nav.php index af0ebbae2..9df50c9fe 100644 --- a/include/nav.php +++ b/include/nav.php @@ -27,6 +27,8 @@ function nav($template = 'default') { </script> EOT; + $is_owner = (((local_channel()) && ((App::$profile_uid == local_channel()) || (App::$profile_uid == 0))) ? true : false); + if(local_channel()) { $channel = App::get_channel(); $observer = App::get_observer(); @@ -39,17 +41,17 @@ EOT; intval(get_account_id()) ); } + $sitelocation = (($is_owner) ? '' : App::$profile['reddress']); } - elseif(remote_channel()) + elseif(remote_channel()) { $observer = App::get_observer(); + $sitelocation = ((App::$profile['reddress']) ? App::$profile['reddress'] : '@' . App::get_hostname()); + } require_once('include/conversation.php'); - $is_owner = (((local_channel()) && ((App::$profile_uid == local_channel()) || (App::$profile_uid == 0))) ? true : false); + $channel_apps[] = channel_apps($is_owner, App::$profile['channel_address']); - $myident = (($channel) ? $channel['xchan_addr'] : ''); - - $sitelocation = (($myident) ? $myident : App::get_hostname()); /** * @@ -438,10 +440,10 @@ function channel_apps($is_owner = false, $nickname = null) { if($p['view_stream'] && $cal_link) { $tabs[] = [ - 'label' => t('Events'), + 'label' => t('Calendar'), 'url' => z_root() . $cal_link, - 'sel' => ((argv(0) == 'cal' || argv(0) == 'events') ? 'active' : ''), - 'title' => t('Events'), + 'sel' => ((argv(0) == 'cal') ? 'active' : ''), + 'title' => t('Calendar'), 'id' => 'event-tab', 'icon' => 'calendar' ]; diff --git a/view/css/bootstrap-red.css b/view/css/bootstrap-red.css index 2dfc9e07b..18efd69e4 100644 --- a/view/css/bootstrap-red.css +++ b/view/css/bootstrap-red.css @@ -19,7 +19,6 @@ nav .dropdown-menu { } } - @media screen and (max-width: 767px) { .navbar { padding: .5rem 7px; @@ -41,6 +40,7 @@ nav .dropdown-menu { .navbar-toggler-right { padding: 0.2rem 0; + white-space: nowrap; } #navbar-collapse-1 i { diff --git a/view/js/main.js b/view/js/main.js index 882f50e8a..c3873d823 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -32,7 +32,12 @@ function handle_comment_form(e) { var fields_empty = true; if(form.find('.comment-edit-text').length) { - form.find('.comment-edit-text').addClass('expanded').removeAttr('placeholder'); + var commentElm = form.find('.comment-edit-text').attr('id'); + var submitElm = commentElm.replace(/text/,'submit'); + + $('#' + commentElm).addClass('expanded').removeAttr('placeholder'); + $('#' + commentElm).attr('tabindex','9'); + $('#' + submitElm).attr('tabindex','10'); form.find(':not(:visible)').show(); } @@ -43,7 +48,12 @@ function handle_comment_form(e) { fields_empty = false; }); if(fields_empty) { - form.find('.comment-edit-text').removeClass('expanded').attr('placeholder', aStr.comment); + var emptyCommentElm = form.find('.comment-edit-text').attr('id'); + var emptySubmitElm = commentElm.replace(/text/,'submit'); + + $('#' + emptyCommentElm).removeClass('expanded').attr('placeholder', aStr.comment); + $('#' + emptyCommentElm).removeAttr('tabindex'); + $('#' + emptySubmitElm).removeAttr('tabindex'); form.find(':not(.comment-edit-text)').hide(); } }); diff --git a/view/js/mod_defperms.js b/view/js/mod_defperms.js new file mode 100644 index 000000000..c89142579 --- /dev/null +++ b/view/js/mod_defperms.js @@ -0,0 +1,32 @@ +$(document).ready(function() { + + $('#id_permcat').change(function() { + $('.loading-role-rotator').show(); + var permName = $('#id_permcat').val(); + loadConnectionRole(permName); + }); + + +}); + + +function loadConnectionRole(name) { + + if(! name) + name = 'default'; + + $('.defperms-edit input').each(function() { + if(! $(this).is(':disabled')) + $(this).removeAttr('checked'); + }); + + $.get('permcat/' + name, function(data) { + $(data.perms).each(function() { + if(this.value) + $('#id_perms_' + this.name).attr('checked','checked'); + }); + $('.loading-role-rotator').hide(); + }); +} + + diff --git a/view/pdl/mod_defperms.pdl b/view/pdl/mod_defperms.pdl new file mode 100644 index 000000000..53a3ac9e5 --- /dev/null +++ b/view/pdl/mod_defperms.pdl @@ -0,0 +1,6 @@ +[region=aside] +[widget=settings_menu][/widget] +[/region] +[region=right_aside] +[widget=notifications][/widget] +[/region] diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 9f9ece7c3..6df5a060b 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -161,10 +161,6 @@ nav { filter:alpha(opacity=$nav_percent_min_opacity); } -#nav-app-link { - white-space: nowrap; -} - #powered-by { font-size: 0.5rem; position: absolute; @@ -977,6 +973,11 @@ a .drop-icons:hover { color: #FF0000; } +.perm-inherited { + color: #FF0000; +} + + #menulist { list-style-type: none; } @@ -1255,6 +1256,12 @@ img.mail-conv-sender-photo { border-radius: $radius; } +#nav-app-link { + padding: 0 !important; + line-height: 1.175; + white-space: nowrap; +} + .page-title { margin: 7px 0px; } @@ -1492,6 +1499,11 @@ blockquote { left: 0px; } + #nav-app-link-wrapper { + min-width: 0; + flex-basis: 25%; + } + } .shareable_element_text { @@ -1639,6 +1651,17 @@ dl.bb-dl > dd > li { background-color: #0275d8; } + +.form-group.checkbox > div > input:disabled + label .onoffswitch-switch { + background-color: red; + border-radius: 3px; + opacity: 0.3; + filter:alpha(opacity=30); + +} + + + .help-searchlist { list-style-type: none; } diff --git a/view/tpl/defperms.tpl b/view/tpl/defperms.tpl new file mode 100755 index 000000000..f4a711957 --- /dev/null +++ b/view/tpl/defperms.tpl @@ -0,0 +1,55 @@ +<div class="generic-content-wrapper"> + <div class="section-title-wrapper"> + <h2>{{$header}}</h2> + </div> + <div class="section-content-wrapper-np"> + <form id="abook-edit-form" action="defperms/{{$contact_id}}" method="post" > + + <input type="hidden" name="contact_id" value="{{$contact_id}}"> + <input type="hidden" name="section" value="{{$section}}"> + + <div class="panel-group" id="contact-edit-tools" role="tablist" aria-multiselectable="true"> + <div class="panel"> + <div id="perms-tool-collapse" class="panel-collapse collapse show" role="tabpanel" aria-labelledby="perms-tool"> + <div class="section-content-tools-wrapper"> + <div class="section-content-warning-wrapper"> + <p>{{$autolbl}}</p> + <p>{{$permnote_self}}</p> + </div> + {{if $permcat_enable}} + <div class="loading-role-rotator spinner-wrapper"></div> + <a href="settings/permcats" class="pull-right"><i class="fa fa-plus"></i> {{$permcat_new}}</a> + {{include file="field_select.tpl" field=$permcat}} + {{/if}} + + <div class="defperms-edit"> + {{foreach $perms as $prm}} + {{include file="field_checkbox.tpl" field=$prm}} + {{/foreach}} + </div> + + {{if $hidden_perms}} + {{foreach $hidden_perms as $prm}} + <input type="hidden" name="{{$prm.0}}" value="{{$prm.1}}" > + {{/foreach}} + {{/if}} + + + + <div> + <div class="section-content-info-wrapper"> + {{$autoapprove}} + </div> + {{include file="field_checkbox.tpl" field=$autoperms}} + </div> + + <div class="settings-submit-wrapper" > + <button type="submit" name="done" value="{{$submit}}" class="btn btn-primary">{{$submit}}</button> + </div> + </div> + </div> + </div> + </div> + </form> + </div> +</div> diff --git a/view/tpl/navbar_default.tpl b/view/tpl/navbar_default.tpl index b330993c8..426d32047 100755 --- a/view/tpl/navbar_default.tpl +++ b/view/tpl/navbar_default.tpl @@ -17,8 +17,8 @@ </div> {{/if}} {{if $userinfo}} -<div class="dropdown usermenu"> - <div class="fakelink" data-toggle="dropdown"> +<div class="dropdown"> + <div class="fakelink usermenu" data-toggle="dropdown"> <img id="avatar" src="{{$userinfo.icon}}" alt="{{$userinfo.name}}"> <i class="fa fa-caret-down"></i> </div> @@ -59,10 +59,17 @@ </div> {{/if}} </div> -<div class="navbar-nav mr-auto"> - <div><a id="nav-app-link" href="{{$url}}" class="nav-link">{{$sel.name}}</a></div> +{{if $sel.name}} +<div id="nav-app-link-wrapper" class="navbar-nav mr-auto"> + <a id="nav-app-link" href="{{$url}}" class="nav-link text-truncate"> + {{$sel.name}} + {{if $sitelocation}} + <br><small class="text-muted">{{$sitelocation}}</small> + {{/if}} + </a> </div> {{/if}} +{{/if}} <div class="navbar-toggler-right"> {{if $nav.help.6}} <button id="context-help-btn" class="navbar-toggler border-0" type="button" onclick="contextualHelp(); return false;"> |