X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FObject%2FPost.php;h=847135d3621bf10945d71a652e694c4b9faa4a8f;hb=f40c57fc204ff47a3cf9f7eab75e8a635566275c;hp=c9e5cddb699f6ebb950cf13870a95a2f4e114ede;hpb=85ff976f83b1037328fedd26fd817c720625e0e9;p=friendica.git diff --git a/src/Object/Post.php b/src/Object/Post.php index c9e5cddb69..847135d362 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -768,6 +768,44 @@ class Post extends BaseObject return $this->comment_box_template; } + /** + * Get default text for the comment box + * + * @return string + */ + private function getDefaultText() + { + if (!local_user()) { + return; + } + + $a = self::getApp(); + + $item = Item::selectFirst(['author-addr'], ['id' => $this->getId()]); + if (!DBA::isResult($item) || empty($item['author-addr'])) { + // Should not happen + return ''; + } + + if ($item['author-addr'] != $a->profile['addr']) { + $text = '@' . $item['author-addr'] . ' '; + } else { + $text = ''; + } + + $terms = Term::tagArrayFromItemId($this->getId(), TERM_MENTION); + + foreach ($terms as $term) { + $profile = Contact::getDetailsByURL($term['url']); + if (!empty($profile['addr']) && ($profile['contact-type'] != Contact::TYPE_COMMUNITY) && + ($profile['addr'] != $a->profile['addr']) && !strstr($text, $profile['addr'])) { + $text .= '@' . $profile['addr'] . ' '; + } + } + + return $text; + } + /** * Get the comment box * @@ -804,6 +842,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 +857,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'),