From 043521fb47d8c451cf2bb32884b4ea22265cc131 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 26 Jan 2019 19:42:13 -0500 Subject: [PATCH 01/34] Switch to supported HTML entity for bullet in delivery indicator --- view/templates/sub/delivery_count.tpl | 2 +- view/theme/frio/templates/sub/delivery_count.tpl | 2 +- view/theme/vier/templates/sub/delivery_count.tpl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/view/templates/sub/delivery_count.tpl b/view/templates/sub/delivery_count.tpl index b487be8847..6ee4be0fe2 100644 --- a/view/templates/sub/delivery_count.tpl +++ b/view/templates/sub/delivery_count.tpl @@ -4,7 +4,7 @@ *}} {{if $delivery.queue_count >= -1 && $delivery.queue_count !== '' && $delivery.queue_count !== null}} - • + • {{if $delivery.queue_count == 0}} {{$delivery.notifier_pending}} {{elseif $delivery.queue_done == 0}} diff --git a/view/theme/frio/templates/sub/delivery_count.tpl b/view/theme/frio/templates/sub/delivery_count.tpl index ee9e411cc4..983b49caac 100644 --- a/view/theme/frio/templates/sub/delivery_count.tpl +++ b/view/theme/frio/templates/sub/delivery_count.tpl @@ -1,6 +1,6 @@ {{if $delivery.queue_count >= -1 && $delivery.queue_count !== '' && $delivery.queue_count !== null}} - • + • {{if $delivery.queue_count == 0}} {{$delivery.notifier_pending}} diff --git a/view/theme/vier/templates/sub/delivery_count.tpl b/view/theme/vier/templates/sub/delivery_count.tpl index a0719f762f..37b123e409 100644 --- a/view/theme/vier/templates/sub/delivery_count.tpl +++ b/view/theme/vier/templates/sub/delivery_count.tpl @@ -1,6 +1,6 @@ {{if $delivery.queue_count >= -1 && $delivery.queue_count !== '' && $delivery.queue_count !== null}} - • + • {{if $delivery.queue_count == 0}} {{$delivery.notifier_pending}} From cd19cce92e539bd2d8b1b3b25903c1f8f4e72bda Mon Sep 17 00:00:00 2001 From: Peter Liebetrau Date: Sun, 27 Jan 2019 04:06:51 +0100 Subject: [PATCH 02/34] frio - fix bug in admin users with table sorting #6529 --- view/theme/frio/templates/admin/users.tpl | 266 +++++++++++----------- 1 file changed, 135 insertions(+), 131 deletions(-) diff --git a/view/theme/frio/templates/admin/users.tpl b/view/theme/frio/templates/admin/users.tpl index 92ef9be6fa..273eb81e68 100644 --- a/view/theme/frio/templates/admin/users.tpl +++ b/view/theme/frio/templates/admin/users.tpl @@ -106,141 +106,147 @@
{{if $users}} - - - - - - {{foreach $th_users as $k=>$th}} - {{if $k < 2 || $order_users == $th.1 || ($k==5 && !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.4.1])) }} - + + + {{if $order_users == $th_users.2.1}} + + {{/if}} + + {{if $order_users == $th_users.3.1}} + + {{/if}} + + {{if $order_users == $th_users.4.1}} + + {{/if}} + + {{if !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.4.1]) }} + + {{/if}} + + + + + + + + + {{/foreach}} + +
- {{$u.name}}{{$u.email}}{{$u.register_date}}{{$u.login_date}}{{$u.lastitem_date}} + + + {{if $u.page_flags_raw==0 && $u.account_type_raw > 0}} + + {{/if}} + {{if $u.is_admin}}{{/if}} + {{if $u.account_expired}}{{/if}} + + +
+
+ {{else}} +
NO USERS?!?
+ {{/if}} From eee0e2285659079183940ab1c6a45aefc437c6ed Mon Sep 17 00:00:00 2001 From: Peter Liebetrau Date: Sun, 27 Jan 2019 13:21:18 +0100 Subject: [PATCH 03/34] frio - fix PHP Notices reported in #6338 --- view/theme/frio/theme.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index 0487cc7331..9434b340d2 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -237,25 +237,25 @@ function frio_remote_nav($a, &$nav) } elseif (!local_user() && remote_user()) { $r = q("SELECT `name`, `nick`, `micro` AS `photo` FROM `contact` WHERE `id` = %d", intval(remote_user())); $nav['remote'] = L10n::t('Guest'); - $remoteUser = $r[0]; } elseif (Model\Profile::getMyURL()) { $r = q("SELECT `name`, `nick`, `photo` FROM `gcontact` WHERE `addr` = '%s' AND `network` = 'dfrn'", DBA::escape($webbie)); $nav['remote'] = L10n::t('Visitor'); - $remoteUser = $r[0]; } else { $r = false; } + $remoteUser = null; if (DBA::isResult($r)) { $nav['userinfo'] = [ 'icon' => (DBA::isResult($r) ? $r[0]['photo'] : 'images/person-48.jpg'), 'name' => $r[0]['name'], ]; + $remoteUser = $r[0]; } - if (!local_user() && !empty($server_url)) { + if (!local_user() && !empty($server_url) && !is_null($remoteUser)) { $nav['logout'] = [$server_url . '/logout', L10n::t('Logout'), '', L10n::t('End this session')]; // user menu From 5ded9671290b9daf406530c13bc5554caed72268 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 27 Jan 2019 19:54:08 +0000 Subject: [PATCH 04/34] Fix database error --- mod/viewcontacts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index d36ea96c7d..7c2b96fad1 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -66,7 +66,7 @@ function viewcontacts_content(App $a) 'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS] ]; - $total = DBA::count('count', $condition); + $total = DBA::count('contact', $condition); $pager = new Pager($a->query_string); From 030c0b5dc661bacc7d66db56263ec1dc227e29e6 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 28 Jan 2019 06:23:06 +0000 Subject: [PATCH 05/34] Another preparation for forum posts via AP --- src/Protocol/ActivityPub/Transmitter.php | 43 +++++++++++++++++------- src/Worker/Notifier.php | 9 +++-- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 05ce138794..41239b3afd 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -28,6 +28,7 @@ use Friendica\Util\Map; use Friendica\Util\Network; require_once 'include/api.php'; +require_once 'mod/share.php'; /** * @brief ActivityPub Transmitter Protocol class @@ -635,16 +636,29 @@ class Transmitter return false; } - $condition = ['item-uri' => $item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB]; - $conversation = DBA::selectFirst('conversation', ['source'], $condition); - if (DBA::isResult($conversation)) { - $data = json_decode($conversation['source']); - if (!empty($data)) { - return $data; + if ($item['wall']) { + $owner = User::getOwnerDataById($item['uid']); + if (($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) && ($item['author-link'] != $owner['url'])) { + $type = 'Announce'; + + // Disguise forum posts as reshares. Will later be converted to a real announce + $item['body'] = share_header($item['author-name'], $item['author-link'], $item['author-avatar'], + $item['guid'], $item['created'], $item['plink']) . $item['body'] . '[/share]'; } } - $type = self::getTypeOfItem($item); + if (empty($type)) { + $condition = ['item-uri' => $item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB]; + $conversation = DBA::selectFirst('conversation', ['source'], $condition); + if (DBA::isResult($conversation)) { + $data = json_decode($conversation['source']); + if (!empty($data)) { + return $data; + } + } + + $type = self::getTypeOfItem($item); + } if (!$object_mode) { $data = ['@context' => ActivityPub::CONTEXT]; @@ -671,7 +685,7 @@ class Transmitter if (in_array($data['type'], ['Create', 'Update', 'Delete'])) { $data['object'] = self::createNote($item); } elseif ($data['type'] == 'Announce') { - $data['object'] = self::createAnnounce($item); + $data = self::createAnnounce($item, $data); } elseif ($data['type'] == 'Undo') { $data['object'] = self::createActivityFromItem($item_id, true); } else { @@ -1045,11 +1059,13 @@ class Transmitter * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ - public static function createAnnounce($item) + private static function createAnnounce($item, $data) { $announce = api_share_as_retweet($item); if (empty($announce['plink'])) { - return self::createNote($item); + $data['type'] = 'Create'; + $data['object'] = self::createNote($item); + return $data; } // Fetch the original id of the object @@ -1058,11 +1074,14 @@ class Transmitter $ldactivity = JsonLD::compact($activity); $id = JsonLD::fetchElement($ldactivity, '@id'); if (!empty($id)) { - return $id; + $data['object'] = $id; + return $data; } } - return self::createNote($item); + $data['type'] = 'Create'; + $data['object'] = self::createNote($item); + return $data; } /** diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 512fbe8844..4d63d436fe 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -603,15 +603,20 @@ class Notifier return false; } + return self::isForum($item['contact-id']); + } + + private static function isForum($contactid) + { $fields = ['forum', 'prv']; - $condition = ['id' => $item['contact-id']]; + $condition = ['id' => $contactid]; $contact = DBA::selectFirst('contact', $fields, $condition); if (!DBA::isResult($contact)) { // Should never happen return false; } - // Is the post from a forum? + // Is it a forum? return ($contact['forum'] || $contact['prv']); } } From a5e12f53e82807c79c7c1976703d1f4ed3fbac8a Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 28 Jan 2019 11:21:48 +0100 Subject: [PATCH 06/34] Logger Unique ID --- src/Util/Logger/FriendicaProcessor.php | 40 +++++++++++++++++++------- src/Util/LoggerFactory.php | 6 ++-- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/Util/Logger/FriendicaProcessor.php b/src/Util/Logger/FriendicaProcessor.php index 21c6fcc031..8e45c228fd 100644 --- a/src/Util/Logger/FriendicaProcessor.php +++ b/src/Util/Logger/FriendicaProcessor.php @@ -17,22 +17,22 @@ class FriendicaProcessor implements ProcessorInterface private $skipStackFramesCount; + private $skipClassesPartials; + private $skipFunctions = [ 'call_user_func', 'call_user_func_array', ]; - private $skipFiles = [ - 'Logger.php' - ]; - /** * @param string|int $level The minimum logging level at which this Processor will be triggered + * @param array $skipClassesPartials An array of classes to skip during logging * @param int $skipStackFramesCount If the logger should use information from other hierarchy levels of the call */ - public function __construct($level = Logger::DEBUG, $skipStackFramesCount = 0) + public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array(), $skipStackFramesCount = 0) { $this->level = Logger::toMonologLevel($level); + $this->skipClassesPartials = array_merge(array('Monolog\\'), $skipClassesPartials); $this->skipStackFramesCount = $skipStackFramesCount; } @@ -47,13 +47,24 @@ class FriendicaProcessor implements ProcessorInterface $i = 1; - // Skip everything that we shouldn't display - while (in_array($trace[$i]['function'], $this->skipFunctions) || - !isset($trace[$i - 1]['file']) || - in_array(basename($trace[$i - 1]['file']), $this->skipFiles)) { - $i++; + while ($this->isTraceClassOrSkippedFunction($trace, $i)) { + if (isset($trace[$i]['class'])) { + foreach ($this->skipClassesPartials as $part) { + if (strpos($trace[$i]['class'], $part) !== false) { + $i++; + continue 2; + } + } + } elseif (in_array($trace[$i]['function'], $this->skipFunctions)) { + $i++; + continue; + } + + break; } + $i += $this->skipStackFramesCount; + // we should have the call source now $record['extra'] = array_merge( $record['extra'], @@ -66,4 +77,13 @@ class FriendicaProcessor implements ProcessorInterface return $record; } + + private function isTraceClassOrSkippedFunction(array $trace, $index) + { + if (!isset($trace[$index])) { + return false; + } + + return isset($trace[$index]['class']) || in_array($trace[$index]['function'], $this->skipFunctions); + } } diff --git a/src/Util/LoggerFactory.php b/src/Util/LoggerFactory.php index 88b6fe8c81..cca8833751 100644 --- a/src/Util/LoggerFactory.php +++ b/src/Util/LoggerFactory.php @@ -28,7 +28,8 @@ class LoggerFactory $logger = new Monolog\Logger($channel); $logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor()); $logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor()); - $logger->pushProcessor(new FriendicaProcessor(LogLevel::DEBUG, 1)); + $logger->pushProcessor(new Monolog\Processor\UidProcessor()); + $logger->pushProcessor(new FriendicaProcessor(LogLevel::DEBUG, ['Friendica\Core\Logger'])); return $logger; } @@ -51,7 +52,8 @@ class LoggerFactory $logger = new Monolog\Logger($channel); $logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor()); $logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor()); - $logger->pushProcessor(new FriendicaProcessor(LogLevel::DEBUG, 1)); + $logger->pushProcessor(new Monolog\Processor\UidProcessor()); + $logger->pushProcessor(new FriendicaProcessor(LogLevel::DEBUG, ['Friendica\Core\Logger'])); $logger->pushHandler(new FriendicaDevelopHandler($developerIp)); From 88e2cc9fa26d72d54319f04b4678b0792fa4dfc1 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 28 Jan 2019 11:35:08 +0100 Subject: [PATCH 07/34] removing array prefix (compatibility) --- src/Util/Logger/FriendicaProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util/Logger/FriendicaProcessor.php b/src/Util/Logger/FriendicaProcessor.php index 8e45c228fd..627f628b88 100644 --- a/src/Util/Logger/FriendicaProcessor.php +++ b/src/Util/Logger/FriendicaProcessor.php @@ -29,7 +29,7 @@ class FriendicaProcessor implements ProcessorInterface * @param array $skipClassesPartials An array of classes to skip during logging * @param int $skipStackFramesCount If the logger should use information from other hierarchy levels of the call */ - public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array(), $skipStackFramesCount = 0) + public function __construct($level = Logger::DEBUG, $skipClassesPartials = array(), $skipStackFramesCount = 0) { $this->level = Logger::toMonologLevel($level); $this->skipClassesPartials = array_merge(array('Monolog\\'), $skipClassesPartials); From 9fe1da5f94bc2a234e64bb47c6fe3e66f0acf9ce Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 28 Jan 2019 12:35:14 +0100 Subject: [PATCH 08/34] Double backslash --- src/Util/LoggerFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Util/LoggerFactory.php b/src/Util/LoggerFactory.php index cca8833751..961585ebfe 100644 --- a/src/Util/LoggerFactory.php +++ b/src/Util/LoggerFactory.php @@ -29,7 +29,7 @@ class LoggerFactory $logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor()); $logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor()); $logger->pushProcessor(new Monolog\Processor\UidProcessor()); - $logger->pushProcessor(new FriendicaProcessor(LogLevel::DEBUG, ['Friendica\Core\Logger'])); + $logger->pushProcessor(new FriendicaProcessor(LogLevel::DEBUG, ['Friendica\\Core\\Logger'])); return $logger; } @@ -53,7 +53,7 @@ class LoggerFactory $logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor()); $logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor()); $logger->pushProcessor(new Monolog\Processor\UidProcessor()); - $logger->pushProcessor(new FriendicaProcessor(LogLevel::DEBUG, ['Friendica\Core\Logger'])); + $logger->pushProcessor(new FriendicaProcessor(LogLevel::DEBUG, ['Friendica\\Core\\Logger'])); $logger->pushHandler(new FriendicaDevelopHandler($developerIp)); From 26af96f31aee405d2f0eaa6723a1c15d246561e2 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 28 Jan 2019 18:26:35 +0100 Subject: [PATCH 09/34] improving code --- src/Util/Logger/FriendicaProcessor.php | 33 +++++++++++++++----------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Util/Logger/FriendicaProcessor.php b/src/Util/Logger/FriendicaProcessor.php index 627f628b88..9f52a6f126 100644 --- a/src/Util/Logger/FriendicaProcessor.php +++ b/src/Util/Logger/FriendicaProcessor.php @@ -48,19 +48,7 @@ class FriendicaProcessor implements ProcessorInterface $i = 1; while ($this->isTraceClassOrSkippedFunction($trace, $i)) { - if (isset($trace[$i]['class'])) { - foreach ($this->skipClassesPartials as $part) { - if (strpos($trace[$i]['class'], $part) !== false) { - $i++; - continue 2; - } - } - } elseif (in_array($trace[$i]['function'], $this->skipFunctions)) { - $i++; - continue; - } - - break; + $i++; } $i += $this->skipStackFramesCount; @@ -78,12 +66,29 @@ class FriendicaProcessor implements ProcessorInterface return $record; } + /** + * Checks if the current trace class or function has to be skipped + * + * @param array $trace The current trace array + * @param int $index The index of the current hierarchy level + * @return bool True if the class or function should get skipped, otherwise false + */ private function isTraceClassOrSkippedFunction(array $trace, $index) { if (!isset($trace[$index])) { return false; } - return isset($trace[$index]['class']) || in_array($trace[$index]['function'], $this->skipFunctions); + if (isset($trace[$index]['class'])) { + foreach ($this->skipClassesPartials as $part) { + if (strpos($trace[$index]['class'], $part) !== false) { + return true; + } + } + } elseif (in_array($trace[$index]['function'], $this->skipFunctions)) { + return true; + } + + return false; } } From d7e35b5802cdb66241778de82bb1061417008cf0 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 28 Jan 2019 18:41:29 +0100 Subject: [PATCH 10/34] Making the processor name more explicit --- ...icaProcessor.php => FriendicaIntrospectionProcessor.php} | 2 +- src/Util/LoggerFactory.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/Util/Logger/{FriendicaProcessor.php => FriendicaIntrospectionProcessor.php} (97%) diff --git a/src/Util/Logger/FriendicaProcessor.php b/src/Util/Logger/FriendicaIntrospectionProcessor.php similarity index 97% rename from src/Util/Logger/FriendicaProcessor.php rename to src/Util/Logger/FriendicaIntrospectionProcessor.php index 9f52a6f126..aa3933a215 100644 --- a/src/Util/Logger/FriendicaProcessor.php +++ b/src/Util/Logger/FriendicaIntrospectionProcessor.php @@ -11,7 +11,7 @@ use Monolog\Processor\ProcessorInterface; * Based on the class IntrospectionProcessor without the "class" information * @see IntrospectionProcessor */ -class FriendicaProcessor implements ProcessorInterface +class FriendicaIntrospectionProcessor implements ProcessorInterface { private $level; diff --git a/src/Util/LoggerFactory.php b/src/Util/LoggerFactory.php index 961585ebfe..4d3a287165 100644 --- a/src/Util/LoggerFactory.php +++ b/src/Util/LoggerFactory.php @@ -4,7 +4,7 @@ namespace Friendica\Util; use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Util\Logger\FriendicaDevelopHandler; -use Friendica\Util\Logger\FriendicaProcessor; +use Friendica\Util\Logger\FriendicaIntrospectionProcessor; use Monolog; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; @@ -29,7 +29,7 @@ class LoggerFactory $logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor()); $logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor()); $logger->pushProcessor(new Monolog\Processor\UidProcessor()); - $logger->pushProcessor(new FriendicaProcessor(LogLevel::DEBUG, ['Friendica\\Core\\Logger'])); + $logger->pushProcessor(new FriendicaIntrospectionProcessor(LogLevel::DEBUG, ['Friendica\\Core\\Logger'])); return $logger; } @@ -53,7 +53,7 @@ class LoggerFactory $logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor()); $logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor()); $logger->pushProcessor(new Monolog\Processor\UidProcessor()); - $logger->pushProcessor(new FriendicaProcessor(LogLevel::DEBUG, ['Friendica\\Core\\Logger'])); + $logger->pushProcessor(new FriendicaIntrospectionProcessor(LogLevel::DEBUG, ['Friendica\\Core\\Logger'])); $logger->pushHandler(new FriendicaDevelopHandler($developerIp)); From d40b2792b638e68f3040f4a55d30d1b3ef3cbe44 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 28 Jan 2019 21:22:03 +0000 Subject: [PATCH 11/34] Display mentioned users and in the comment box by default --- src/Model/Item.php | 4 +-- src/Object/Post.php | 32 +++++++++++++++++++ view/templates/comment_item.tpl | 2 +- .../duepuntozero/templates/comment_item.tpl | 2 +- view/theme/frio/templates/comment_item.tpl | 2 +- view/theme/quattro/templates/comment_item.tpl | 2 +- view/theme/vier/templates/comment_item.tpl | 2 +- 7 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 67071db318..db9fbf44f6 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -559,10 +559,10 @@ class Item extends BaseObject $fields['permissionset'] = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']; - $fields['author'] = ['url' => 'author-link', 'name' => 'author-name', + $fields['author'] = ['url' => 'author-link', 'name' => 'author-name', 'addr' => 'author-addr', 'thumb' => 'author-avatar', 'nick' => 'author-nick', 'network' => 'author-network']; - $fields['owner'] = ['url' => 'owner-link', 'name' => 'owner-name', + $fields['owner'] = ['url' => 'owner-link', 'name' => 'owner-name', 'addr' => 'owner-addr', 'thumb' => 'owner-avatar', 'nick' => 'owner-nick', 'network' => 'owner-network']; $fields['contact'] = ['url' => 'contact-link', 'name' => 'contact-name', 'thumb' => 'contact-avatar', diff --git a/src/Object/Post.php b/src/Object/Post.php index c9e5cddb69..1e3f5bd99d 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -768,6 +768,35 @@ class Post extends BaseObject return $this->comment_box_template; } + /** + * Get default text for the comment box + * + * @param integer $parent_id ID of the parent item + * + * @return string + */ + private function getDefaultText($parent_id) + { + $item = Item::selectFirst(['author-addr'], ['id' => $parent_id]); + if (!DBA::isResult($item) || empty($item['author-addr'])) { + // Should not happen + return ''; + } + + $text = '@'.$item['author-addr'].' '; + + $terms = Term::tagArrayFromItemId($parent_id, TERM_MENTION); + + foreach ($terms as $term) { + $profile = Contact::getDetailsByURL($term['url']); + if (!empty($profile['addr']) && !strstr($text, $profile['addr'])) { + $text .= '@' . $profile['addr'] . ' '; + } + } + + return $text; + } + /** * Get the comment box * @@ -804,6 +833,8 @@ class Post extends BaseObject $uid = $conv->getProfileOwner(); $parent_uid = $this->getDataValue('uid'); + $default_text = $this->getDefaultText($this->getId()); + if (!is_null($parent_uid) && ($uid != $parent_uid)) { $uid = $parent_uid; } @@ -817,6 +848,7 @@ class Post extends BaseObject '$id' => $this->getId(), '$parent' => $this->getId(), '$qcomment' => $qcomment, + '$default' => $default_text, '$profile_uid' => $uid, '$mylink' => $a->removeBaseURL($a->contact['url']), '$mytitle' => L10n::t('This is you'), diff --git a/view/templates/comment_item.tpl b/view/templates/comment_item.tpl index 6ad01b991b..9412b681eb 100644 --- a/view/templates/comment_item.tpl +++ b/view/templates/comment_item.tpl @@ -17,7 +17,7 @@ {{$mytitle}}
- + {{if $qcomment}} + {{if $qcomment}}
- +
{{if $qcomment}} diff --git a/view/theme/vier/templates/comment_item.tpl b/view/theme/vier/templates/comment_item.tpl index 3e72df6dc6..4ef31b7af8 100644 --- a/view/theme/vier/templates/comment_item.tpl +++ b/view/theme/vier/templates/comment_item.tpl @@ -17,7 +17,7 @@ {{$mytitle}}
- + {{if $qcomment}}