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..3ac5c77ee9 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -768,6 +768,33 @@ class Post extends BaseObject return $this->comment_box_template; } + /** + * Get default text for the comment box + * + * @return string + */ + private function getDefaultText() + { + $item = Item::selectFirst(['author-addr'], ['id' => $this->getId()]); + if (!DBA::isResult($item) || empty($item['author-addr'])) { + // Should not happen + return ''; + } + + $text = '@' . $item['author-addr'] . ' '; + + $terms = Term::tagArrayFromItemId($this->getId(), 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 +831,8 @@ class Post extends BaseObject $uid = $conv->getProfileOwner(); $parent_uid = $this->getDataValue('uid'); + $default_text = $this->getDefaultText(); + if (!is_null($parent_uid) && ($uid != $parent_uid)) { $uid = $parent_uid; } @@ -817,6 +846,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}}