From e6da6668852b3a9d54b3f781a69e4aa536b24f2e Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Thu, 5 Dec 2019 20:19:25 +0100 Subject: [PATCH 01/13] Make Two Factor Field numeric --- src/Module/TwoFactor/Verify.php | 2 +- view/templates/field_input.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module/TwoFactor/Verify.php b/src/Module/TwoFactor/Verify.php index f6f040f5a..958585925 100644 --- a/src/Module/TwoFactor/Verify.php +++ b/src/Module/TwoFactor/Verify.php @@ -64,7 +64,7 @@ class Verify extends BaseModule '$errors_label' => L10n::tt('Error', 'Errors', count(self::$errors)), '$errors' => self::$errors, '$recovery_message' => L10n::t('Don’t have your phone? Enter a two-factor recovery code', '2fa/recovery'), - '$verify_code' => ['verify_code', L10n::t('Please enter a code from your authentication app'), '', '', 'required', 'autofocus placeholder="000000"'], + '$verify_code' => ['verify_code', L10n::t('Please enter a code from your authentication app'), '', '', 'required', 'autofocus placeholder="000000"', 'int'], '$verify_label' => L10n::t('Verify code and complete login'), ]); } diff --git a/view/templates/field_input.tpl b/view/templates/field_input.tpl index 399cf0c43..b0462e9f2 100644 --- a/view/templates/field_input.tpl +++ b/view/templates/field_input.tpl @@ -1,7 +1,7 @@
- + {{if $field.3}} {{$field.3 nofilter}} {{/if}} From da3e293e9157d51b126bb01e2193d80eb3a216e2 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Thu, 5 Dec 2019 20:47:21 +0100 Subject: [PATCH 02/13] Adding doc for new field-type --- doc/smarty3-templates.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/smarty3-templates.md b/doc/smarty3-templates.md index f174f2164..abb1ed563 100644 --- a/doc/smarty3-templates.md +++ b/doc/smarty3-templates.md @@ -89,7 +89,7 @@ Field parameter: 3. Help text for the input box, 4. if set to "required" modern browser will check that this input box is filled when submitting the form, 5. if set to "autofocus" modern browser will put the cursur into this box once the page is loaded, -6. if set to "email" or "url" modern browser will check that the filled in value corresponds to an email address or URL. +6. if set to "email", "url" or "int" modern browser will check that the filled in value corresponds to an email address, URL or numeric. ### field_intcheckbox.tpl From 47505aceec819575788556bb8b05146995b2f2a4 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Thu, 5 Dec 2019 21:13:49 +0100 Subject: [PATCH 03/13] double quoted field & use number --- view/templates/field_input.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/view/templates/field_input.tpl b/view/templates/field_input.tpl index b0462e9f2..4815302ae 100644 --- a/view/templates/field_input.tpl +++ b/view/templates/field_input.tpl @@ -1,8 +1,8 @@ -
- - +
+ + {{if $field.3}} - {{$field.3 nofilter}} + {{$field.3 nofilter}} {{/if}}
From c28f1fec519de3728fc8b9497cc6dac3f22f33c1 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Thu, 5 Dec 2019 21:42:33 +0100 Subject: [PATCH 04/13] General usage of type in input fields --- doc/smarty3-templates.md | 4 ++-- src/Module/TwoFactor/Verify.php | 2 +- view/templates/field_input.tpl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/smarty3-templates.md b/doc/smarty3-templates.md index abb1ed563..6e98d0865 100644 --- a/doc/smarty3-templates.md +++ b/doc/smarty3-templates.md @@ -80,7 +80,7 @@ Field parameter: ### field_input.tpl -A single line input field for textual input. +A single line input field for any type of input. Field parameter: 0. Name of the field, @@ -89,7 +89,7 @@ Field parameter: 3. Help text for the input box, 4. if set to "required" modern browser will check that this input box is filled when submitting the form, 5. if set to "autofocus" modern browser will put the cursur into this box once the page is loaded, -6. if set to "email", "url" or "int" modern browser will check that the filled in value corresponds to an email address, URL or numeric. +6. if set, it will be used for the input type, default is `text` (possible types: https://www.w3schools.com/html/html_form_input_types.asp). ### field_intcheckbox.tpl diff --git a/src/Module/TwoFactor/Verify.php b/src/Module/TwoFactor/Verify.php index 958585925..27001683e 100644 --- a/src/Module/TwoFactor/Verify.php +++ b/src/Module/TwoFactor/Verify.php @@ -64,7 +64,7 @@ class Verify extends BaseModule '$errors_label' => L10n::tt('Error', 'Errors', count(self::$errors)), '$errors' => self::$errors, '$recovery_message' => L10n::t('Don’t have your phone? Enter a two-factor recovery code', '2fa/recovery'), - '$verify_code' => ['verify_code', L10n::t('Please enter a code from your authentication app'), '', '', 'required', 'autofocus placeholder="000000"', 'int'], + '$verify_code' => ['verify_code', L10n::t('Please enter a code from your authentication app'), '', '', 'required', 'autofocus placeholder="000000"', 'number'], '$verify_label' => L10n::t('Verify code and complete login'), ]); } diff --git a/view/templates/field_input.tpl b/view/templates/field_input.tpl index 4815302ae..956c6259c 100644 --- a/view/templates/field_input.tpl +++ b/view/templates/field_input.tpl @@ -1,7 +1,7 @@
- + {{if $field.3}} {{$field.3 nofilter}} {{/if}} From 144d4d9cf563796278f6060ac4f7cb13a21ba4ae Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Thu, 5 Dec 2019 22:10:04 +0100 Subject: [PATCH 05/13] add non-leecher link --- doc/smarty3-templates.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/smarty3-templates.md b/doc/smarty3-templates.md index 6e98d0865..1fadcb221 100644 --- a/doc/smarty3-templates.md +++ b/doc/smarty3-templates.md @@ -89,7 +89,7 @@ Field parameter: 3. Help text for the input box, 4. if set to "required" modern browser will check that this input box is filled when submitting the form, 5. if set to "autofocus" modern browser will put the cursur into this box once the page is loaded, -6. if set, it will be used for the input type, default is `text` (possible types: https://www.w3schools.com/html/html_form_input_types.asp). +6. if set, it will be used for the input type, default is `text` (possible types: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#%3Cinput%3E_types). ### field_intcheckbox.tpl From 7056639b620385f98d9fb9b9a71a773b0e6af0e5 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Thu, 5 Dec 2019 22:56:00 +0100 Subject: [PATCH 06/13] Add numeric field_input to frio --- view/theme/frio/templates/field_input.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/theme/frio/templates/field_input.tpl b/view/theme/frio/templates/field_input.tpl index 838eaf6e5..d5b75119b 100644 --- a/view/theme/frio/templates/field_input.tpl +++ b/view/theme/frio/templates/field_input.tpl @@ -3,7 +3,7 @@ {{if !isset($label) || $label != false }} {{/if}} - + {{if $field.3}} {{$field.3 nofilter}} {{/if}} From 3d92989c15f78c4140a82ba332ecae7668a6d32b Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Thu, 5 Dec 2019 23:25:03 +0100 Subject: [PATCH 07/13] fix run_xgettext.sh FRIENDICA_VERSION --- bin/run_xgettext.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/run_xgettext.sh b/bin/run_xgettext.sh index 5c40df8b5..8318a8c93 100755 --- a/bin/run_xgettext.sh +++ b/bin/run_xgettext.sh @@ -50,7 +50,7 @@ case "$MODE" in # skip addon folder FINDOPTS="( -wholename */addon -or -wholename */addons -or -wholename */addons-extra -or -wholename */smarty3 ) -prune -o" - F9KVERSION=$(sed -n "s/.*'FRIENDICA_VERSION'.*'\([0-9.]*\)'.*/\1/p" ./boot.php); + F9KVERSION=$(cat ./VERSION); echo "Friendica version $F9KVERSION" ;; esac From 7cfe05f849812b744d893d73d1786f9025bcd6ff Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 5 Dec 2019 20:05:47 -0500 Subject: [PATCH 08/13] Restore correct test for hidewall in ACL::getFullSelectorHTML --- src/Core/ACL.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/ACL.php b/src/Core/ACL.php index e6dd1a8f3..044f61aeb 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -367,7 +367,7 @@ class ACL extends BaseObject } } - if ($default_permissions['hidewall']) { + if (!$default_permissions['hidewall']) { if ($mail_enabled) { $jotnets_fields[] = [ 'type' => 'checkbox', From b1fa0e8e268b5a49d548d0b2446f8998f878740f Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 6 Dec 2019 07:25:21 +0000 Subject: [PATCH 09/13] ACL: Contact list is now sorted, forums reappeared --- src/Core/ACL.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Core/ACL.php b/src/Core/ACL.php index 044f61aeb..83fae423a 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -258,10 +258,20 @@ class ACL extends BaseObject */ public static function getContactListByUserId(int $user_id) { - $acl_contacts = Contact::selectToArray( - ['id', 'name', 'addr', 'micro'], - ['uid' => $user_id, 'pending' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]] + $fields = ['id', 'name', 'addr', 'micro']; + $params = ['order' => ['name']]; + $acl_contacts = Contact::selectToArray($fields, + ['uid' => $user_id, 'self' => false, 'blocked' => false, 'archive' => false, 'deleted' => false, + 'pending' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]], $params ); + + $acl_forums = Contact::selectToArray($fields, + ['uid' => $user_id, 'self' => false, 'blocked' => false, 'archive' => false, 'deleted' => false, + 'pending' => false, 'contact-type' => Contact::TYPE_COMMUNITY], $params + ); + + $acl_contacts = array_merge($acl_forums, $acl_contacts); + array_walk($acl_contacts, function (&$value) { $value['type'] = 'contact'; }); From 74cc9d00fa4f8b831f325776b765590fccb7f801 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 7 Dec 2019 05:50:15 -0500 Subject: [PATCH 10/13] Allow contacts and groups with same ID in ACL selector --- view/templates/acl_selector.tpl | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/view/templates/acl_selector.tpl b/view/templates/acl_selector.tpl index 4da7862bb..a5929900b 100644 --- a/view/templates/acl_selector.tpl +++ b/view/templates/acl_selector.tpl @@ -130,19 +130,19 @@ // Custom visibility tags inputs let acl_groups = new Bloodhound({ local: {{$acl_groups|@json_encode nofilter}}, - identify: function(obj) { return obj.id; }, + identify: function(obj) { return obj.type + '-' + obj.id.toString(); }, datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name']), queryTokenizer: Bloodhound.tokenizers.whitespace, }); let acl_contacts = new Bloodhound({ local: {{$acl_contacts|@json_encode nofilter}}, - identify: function(obj) { return obj.id; }, + identify: function(obj) { return obj.type + '-' + obj.id.toString(); }, datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name', 'addr']), queryTokenizer: Bloodhound.tokenizers.whitespace, }); let acl = new Bloodhound({ local: {{$acl_list|@json_encode nofilter}}, - identify: function(obj) { return obj.id; }, + identify: function(obj) { return obj.type + '-' + obj.id.toString(); }, datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name', 'addr']), queryTokenizer: Bloodhound.tokenizers.whitespace, }); @@ -163,7 +163,7 @@ return 'label label-info'; } }, - itemValue: 'id', + itemValue: function (item) { return item.type + '-' + item.id.toString(); }, itemText: 'name', itemThumb: 'micro', itemTitle: function(item) { @@ -191,7 +191,7 @@ return 'label label-info'; } }, - itemValue: 'id', + itemValue: function (item) { return item.type + '-' + item.id.toString(); }, itemText: 'name', itemThumb: 'micro', itemTitle: function(item) { @@ -209,17 +209,17 @@ // Import existing ACL into the tags input fields. - $group_allow_input.val().split(',').forEach(function (val) { - $acl_allow_input.tagsinput('add', acl_groups.get(val)[0]); + $group_allow_input.val().split(',').forEach(function (group_id) { + $acl_allow_input.tagsinput('add', acl_groups.get('group-' + group_id)[0]); }); - $contact_allow_input.val().split(',').forEach(function (val) { - $acl_allow_input.tagsinput('add', acl_contacts.get(val)[0]); + $contact_allow_input.val().split(',').forEach(function (contact_id) { + $acl_allow_input.tagsinput('add', acl_contacts.get('contact-' + contact_id)[0]); }); - $group_deny_input.val().split(',').forEach(function (val) { - $acl_deny_input.tagsinput('add', acl_groups.get(val)[0]); + $group_deny_input.val().split(',').forEach(function (group_id) { + $acl_deny_input.tagsinput('add', acl_groups.get('group-' + group_id)[0]); }); - $contact_deny_input.val().split(',').forEach(function (val) { - $acl_deny_input.tagsinput('add', acl_contacts.get(val)[0]); + $contact_deny_input.val().split(',').forEach(function (contact_id) { + $acl_deny_input.tagsinput('add', acl_contacts.get('contact-' + contact_id)[0]); }); // Anti-duplicate callback + acl fields value generation From 23cdc9cec85c6ed6db11ba93add4b8936b3a0306 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 7 Dec 2019 21:05:14 +0000 Subject: [PATCH 11/13] Fixes issue 7914: Reshares got crumbled --- mod/item.php | 6 +++--- src/Content/Text/BBCode.php | 5 ++--- src/Model/Item.php | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/mod/item.php b/mod/item.php index 999e7a25c..93da70e40 100644 --- a/mod/item.php +++ b/mod/item.php @@ -652,6 +652,9 @@ function item_post(App $a) { if ($orig_post) { $datarray['edit'] = true; } else { + // If this was a share, add missing data here + $datarray = Item::addShareDataFromOriginal($datarray); + $datarray['edit'] = false; } @@ -730,9 +733,6 @@ function item_post(App $a) { } } - // If this was a share, add missing data here - $datarray = Item::addShareDataFromOriginal($datarray); - $post_id = Item::insert($datarray); if (!$post_id) { diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 0291c729e..29b4f47eb 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -953,12 +953,11 @@ class BBCode extends BaseObject public static function convertShare($text, callable $callback) { $return = preg_replace_callback( - "/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism", + "/(.*?)\[share(.*?)\](.*)\[\/share\]/ism", function ($match) use ($callback) { $attribute_string = $match[2]; - $attributes = []; - foreach(['author', 'profile', 'avatar', 'link', 'posted'] as $field) { + foreach (['author', 'profile', 'avatar', 'link', 'posted'] as $field) { preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches); $attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8'); } diff --git a/src/Model/Item.php b/src/Model/Item.php index 0f008518b..1e3b16002 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -3833,7 +3833,7 @@ class Item extends BaseObject $body = $shared_item['body']; } - $item['body'] = preg_replace("/(.*?\[share.*?\]\s?).*?(\s?\[\/share\]\s?)/ism", '$1' . $body . '$2', $item['body']); + $item['body'] = preg_replace("/\[share ([^\[\]]*)\].*\[\/share\]/ism", '[share $1]' . $body . '[/share]', $item['body']); unset($shared_item['body']); return array_merge($item, $shared_item); From 484b99f7cf3550c56c1ab1b598ab3cd7b286e7da Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 7 Dec 2019 21:42:55 +0000 Subject: [PATCH 12/13] Fix: Don't automatically mention a post creator on private posts --- src/Protocol/ActivityPub/Transmitter.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 5bb03a851..aebf59891 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -381,16 +381,16 @@ class Transmitter $terms = Term::tagArrayFromItemId($item['id'], [Term::MENTION, Term::IMPLICIT_MENTION]); - // Directly mention the original author upon a quoted reshare. - // Else just ensure that the original author receives the reshare. - $announce = self::getAnnounceArray($item); - if (!empty($announce['comment'])) { - $data['to'][] = $announce['actor']['url']; - } elseif (!empty($announce)) { - $data['cc'][] = $announce['actor']['url']; - } - if (!$item['private']) { + // Directly mention the original author upon a quoted reshare. + // Else just ensure that the original author receives the reshare. + $announce = self::getAnnounceArray($item); + if (!empty($announce['comment'])) { + $data['to'][] = $announce['actor']['url']; + } elseif (!empty($announce)) { + $data['cc'][] = $announce['actor']['url']; + } + $data = array_merge($data, self::fetchPermissionBlockFromConversation($item)); $data['to'][] = ActivityPub::PUBLIC_COLLECTION; From 6728c58535986e69899d1cc47c84cd58431c43d0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 8 Dec 2019 05:19:15 +0000 Subject: [PATCH 13/13] Mail contacts: Update public via user contact / display owner's posts --- src/Model/Contact.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 765c44064..a30cd39ba 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1458,15 +1458,26 @@ class Contact extends BaseObject if (DBA::isResult($contact)) { $contact_id = $contact["id"]; - // Update the contact every 7 days - if (in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { + // Update the contact every 7 days (Don't update mail or feed contacts) + if (in_array($contact['network'], Protocol::FEDERATED)) { $update_contact = ($contact['updated'] < DateTimeFormat::utc('now -7 days')); // We force the update if the avatar is empty if (empty($contact['avatar'])) { $update_contact = true; } - } else { + } elseif (empty($default) && in_array($contact['network'], [Protocol::MAIL, Protocol::PHANTOM]) && ($uid == 0)) { + // Update public mail accounts via their user's accounts + $fields = ['network', 'addr', 'name', 'nick', 'avatar', 'photo', 'thumb', 'micro']; + $mailcontact = DBA::selectFirst('contact', $fields, ["`addr` = ? AND `network` = ? AND `uid` != 0", $url, Protocol::MAIL]); + if (!DBA::isResult($mailcontact)) { + $mailcontact = DBA::selectFirst('contact', $fields, ["`nurl` = ? AND `network` = ? AND `uid` != 0", $url, Protocol::MAIL]); + } + + if (DBA::isResult($mailcontact)) { + DBA::update('contact', $mailcontact, ['id' => $contact_id]); + } + $update_contact = false; } @@ -1743,7 +1754,7 @@ class Contact extends BaseObject $sql = "`item`.`uid` = ?"; } - $contact_field = ($contact["contact-type"] == self::TYPE_COMMUNITY ? 'owner-id' : 'author-id'); + $contact_field = ((($contact["contact-type"] == self::TYPE_COMMUNITY) || ($contact['network'] == Protocol::MAIL)) ? 'owner-id' : 'author-id'); if ($thread_mode) { $condition = ["`$contact_field` = ? AND `gravity` = ? AND " . $sql,