From 898f7e7e38d2db61d82974e8f5199c16f1b8ce06 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 24 Mar 2019 22:40:50 -0400 Subject: [PATCH] Add connector collapsible panel in permission - Replace HTML string by structured array in jot_networks hook - Add collapsed panel when there are more than two connectors --- src/Core/ACL.php | 28 ++++++++++++---------- view/global.css | 4 ++++ view/templates/acl_selector.tpl | 27 ++++++++++++++++++--- view/theme/frio/templates/acl_selector.tpl | 26 +++++++++++++++++--- 4 files changed, 67 insertions(+), 18 deletions(-) diff --git a/src/Core/ACL.php b/src/Core/ACL.php index 19015714e..e6c82fd4b 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -266,14 +266,12 @@ class ACL extends BaseObject $default_permissions = self::getDefaultUserPermissions($user); } - $jotnets = ''; + $jotnets_fields = []; if ($show_jotnets) { - $imap_disabled = !function_exists('imap_open') || Config::get('system', 'imap_disabled'); - $mail_enabled = false; $pubmail_enabled = false; - if (!$imap_disabled) { + if (function_exists('imap_open') && !Config::get('system', 'imap_disabled')) { $mailacct = DBA::selectFirst('mailacct', ['pubmail'], ['`uid` = ? AND `server` != ""', local_user()]); if (DBA::isResult($mailacct)) { $mail_enabled = true; @@ -283,17 +281,20 @@ class ACL extends BaseObject if (empty($default_permissions['hidewall'])) { if ($mail_enabled) { - $selected = $pubmail_enabled ? ' checked="checked"' : ''; - $jotnets .= '
' . L10n::t("Post to Email") . '
'; + $jotnets_fields[] = [ + 'type' => 'checkbox', + 'field' => [ + 'pubmail_enable', + L10n::t('Post to Email'), + $pubmail_enabled + ] + ]; } - Hook::callAll('jot_networks', $jotnets); - } else { - $jotnets .= L10n::t('Connectors disabled, since "%s" is enabled.', - L10n::t('Hide your profile details from unknown viewers?')); + Hook::callAll('jot_networks', $jotnets_fields); } } - + $tpl = Renderer::getMarkupTemplate('acl_selector.tpl'); $o = Renderer::replaceMacros($tpl, [ '$showall' => L10n::t('Visible to everybody'), @@ -306,7 +307,10 @@ class ACL extends BaseObject '$networks' => $show_jotnets, '$emailcc' => L10n::t('CC: email addresses'), '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'), - '$jotnets' => $jotnets, + '$jotnets_enabled' => empty($default_permissions['hidewall']), + '$jotnets_summary' => L10n::t('Connectors'), + '$jotnets_fields' => $jotnets_fields, + '$jotnets_disabled_label' => L10n::t('Connectors disabled, since "%s" is enabled.', L10n::t('Hide your profile details from unknown viewers?')), '$aclModalTitle' => L10n::t('Permissions'), '$aclModalDismiss' => L10n::t('Close'), '$features' => [ diff --git a/view/global.css b/view/global.css index afab5d903..b48fa1a24 100644 --- a/view/global.css +++ b/view/global.css @@ -1,6 +1,10 @@ /* General style rules .*/ .pull-right { float: right } +details > summary { + cursor: pointer; +} + /* General designing elements */ .btn { outline: none; diff --git a/view/templates/acl_selector.tpl b/view/templates/acl_selector.tpl index 48706535f..6755f2a19 100644 --- a/view/templates/acl_selector.tpl +++ b/view/templates/acl_selector.tpl @@ -19,9 +19,30 @@
{{$emailcc}}
-{{if $jotnets}} -{{$jotnets nofilter}} -{{/if}}{{/if}} + + {{if $jotnets_fields}} + {{if $jotnets_fields|count < 3}} +
+ {{else}} +
+ {{$jotnets_summary}} + {{/if}} + + {{foreach $jotnets_fields as $jotnets_field}} + {{if $jotnets_field.type == 'checkbox'}} + {{include file="field_checkbox.tpl" field=$jotnets_field.field}} + {{elseif $jotnets_field.type == 'select'}} + {{include file="field_select.tpl" field=$jotnets_field.field}} + {{/if}} + {{/foreach}} + + {{if $jotnets_fields|count >= 3}} +
+ {{else}} +
+ {{/if}} + {{/if}} +{{/if}}