]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Post.php
2) Refactor App->config[] into Core\PConfig
[friendica.git] / src / Object / Post.php
index 2d52f4244a6c5fbe19b10af406c5b78b8907fa13..847135d3621bf10945d71a652e694c4b9faa4a8f 100644 (file)
@@ -250,7 +250,7 @@ class Post extends BaseObject
                        }
                }
 
-               $responses = get_responses($conv_responses, $response_verbs, $this, $item);
+               $responses = get_responses($conv_responses, $response_verbs, $item, $this);
 
                foreach ($response_verbs as $value => $verbs) {
                        $responses[$verbs]['output'] = !empty($conv_responses[$verbs][$item['uri']]) ? format_like($conv_responses[$verbs][$item['uri']], $conv_responses[$verbs][$item['uri'] . '-l'], $verbs, $item['uri']) : '';
@@ -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'),