3 * @file src/Object/Post.php
5 namespace Friendica\Object;
7 use Friendica\Content\ContactSelector;
8 use Friendica\Content\Feature;
9 use Friendica\Core\Addon;
10 use Friendica\Core\Config;
11 use Friendica\Core\Hook;
12 use Friendica\Core\L10n;
13 use Friendica\Core\Logger;
14 use Friendica\Core\PConfig;
15 use Friendica\Core\Protocol;
16 use Friendica\Core\Renderer;
17 use Friendica\Core\Session;
18 use Friendica\Database\DBA;
20 use Friendica\Model\Contact;
21 use Friendica\Model\Item;
22 use Friendica\Model\Term;
23 use Friendica\Model\User;
24 use Friendica\Protocol\Activity;
25 use Friendica\Util\Crypto;
26 use Friendica\Util\DateTimeFormat;
27 use Friendica\Util\Proxy as ProxyUtils;
28 use Friendica\Util\Strings;
29 use Friendica\Util\Temporal;
37 private $template = null;
38 private $available_templates = [
39 'wall' => 'wall_thread.tpl',
40 'wall2wall' => 'wallwall_thread.tpl'
42 private $comment_box_template = 'comment_item.tpl';
43 private $toplevel = false;
44 private $writable = false;
48 private $children = [];
49 private $parent = null;
54 private $thread = null;
55 private $redirect_url = null;
56 private $owner_url = '';
57 private $owner_photo = '';
58 private $owner_name = '';
59 private $wall_to_wall = false;
60 private $threaded = false;
61 private $visiting = false;
66 * @param array $data data array
69 public function __construct(array $data)
72 $this->setTemplate('wall');
73 $this->toplevel = $this->getId() == $this->getDataValue('parent');
75 if (!empty(Session::getUserIDForVisitorContactID($this->getDataValue('contact-id')))) {
76 $this->visiting = true;
79 $this->writable = $this->getDataValue('writable') || $this->getDataValue('self');
80 $author = ['uid' => 0, 'id' => $this->getDataValue('author-id'),
81 'network' => $this->getDataValue('author-network'),
82 'url' => $this->getDataValue('author-link')];
83 $this->redirect_url = Contact::magicLinkByContact($author);
84 if (!$this->isToplevel()) {
85 $this->threaded = true;
88 // Prepare the children
89 if (!empty($data['children'])) {
90 foreach ($data['children'] as $item) {
91 // Only add will be displayed
92 if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
94 } elseif (!visible_activity($item)) {
98 // You can always comment on Diaspora and OStatus items
99 if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (local_user() == $item['uid'])) {
100 $item['writable'] = true;
103 $item['pagedrop'] = $data['pagedrop'];
104 $child = new Post($item);
105 $this->addChild($child);
111 * Get data in a form usable by a conversation template
113 * @param array $conv_responses conversation responses
114 * @param integer $thread_level default = 1
116 * @return mixed The data requested on success
118 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
119 * @throws \ImagickException
121 public function getTemplateData(array $conv_responses, $thread_level = 1)
125 $item = $this->getData();
127 // If the time between "created" and "edited" differs we add
128 // a notice that the post was edited.
129 // Note: In some networks reshared items seem to have (sometimes) a difference
130 // between creation time and edit time of a second. Thats why we add the notice
131 // only if the difference is more than 1 second.
132 if (strtotime($item['edited']) - strtotime($item['created']) > 1) {
134 'label' => L10n::t('This entry was edited'),
135 'date' => DateTimeFormat::local($item['edited'], 'r'),
136 'relative' => Temporal::getRelativeDate($item['edited'])
146 $ispinned = "unpinned";
147 $isstarred = "unstarred";
151 $total_children = $this->countDescendants();
153 $conv = $this->getThread();
155 $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
156 || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
157 ? L10n::t('Private Message')
160 $shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != 1;
165 if (Strings::compareLink($a->contact['url'], $item['author-link'])) {
166 if ($item["event-id"] != 0) {
167 $edpost = ["events/event/" . $item['event-id'], L10n::t("Edit")];
169 $edpost = ["editpost/" . $item['id'], L10n::t("Edit")];
172 $dropping = in_array($item['uid'], [0, local_user()]);
175 // Editing on items of not subscribed users isn't currently possible
176 // There are some issues on editing that prevent this.
177 // But also it is an issue of the supported protocols that doesn't allow editing at all.
178 if ($item['uid'] == 0) {
182 if (($this->getDataValue('uid') == local_user()) || $this->isVisiting()) {
186 $origin = $item['origin'];
189 /// @todo This shouldn't be done as query here, but better during the data creation.
190 // it is now done here, since during the RC phase we shouldn't make to intense changes.
191 $parent = Item::selectFirst(['origin'], ['id' => $item['parent']]);
192 if (DBA::isResult($parent)) {
193 $origin = $parent['origin'];
195 } elseif ($item['pinned']) {
196 $pinned = L10n::t('pinned item');
199 if ($origin && ($item['id'] != $item['parent']) && ($item['network'] == Protocol::ACTIVITYPUB)) {
200 // ActivityPub doesn't allow removal of remote comments
201 $delete = L10n::t('Delete locally');
203 // Showing the one or the other text, depending upon if we can only hide it or really delete it.
204 $delete = $origin ? L10n::t('Delete globally') : L10n::t('Remove locally');
208 'dropping' => $dropping,
209 'pagedrop' => $item['pagedrop'],
210 'select' => L10n::t('Select'),
218 $filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? L10n::t("save to folder") : false);
220 $profile_name = $item['author-name'];
221 if (!empty($item['author-link']) && empty($item['author-name'])) {
222 $profile_name = $item['author-link'];
225 $author = ['uid' => 0, 'id' => $item['author-id'],
226 'network' => $item['author-network'], 'url' => $item['author-link']];
228 if (Session::isAuthenticated()) {
229 $profile_link = Contact::magicLinkByContact($author);
231 $profile_link = $item['author-link'];
234 if (strpos($profile_link, 'redir/') === 0) {
235 $sparkle = ' sparkle';
238 $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
239 Hook::callAll('render_location', $locate);
240 $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
242 // process action responses - e.g. like/dislike/attend/agree/whatever
243 $response_verbs = ['like', 'dislike', 'announce'];
247 if ($item['object-type'] === Activity\ObjectType::EVENT) {
248 $response_verbs[] = 'attendyes';
249 $response_verbs[] = 'attendno';
250 $response_verbs[] = 'attendmaybe';
251 if ($conv->isWritable()) {
253 $attend = [L10n::t('I will attend'), L10n::t('I will not attend'), L10n::t('I might attend')];
257 $responses = get_responses($conv_responses, $response_verbs, $item, $this);
259 foreach ($response_verbs as $value => $verbs) {
260 $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']) : '';
264 * We should avoid doing this all the time, but it depends on the conversation mode
265 * And the conv mode may change when we change the conv, or it changes its mode
266 * Maybe we should establish a way to be notified about conversation changes
268 $this->checkWallToWall();
270 if ($this->isWallToWall() && ($this->getOwnerUrl() == $this->getRedirectUrl())) {
271 $osparkle = ' sparkle';
276 if ($this->isToplevel()) {
278 $thread = Item::selectFirstThreadForUser(local_user(), ['ignored'], ['iid' => $item['id']]);
279 if (DBA::isResult($thread)) {
281 'do' => L10n::t("ignore thread"),
282 'undo' => L10n::t("unignore thread"),
283 'toggle' => L10n::t("toggle ignore status"),
284 'classdo' => $thread['ignored'] ? "hidden" : "",
285 'classundo' => $thread['ignored'] ? "" : "hidden",
286 'ignored' => L10n::t('ignored'),
290 if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
292 $ispinned = ($item['pinned'] ? 'pinned' : 'unpinned');
295 'do' => L10n::t('pin'),
296 'undo' => L10n::t('unpin'),
297 'toggle' => L10n::t('toggle pin status'),
298 'classdo' => $item['pinned'] ? 'hidden' : '',
299 'classundo' => $item['pinned'] ? '' : 'hidden',
300 'pinned' => L10n::t('pinned'),
304 $isstarred = (($item['starred']) ? "starred" : "unstarred");
307 'do' => L10n::t("add star"),
308 'undo' => L10n::t("remove star"),
309 'toggle' => L10n::t("toggle star status"),
310 'classdo' => $item['starred'] ? "hidden" : "",
311 'classundo' => $item['starred'] ? "" : "hidden",
312 'starred' => L10n::t('starred'),
316 'add' => L10n::t("add tag"),
325 if ($conv->isWritable()) {
327 'like' => [L10n::t("I like this \x28toggle\x29"), L10n::t("like")],
328 'dislike' => [L10n::t("I don't like this \x28toggle\x29"), L10n::t("dislike")],
331 $buttons['share'] = [L10n::t('Share this'), L10n::t('share')];
335 $comment = $this->getCommentBox($indent);
337 if (strcmp(DateTimeFormat::utc($item['created']), DateTimeFormat::utc('now - 12 hours')) > 0) {
341 localize_item($item);
343 $body = Item::prepareBody($item, true);
345 list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);
348 $text_e = strip_tags($body);
349 $name_e = $profile_name;
351 if (!empty($item['content-warning']) && PConfig::get(local_user(), 'system', 'disable_cw', false)) {
352 $title_e = ucfirst($item['content-warning']);
354 $title_e = $item['title'];
357 $location_e = $location;
358 $owner_name_e = $this->getOwnerName();
360 // Disable features that aren't available in several networks
361 if (!in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA]) && isset($buttons["dislike"])) {
362 unset($buttons["dislike"]);
367 if (($item["network"] == Protocol::FEED) && isset($buttons["like"])) {
368 unset($buttons["like"]);
371 if (($item["network"] == Protocol::MAIL) && isset($buttons["like"])) {
372 unset($buttons["like"]);
375 $tags = Term::populateTagsFromItem($item);
377 $ago = Temporal::getRelativeDate($item['created']);
378 $ago_received = Temporal::getRelativeDate($item['received']);
379 if (Config::get('system', 'show_received') && (abs(strtotime($item['created']) - strtotime($item['received'])) > Config::get('system', 'show_received_seconds')) && ($ago != $ago_received)) {
380 $ago = L10n::t('%s (Received %s)', $ago, $ago_received);
384 'template' => $this->getTemplate(),
385 'type' => implode("", array_slice(explode("/", $item['verb']), -1)),
386 'suppress_tags' => Config::get('system', 'suppress_tags'),
387 'tags' => $tags['tags'],
388 'hashtags' => $tags['hashtags'],
389 'mentions' => $tags['mentions'],
390 'implicit_mentions' => $tags['implicit_mentions'],
391 'txt_cats' => L10n::t('Categories:'),
392 'txt_folders' => L10n::t('Filed under:'),
393 'has_cats' => ((count($categories)) ? 'true' : ''),
394 'has_folders' => ((count($folders)) ? 'true' : ''),
395 'categories' => $categories,
396 'folders' => $folders,
399 'id' => $this->getId(),
400 'guid' => urlencode($item['guid']),
401 'isevent' => $isevent,
403 'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
404 'olinktitle' => L10n::t('View %s\'s profile @ %s', $this->getOwnerName(), $item['owner-link']),
405 'to' => L10n::t('to'),
406 'via' => L10n::t('via'),
407 'wall' => L10n::t('Wall-to-Wall'),
408 'vwall' => L10n::t('via Wall-To-Wall:'),
409 'profile_url' => $profile_link,
410 'item_photo_menu' => item_photo_menu($item),
412 'thumb' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['author-avatar'], false, ProxyUtils::SIZE_THUMB)),
413 'osparkle' => $osparkle,
414 'sparkle' => $sparkle,
416 'localtime' => DateTimeFormat::local($item['created'], 'r'),
417 'ago' => $item['app'] ? L10n::t('%s from %s', $ago, $item['app']) : $ago,
418 'app' => $item['app'],
421 'location' => $location_e,
424 'owner_self' => $item['author-link'] == Session::get('my_url'),
425 'owner_url' => $this->getOwnerUrl(),
426 'owner_photo' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
427 'owner_name' => $owner_name_e,
428 'plink' => Item::getPlink($item),
430 'ispinned' => $ispinned,
433 'isstarred' => $isstarred,
440 'like' => $responses['like']['output'],
441 'dislike' => $responses['dislike']['output'],
442 'responses' => $responses,
443 'switchcomment' => L10n::t('Comment'),
444 'reply_label' => L10n::t('Reply to %s', $name_e),
445 'comment' => $comment,
446 'previewing' => $conv->isPreview() ? ' preview ' : '',
447 'wait' => L10n::t('Please wait'),
448 'thread_level' => $thread_level,
450 'network' => $item["network"],
451 'network_name' => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network']),
452 'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']),
453 'received' => $item['received'],
454 'commented' => $item['commented'],
455 'created_date' => $item['created'],
456 'return' => ($a->cmd) ? bin2hex($a->cmd) : '',
458 'queue_count' => $item['delivery_queue_count'],
459 'queue_done' => $item['delivery_queue_done'] + $item['delivery_queue_failed'], /// @todo Possibly display it separately in the future
460 'notifier_pending' => L10n::t('Notifier task is pending'),
461 'delivery_pending' => L10n::t('Delivery to remote servers is pending'),
462 'delivery_underway' => L10n::t('Delivery to remote servers is underway'),
463 'delivery_almost' => L10n::t('Delivery to remote servers is mostly done'),
464 'delivery_done' => L10n::t('Delivery to remote servers is done'),
468 $arr = ['item' => $item, 'output' => $tmp_item];
469 Hook::callAll('display_item', $arr);
471 $result = $arr['output'];
473 $result['children'] = [];
474 $children = $this->getChildren();
475 $nb_children = count($children);
476 if ($nb_children > 0) {
477 foreach ($children as $child) {
478 $result['children'][] = $child->getTemplateData($conv_responses, $thread_level + 1);
482 if (($nb_children > 2) || ($thread_level > 1)) {
483 $result['children'][0]['comment_firstcollapsed'] = true;
484 $result['children'][0]['num_comments'] = L10n::tt('%d comment', '%d comments', $total_children);
485 $result['children'][0]['show_text'] = L10n::t('Show more');
486 $result['children'][0]['hide_text'] = L10n::t('Show fewer');
487 if ($thread_level > 1) {
488 $result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
490 $result['children'][$nb_children - 3]['comment_lastcollapsed'] = true;
495 if ($this->isToplevel()) {
496 $result['total_comments_num'] = "$total_children";
497 $result['total_comments_text'] = L10n::tt('comment', 'comments', $total_children);
500 $result['private'] = $item['private'];
501 $result['toplevel'] = ($this->isToplevel() ? 'toplevel_item' : '');
503 if ($this->isThreaded()) {
504 $result['flatten'] = false;
505 $result['threaded'] = true;
507 $result['flatten'] = true;
508 $result['threaded'] = false;
517 public function getId()
519 return $this->getDataValue('id');
525 public function isThreaded()
527 return $this->threaded;
533 * @param Post $item The child item to add
538 public function addChild(Post $item)
540 $item_id = $item->getId();
542 Logger::log('[ERROR] Post::addChild : Item has no ID!!', Logger::DEBUG);
544 } elseif ($this->getChild($item->getId())) {
545 Logger::log('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').', Logger::DEBUG);
549 $activity = DI::activity();
552 * Only add what will be displayed
554 if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
556 } elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) ||
557 $activity->match($item->getDataValue('verb'), Activity::DISLIKE)) {
561 $item->setParent($this);
562 $this->children[] = $item;
564 return end($this->children);
568 * Get a child by its ID
570 * @param integer $id The child id
574 public function getChild($id)
576 foreach ($this->getChildren() as $child) {
577 if ($child->getId() == $id) {
586 * Get all our children
590 public function getChildren()
592 return $this->children;
598 * @param Post $item The item to set as parent
602 protected function setParent(Post $item)
604 $parent = $this->getParent();
606 $parent->removeChild($this);
609 $this->parent = $item;
610 $this->setThread($item->getThread());
618 protected function removeParent()
620 $this->parent = null;
621 $this->thread = null;
627 * @param Post $item The child to be removed
629 * @return boolean Success or failure
632 public function removeChild(Post $item)
634 $id = $item->getId();
635 foreach ($this->getChildren() as $key => $child) {
636 if ($child->getId() == $id) {
637 $child->removeParent();
638 unset($this->children[$key]);
639 // Reindex the array, in order to make sure there won't be any trouble on loops using count()
640 $this->children = array_values($this->children);
644 Logger::log('[WARN] Item::removeChild : Item is not a child (' . $id . ').', Logger::DEBUG);
653 protected function getParent()
655 return $this->parent;
659 * Set conversation thread
661 * @param Thread $thread
665 public function setThread(Thread $thread = null)
667 $this->thread = $thread;
669 // Set it on our children too
670 foreach ($this->getChildren() as $child) {
671 $child->setThread($thread);
680 public function getThread()
682 return $this->thread;
688 * We shouldn't need this
692 public function getData()
700 * @param string $name key
702 * @return mixed value on success
705 public function getDataValue($name)
707 if (!isset($this->data[$name])) {
708 // Logger::log('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".', Logger::DEBUG);
712 return $this->data[$name];
718 * @param string $name template name
722 private function setTemplate($name)
724 if (empty($this->available_templates[$name])) {
725 Logger::log('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', Logger::DEBUG);
729 $this->template = $this->available_templates[$name];
739 private function getTemplate()
741 return $this->template;
745 * Check if this is a toplevel post
749 private function isToplevel()
751 return $this->toplevel;
755 * Check if this is writable
759 private function isWritable()
761 $conv = $this->getThread();
764 // This will allow us to comment on wall-to-wall items owned by our friends
765 // and community forums even if somebody else wrote the post.
766 // bug #517 - this fixes for conversation owner
767 if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == local_user()) {
771 // this fixes for visitors
772 return ($this->writable || ($this->isVisiting() && $conv->getMode() == 'profile'));
774 return $this->writable;
778 * Count the total of our descendants
782 private function countDescendants()
784 $children = $this->getChildren();
785 $total = count($children);
787 foreach ($children as $child) {
788 $total += $child->countDescendants();
796 * Get the template for the comment box
800 private function getCommentBoxTemplate()
802 return $this->comment_box_template;
806 * Get default text for the comment box
809 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
811 private function getDefaultText()
819 $owner = User::getOwnerDataById($a->user['uid']);
821 if (!Feature::isEnabled(local_user(), 'explicit_mentions')) {
825 $item = Item::selectFirst(['author-addr'], ['id' => $this->getId()]);
826 if (!DBA::isResult($item) || empty($item['author-addr'])) {
831 if ($item['author-addr'] != $owner['addr']) {
832 $text = '@' . $item['author-addr'] . ' ';
837 $terms = Term::tagArrayFromItemId($this->getId(), [Term::MENTION, Term::IMPLICIT_MENTION]);
838 foreach ($terms as $term) {
839 $profile = Contact::getDetailsByURL($term['url']);
840 if (!empty($profile['addr']) && ((($profile['contact-type'] ?? '') ?: Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&
841 ($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) {
842 $text .= '@' . $profile['addr'] . ' ';
850 * Get the comment box
852 * @param string $indent Indent value
854 * @return mixed The comment box string (empty if no comment box)
858 private function getCommentBox($indent)
863 $conv = $this->getThread();
865 if (($conv->getMode() === 'network') && $this->isWallToWall()) {
869 if ($conv->isWritable() && $this->isWritable()) {
873 * Hmmm, code depending on the presence of a particular addon?
874 * This should be better if done by a hook
876 if (Addon::isEnabled('qcomment')) {
877 $qc = ((local_user()) ? PConfig::get(local_user(), 'qcomment', 'words') : null);
878 $qcomment = (($qc) ? explode("\n", $qc) : null);
881 // Fetch the user id from the parent when the owner user is empty
882 $uid = $conv->getProfileOwner();
883 $parent_uid = $this->getDataValue('uid');
885 $default_text = $this->getDefaultText();
887 if (!is_null($parent_uid) && ($uid != $parent_uid)) {
891 $template = Renderer::getMarkupTemplate($this->getCommentBoxTemplate());
892 $comment_box = Renderer::replaceMacros($template, [
893 '$return_path' => DI::args()->getQueryString(),
894 '$threaded' => $this->isThreaded(),
896 '$wall' => ($conv->getMode() === 'profile'),
897 '$id' => $this->getId(),
898 '$parent' => $this->getId(),
899 '$qcomment' => $qcomment,
900 '$default' => $default_text,
901 '$profile_uid' => $uid,
902 '$mylink' => DI::baseUrl()->remove($a->contact['url']),
903 '$mytitle' => L10n::t('This is you'),
904 '$myphoto' => DI::baseUrl()->remove($a->contact['thumb']),
905 '$comment' => L10n::t('Comment'),
906 '$submit' => L10n::t('Submit'),
907 '$edbold' => L10n::t('Bold'),
908 '$editalic' => L10n::t('Italic'),
909 '$eduline' => L10n::t('Underline'),
910 '$edquote' => L10n::t('Quote'),
911 '$edcode' => L10n::t('Code'),
912 '$edimg' => L10n::t('Image'),
913 '$edurl' => L10n::t('Link'),
914 '$edattach' => L10n::t('Link or Media'),
915 '$prompttext' => L10n::t('Please enter a image/video/audio/webpage URL:'),
916 '$preview' => L10n::t('Preview'),
917 '$indent' => $indent,
918 '$sourceapp' => L10n::t($a->sourcename),
919 '$ww' => $conv->getMode() === 'network' ? $ww : '',
920 '$rand_num' => Crypto::randomDigits(12)
930 private function getRedirectUrl()
932 return $this->redirect_url;
936 * Check if we are a wall to wall item and set the relevant properties
941 protected function checkWallToWall()
944 $conv = $this->getThread();
945 $this->wall_to_wall = false;
947 if ($this->isToplevel()) {
948 if ($conv->getMode() !== 'profile') {
949 if ($this->getDataValue('wall') && !$this->getDataValue('self')) {
950 // On the network page, I am the owner. On the display page it will be the profile owner.
951 // This will have been stored in $a->page_contact by our calling page.
952 // Put this person as the wall owner of the wall-to-wall notice.
954 $this->owner_url = Contact::magicLink($a->page_contact['url']);
955 $this->owner_photo = $a->page_contact['thumb'];
956 $this->owner_name = $a->page_contact['name'];
957 $this->wall_to_wall = true;
958 } elseif ($this->getDataValue('owner-link')) {
959 $owner_linkmatch = (($this->getDataValue('owner-link')) && Strings::compareLink($this->getDataValue('owner-link'), $this->getDataValue('author-link')));
960 $alias_linkmatch = (($this->getDataValue('alias')) && Strings::compareLink($this->getDataValue('alias'), $this->getDataValue('author-link')));
961 $owner_namematch = (($this->getDataValue('owner-name')) && $this->getDataValue('owner-name') == $this->getDataValue('author-name'));
963 if (!$owner_linkmatch && !$alias_linkmatch && !$owner_namematch) {
964 // The author url doesn't match the owner (typically the contact)
965 // and also doesn't match the contact alias.
966 // The name match is a hack to catch several weird cases where URLs are
967 // all over the park. It can be tricked, but this prevents you from
968 // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
969 // well that it's the same Bob Smith.
970 // But it could be somebody else with the same name. It just isn't highly likely.
973 $this->owner_photo = $this->getDataValue('owner-avatar');
974 $this->owner_name = $this->getDataValue('owner-name');
975 $this->wall_to_wall = true;
977 $owner = ['uid' => 0, 'id' => $this->getDataValue('owner-id'),
978 'network' => $this->getDataValue('owner-network'),
979 'url' => $this->getDataValue('owner-link')];
980 $this->owner_url = Contact::magicLinkByContact($owner);
986 if (!$this->wall_to_wall) {
987 $this->setTemplate('wall');
988 $this->owner_url = '';
989 $this->owner_photo = '';
990 $this->owner_name = '';
997 private function isWallToWall()
999 return $this->wall_to_wall;
1005 private function getOwnerUrl()
1007 return $this->owner_url;
1013 private function getOwnerName()
1015 return $this->owner_name;
1021 private function isVisiting()
1023 return $this->visiting;