From a844fd8f58fbdc5ef95c8db4688fd035ba0c28c5 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 3 Sep 2020 09:58:07 -0400 Subject: [PATCH 1/3] Move ACL full selector template to subfolder - Fix display overflow in contact complete suggestion box --- src/Core/ACL.php | 2 +- view/templates/{acl_selector.tpl => acl/full_selector.tpl} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename view/templates/{acl_selector.tpl => acl/full_selector.tpl} (98%) diff --git a/src/Core/ACL.php b/src/Core/ACL.php index f35889061..504e5d847 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -303,7 +303,7 @@ class ACL 'emailcc' => $form_prefix ? $form_prefix . '[emailcc]' : 'emailcc', ]; - $tpl = Renderer::getMarkupTemplate('acl_selector.tpl'); + $tpl = Renderer::getMarkupTemplate('acl/full_selector.tpl'); $o = Renderer::replaceMacros($tpl, [ '$public_title' => DI::l10n()->t('Public'), '$public_desc' => DI::l10n()->t('This content will be shown to all your followers and can be seen in the community pages and by anyone with its link.'), diff --git a/view/templates/acl_selector.tpl b/view/templates/acl/full_selector.tpl similarity index 98% rename from view/templates/acl_selector.tpl rename to view/templates/acl/full_selector.tpl index f1943cf3f..ada05fbd4 100644 --- a/view/templates/acl_selector.tpl +++ b/view/templates/acl/full_selector.tpl @@ -155,7 +155,7 @@ acl.initialize(); let suggestionTemplate = function (item) { - return '
' + item.name + '
' + item.addr + '
'; + return '

' + item.name + '
' + item.addr + '

'; }; $acl_allow_input.tagsinput({ From 4a4d0f04cb91e443895a6367345352017f84621c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 3 Sep 2020 10:01:58 -0400 Subject: [PATCH 2/3] Fix new private message recipient input - Add new private message recipient ACL template - Remove now redundant theme private message templates --- mod/message.php | 45 +--------- src/Core/ACL.php | 83 +++++++------------ view/templates/acl/message_recipient.tpl | 54 ++++++++++++ view/templates/message-head.tpl | 8 -- view/theme/duepuntozero/style.css | 3 - .../duepuntozero/templates/prv_message.tpl | 40 --------- view/theme/frio/templates/prv_message.tpl | 11 +-- view/theme/quattro/templates/prv_message.tpl | 37 --------- 8 files changed, 89 insertions(+), 192 deletions(-) create mode 100644 view/templates/acl/message_recipient.tpl delete mode 100644 view/theme/duepuntozero/templates/prv_message.tpl delete mode 100644 view/theme/quattro/templates/prv_message.tpl diff --git a/mod/message.php b/mod/message.php index f04bdaecd..6326bb9ea 100644 --- a/mod/message.php +++ b/mod/message.php @@ -74,7 +74,7 @@ function message_post(App $a) $replyto = !empty($_REQUEST['replyto']) ? Strings::escapeTags(trim($_REQUEST['replyto'])) : ''; $subject = !empty($_REQUEST['subject']) ? Strings::escapeTags(trim($_REQUEST['subject'])) : ''; $body = !empty($_REQUEST['body']) ? Strings::escapeHtml(trim($_REQUEST['body'])) : ''; - $recipient = !empty($_REQUEST['messageto']) ? intval($_REQUEST['messageto']) : 0; + $recipient = !empty($_REQUEST['recipient']) ? intval($_REQUEST['recipient']) : 0; $ret = Mail::send($recipient, $body, $subject, $replyto); $norecip = false; @@ -215,50 +215,14 @@ function message_content(App $a) '$linkurl' => DI::l10n()->t('Please enter a link URL:') ]); - $preselect = isset($a->argv[2]) ? [$a->argv[2]] : []; + $recipientId = $a->argv[2] ?? null; - $prename = $preurl = $preid = ''; - - if ($preselect) { - $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1", - intval(local_user()), - intval($a->argv[2]) - ); - if (!DBA::isResult($r)) { - $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1", - intval(local_user()), - DBA::escape(Strings::normaliseLink(base64_decode($a->argv[2]))) - ); - } - - if (!DBA::isResult($r)) { - $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `addr` = '%s' LIMIT 1", - intval(local_user()), - DBA::escape(base64_decode($a->argv[2])) - ); - } - - if (DBA::isResult($r)) { - $prename = $r[0]['name']; - $preid = $r[0]['id']; - $preselect = [$preid]; - } else { - $preselect = []; - } - } - - $prefill = $preselect ? $prename : ''; - - // the ugly select box - $select = ACL::getMessageContactSelectHTML('messageto', 'message-to-select', $preselect, 4, 10); + $select = ACL::getMessageContactSelectHTML($recipientId); $tpl = Renderer::getMarkupTemplate('prv_message.tpl'); $o .= Renderer::replaceMacros($tpl, [ '$header' => DI::l10n()->t('Send Private Message'), '$to' => DI::l10n()->t('To:'), - '$showinputs' => 'true', - '$prefill' => $prefill, - '$preid' => $preid, '$subject' => DI::l10n()->t('Subject:'), '$subjtxt' => $_REQUEST['subject'] ?? '', '$text' => $_REQUEST['body'] ?? '', @@ -413,7 +377,7 @@ function message_content(App $a) $seen = $message['seen']; } - $select = $message['name'] . ''; + $select = $message['name'] . ''; $parent = ''; $tpl = Renderer::getMarkupTemplate('mail_display.tpl'); @@ -429,7 +393,6 @@ function message_content(App $a) // reply '$header' => DI::l10n()->t('Send Reply'), '$to' => DI::l10n()->t('To:'), - '$showinputs' => '', '$subject' => DI::l10n()->t('Subject:'), '$subjtxt' => $message['title'], '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ', diff --git a/src/Core/ACL.php b/src/Core/ACL.php index 504e5d847..4df15dc53 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -33,75 +33,52 @@ use Friendica\Model\Group; class ACL { /** - * Returns a select input tag with all the contact of the local user + * Returns a select input tag for private message recipient * - * @param string $selname Name attribute of the select input tag - * @param string $selclass Class attribute of the select input tag - * @param array $preselected Contact IDs that should be already selected - * @param int $size Length of the select box - * @param int $tabindex Select input tag tabindex attribute + * @param int $selected Existing recipien contact ID * @return string * @throws \Exception */ - public static function getMessageContactSelectHTML($selname, $selclass, array $preselected = [], $size = 4, $tabindex = null) + public static function getMessageContactSelectHTML(int $selected = null) { - $a = DI::app(); - $o = ''; + $page = DI::page(); + + $page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js')); + $page->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css')); + // When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector // to one recipient. By default our selector allows multiple selects amongst all contacts. - $sql_extra = sprintf(" AND `rel` = %d ", intval(Contact::FRIEND)); - $sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ", Protocol::DFRN, Protocol::DIASPORA); + $condition = [ + 'uid' => local_user(), + 'self' => false, + 'blocked' => false, + 'pending' => false, + 'archive' => false, + 'deleted' => false, + 'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND], + 'network' => Protocol::FEDERATED, + ]; - $tabindex_attr = !empty($tabindex) ? ' tabindex="' . intval($tabindex) . '"' : ''; - - $hidepreselected = ''; - if ($preselected) { - $sql_extra .= " AND `id` IN (" . implode(",", $preselected) . ")"; - $hidepreselected = ' style="display: none;"'; - } - - $o .= "' . PHP_EOL; - - if ($preselected) { - $o .= implode(', ', $receiverlist); - } - - Hook::callAll(DI::module()->getName() . '_post_' . $selname, $o); + Hook::callAll(DI::module()->getName() . '_post_recipient', $o); return $o; } diff --git a/view/templates/acl/message_recipient.tpl b/view/templates/acl/message_recipient.tpl new file mode 100644 index 000000000..07c22f449 --- /dev/null +++ b/view/templates/acl/message_recipient.tpl @@ -0,0 +1,54 @@ + + diff --git a/view/templates/message-head.tpl b/view/templates/message-head.tpl index fe71bc425..e69de29bb 100644 --- a/view/templates/message-head.tpl +++ b/view/templates/message-head.tpl @@ -1,8 +0,0 @@ - - diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 3c8a18c88..85669be9f 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -3228,9 +3228,6 @@ div.jGrowl div.info { width:100px; } -#recip { - -} .autocomplete-w1 { background: #ffffff no-repeat bottom right; position:absolute; top:0px; left:0px; margin:6px 0 0 6px; /* IE6 fix: */ _background:none; _margin:1px 0 0 0; } .autocomplete { color:#000; border:1px solid #999; background:#FFF; cursor:default; text-align:left; max-height:350px; overflow:auto; margin:-6px 6px 6px -6px; /* IE6 specific: */ _height:350px; _margin:0; _overflow-x:hidden; } .autocomplete .selected { background:#F0F0F0; } diff --git a/view/theme/duepuntozero/templates/prv_message.tpl b/view/theme/duepuntozero/templates/prv_message.tpl deleted file mode 100644 index 3f658ef81..000000000 --- a/view/theme/duepuntozero/templates/prv_message.tpl +++ /dev/null @@ -1,40 +0,0 @@ - - -

{{$header}}

- -
-
- -{{$parent nofilter}} - -
{{$to}}
- -{{if $showinputs}} - - -{{else}} -{{$select nofilter}} -{{/if}} - -
{{$subject}}
- - -
{{$yourmessage}}
- - - -
- -
-
-
- -
- -
-
-
-
-
diff --git a/view/theme/frio/templates/prv_message.tpl b/view/theme/frio/templates/prv_message.tpl index 68db2568a..f936741c0 100644 --- a/view/theme/frio/templates/prv_message.tpl +++ b/view/theme/frio/templates/prv_message.tpl @@ -2,21 +2,12 @@
- {{* Disable the header. We will see if we will need it -

{{$header}}

- *}} - {{$parent nofilter}} {{* The To: form-group which contains the message recipient *}}
-
- {{if $showinputs}} - - - {{else}} +
{{$select nofilter}} - {{/if}}
{{* The subject input field *}} diff --git a/view/theme/quattro/templates/prv_message.tpl b/view/theme/quattro/templates/prv_message.tpl deleted file mode 100644 index c956fbf72..000000000 --- a/view/theme/quattro/templates/prv_message.tpl +++ /dev/null @@ -1,37 +0,0 @@ -

{{$header}}

- -
- - -{{$parent nofilter}} - -
{{$to}}
-{{if $showinputs}} - - -{{else}} -{{$select nofilter}} -{{/if}} - -
{{$subject}}
- - -
{{$yourmessage}}
- - - -
- -
-
-
- -
- -
-
-
- -
From 9ea7f7d4ade110ece8dad6cd5f07e53330da0222 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 3 Sep 2020 10:03:36 -0400 Subject: [PATCH 3/3] [frio] Ensure tagsinput library is loaded in pages where new PM can be submitted - The new private message page loads in a modal, requiring the base page to load them in advance --- include/conversation.php | 8 ++++++++ src/Module/Contact.php | 10 +++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index c668e53d9..aa807619e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -28,6 +28,7 @@ use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Session; +use Friendica\Core\Theme; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -354,6 +355,13 @@ function conv_get_blocklist() */ function conversation(App $a, array $items, $mode, $update, $preview = false, $order = 'commented', $uid = 0) { + $page = DI::page(); + + $page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js')); + $page->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css')); + $ssl_state = (local_user() ? true : false); $profile_owner = 0; diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 4a5aeefe4..6e8778f17 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -32,6 +32,7 @@ use Friendica\Core\ACL; use Friendica\Core\Hook; use Friendica\Core\Protocol; use Friendica\Core\Renderer; +use Friendica\Core\Theme; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; @@ -259,9 +260,12 @@ class Contact extends BaseModule $rel = Strings::escapeTags(trim($_GET['rel'] ?? '')); $group = Strings::escapeTags(trim($_GET['group'] ?? '')); - if (empty(DI::page()['aside'])) { - DI::page()['aside'] = ''; - } + $page = DI::page(); + + $page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js')); + $page->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css')); $contact = null; // @TODO: Replace with parameter from router