3 * @file src/Object/Post.php
5 namespace Friendica\Object;
7 use Friendica\BaseObject;
8 use Friendica\Content\ContactSelector;
9 use Friendica\Content\Feature;
10 use Friendica\Content\Item as ContentItem;
11 use Friendica\Core\Addon;
12 use Friendica\Core\Config;
13 use Friendica\Core\Hook;
14 use Friendica\Core\L10n;
15 use Friendica\Core\Logger;
16 use Friendica\Core\PConfig;
17 use Friendica\Core\Protocol;
18 use Friendica\Core\Renderer;
19 use Friendica\Core\Session;
20 use Friendica\Database\DBA;
21 use Friendica\Model\Contact;
22 use Friendica\Model\Item;
23 use Friendica\Model\Term;
24 use Friendica\Model\User;
25 use Friendica\Protocol\Activity;
26 use Friendica\Util\Crypto;
27 use Friendica\Util\DateTimeFormat;
28 use Friendica\Util\Proxy as ProxyUtils;
29 use Friendica\Util\Strings;
30 use Friendica\Util\Temporal;
35 class Post extends BaseObject
38 private $template = null;
39 private $available_templates = [
40 'wall' => 'wall_thread.tpl',
41 'wall2wall' => 'wallwall_thread.tpl'
43 private $comment_box_template = 'comment_item.tpl';
44 private $toplevel = false;
45 private $writable = false;
49 private $children = [];
50 private $parent = null;
55 private $thread = null;
56 private $redirect_url = null;
57 private $owner_url = '';
58 private $owner_photo = '';
59 private $owner_name = '';
60 private $wall_to_wall = false;
61 private $threaded = false;
62 private $visiting = false;
67 * @param array $data data array
70 public function __construct(array $data)
73 $this->setTemplate('wall');
74 $this->toplevel = $this->getId() == $this->getDataValue('parent');
76 if (!empty(Session::getUserIDForVisitorContactID($this->getDataValue('contact-id')))) {
77 $this->visiting = true;
80 $this->writable = $this->getDataValue('writable') || $this->getDataValue('self');
81 $author = ['uid' => 0, 'id' => $this->getDataValue('author-id'),
82 'network' => $this->getDataValue('author-network'),
83 'url' => $this->getDataValue('author-link')];
84 $this->redirect_url = Contact::magicLinkByContact($author);
85 if (!$this->isToplevel()) {
86 $this->threaded = true;
89 // Prepare the children
90 if (!empty($data['children'])) {
91 foreach ($data['children'] as $item) {
92 // Only add will be displayed
93 if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
95 } elseif (!visible_activity($item)) {
99 // You can always comment on Diaspora and OStatus items
100 if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (local_user() == $item['uid'])) {
101 $item['writable'] = true;
104 $item['pagedrop'] = $data['pagedrop'];
105 $child = new Post($item);
106 $this->addChild($child);
112 * Get data in a form usable by a conversation template
114 * @param array $conv_responses conversation responses
115 * @param integer $thread_level default = 1
117 * @return mixed The data requested on success
119 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
120 * @throws \ImagickException
122 public function getTemplateData(array $conv_responses, $thread_level = 1)
126 $item = $this->getData();
128 // If the time between "created" and "edited" differs we add
129 // a notice that the post was edited.
130 // Note: In some networks reshared items seem to have (sometimes) a difference
131 // between creation time and edit time of a second. Thats why we add the notice
132 // only if the difference is more than 1 second.
133 if (strtotime($item['edited']) - strtotime($item['created']) > 1) {
135 'label' => L10n::t('This entry was edited'),
136 'date' => DateTimeFormat::local($item['edited'], 'r'),
137 'relative' => Temporal::getRelativeDate($item['edited'])
147 $ispinned = "unpinned";
148 $isstarred = "unstarred";
152 $total_children = $this->countDescendants();
154 $conv = $this->getThread();
156 $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
157 || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
158 ? L10n::t('Private Message')
161 $shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != 1;
166 if (Strings::compareLink($a->contact['url'], $item['author-link'])) {
167 if ($item["event-id"] != 0) {
168 $edpost = ["events/event/" . $item['event-id'], L10n::t("Edit")];
170 $edpost = ["editpost/" . $item['id'], L10n::t("Edit")];
173 $dropping = in_array($item['uid'], [0, local_user()]);
176 // Editing on items of not subscribed users isn't currently possible
177 // There are some issues on editing that prevent this.
178 // But also it is an issue of the supported protocols that doesn't allow editing at all.
179 if ($item['uid'] == 0) {
183 if (($this->getDataValue('uid') == local_user()) || $this->isVisiting()) {
187 $origin = $item['origin'];
190 /// @todo This shouldn't be done as query here, but better during the data creation.
191 // it is now done here, since during the RC phase we shouldn't make to intense changes.
192 $parent = Item::selectFirst(['origin'], ['id' => $item['parent']]);
193 if (DBA::isResult($parent)) {
194 $origin = $parent['origin'];
196 } elseif ($item['pinned']) {
197 $pinned = L10n::t('pinned item');
200 if ($origin && ($item['id'] != $item['parent']) && ($item['network'] == Protocol::ACTIVITYPUB)) {
201 // ActivityPub doesn't allow removal of remote comments
202 $delete = L10n::t('Delete locally');
204 // Showing the one or the other text, depending upon if we can only hide it or really delete it.
205 $delete = $origin ? L10n::t('Delete globally') : L10n::t('Remove locally');
209 'dropping' => $dropping,
210 'pagedrop' => $item['pagedrop'],
211 'select' => L10n::t('Select'),
219 $filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? L10n::t("save to folder") : false);
221 $profile_name = $item['author-name'];
222 if (!empty($item['author-link']) && empty($item['author-name'])) {
223 $profile_name = $item['author-link'];
226 $author = ['uid' => 0, 'id' => $item['author-id'],
227 'network' => $item['author-network'], 'url' => $item['author-link']];
229 if (Session::isAuthenticated()) {
230 $profile_link = Contact::magicLinkByContact($author);
232 $profile_link = $item['author-link'];
235 if (strpos($profile_link, 'redir/') === 0) {
236 $sparkle = ' sparkle';
239 $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
240 Hook::callAll('render_location', $locate);
241 $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
243 // process action responses - e.g. like/dislike/attend/agree/whatever
244 $response_verbs = ['like', 'dislike', 'announce'];
248 if ($item['object-type'] === Activity\ObjectType::EVENT) {
249 $response_verbs[] = 'attendyes';
250 $response_verbs[] = 'attendno';
251 $response_verbs[] = 'attendmaybe';
252 if ($conv->isWritable()) {
254 $attend = [L10n::t('I will attend'), L10n::t('I will not attend'), L10n::t('I might attend')];
258 $responses = get_responses($conv_responses, $response_verbs, $item, $this);
260 foreach ($response_verbs as $value => $verbs) {
261 $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']) : '';
265 * We should avoid doing this all the time, but it depends on the conversation mode
266 * And the conv mode may change when we change the conv, or it changes its mode
267 * Maybe we should establish a way to be notified about conversation changes
269 $this->checkWallToWall();
271 if ($this->isWallToWall() && ($this->getOwnerUrl() == $this->getRedirectUrl())) {
272 $osparkle = ' sparkle';
277 if ($this->isToplevel()) {
279 $thread = Item::selectFirstThreadForUser(local_user(), ['ignored'], ['iid' => $item['id']]);
280 if (DBA::isResult($thread)) {
282 'do' => L10n::t("ignore thread"),
283 'undo' => L10n::t("unignore thread"),
284 'toggle' => L10n::t("toggle ignore status"),
285 'classdo' => $thread['ignored'] ? "hidden" : "",
286 'classundo' => $thread['ignored'] ? "" : "hidden",
287 'ignored' => L10n::t('ignored'),
291 if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
293 $ispinned = ($item['pinned'] ? 'pinned' : 'unpinned');
296 'do' => L10n::t('pin'),
297 'undo' => L10n::t('unpin'),
298 'toggle' => L10n::t('toggle pin status'),
299 'classdo' => $item['pinned'] ? 'hidden' : '',
300 'classundo' => $item['pinned'] ? '' : 'hidden',
301 'pinned' => L10n::t('pinned'),
305 $isstarred = (($item['starred']) ? "starred" : "unstarred");
308 'do' => L10n::t("add star"),
309 'undo' => L10n::t("remove star"),
310 'toggle' => L10n::t("toggle star status"),
311 'classdo' => $item['starred'] ? "hidden" : "",
312 'classundo' => $item['starred'] ? "" : "hidden",
313 'starred' => L10n::t('starred'),
317 'add' => L10n::t("add tag"),
326 if ($conv->isWritable()) {
328 'like' => [L10n::t("I like this \x28toggle\x29"), L10n::t("like")],
329 'dislike' => [L10n::t("I don't like this \x28toggle\x29"), L10n::t("dislike")],
332 $buttons['share'] = [L10n::t('Share this'), L10n::t('share')];
336 $comment = $this->getCommentBox($indent);
338 if (strcmp(DateTimeFormat::utc($item['created']), DateTimeFormat::utc('now - 12 hours')) > 0) {
342 localize_item($item);
344 $body = Item::prepareBody($item, true);
346 /** @var ContentItem $contItem */
347 $contItem = self::getClass(ContentItem::class);
349 list($categories, $folders) = $contItem->determineCategoriesTerms($item);
352 $text_e = strip_tags($body);
353 $name_e = $profile_name;
355 if (!empty($item['content-warning']) && PConfig::get(local_user(), 'system', 'disable_cw', false)) {
356 $title_e = ucfirst($item['content-warning']);
358 $title_e = $item['title'];
361 $location_e = $location;
362 $owner_name_e = $this->getOwnerName();
364 // Disable features that aren't available in several networks
365 if (!in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA]) && isset($buttons["dislike"])) {
366 unset($buttons["dislike"]);
371 if (($item["network"] == Protocol::FEED) && isset($buttons["like"])) {
372 unset($buttons["like"]);
375 if (($item["network"] == Protocol::MAIL) && isset($buttons["like"])) {
376 unset($buttons["like"]);
379 $tags = Term::populateTagsFromItem($item);
381 $ago = Temporal::getRelativeDate($item['created']);
382 $ago_received = Temporal::getRelativeDate($item['received']);
383 if (Config::get('system', 'show_received') && (abs(strtotime($item['created']) - strtotime($item['received'])) > Config::get('system', 'show_received_seconds')) && ($ago != $ago_received)) {
384 $ago = L10n::t('%s (Received %s)', $ago, $ago_received);
388 'template' => $this->getTemplate(),
389 'type' => implode("", array_slice(explode("/", $item['verb']), -1)),
390 'suppress_tags' => Config::get('system', 'suppress_tags'),
391 'tags' => $tags['tags'],
392 'hashtags' => $tags['hashtags'],
393 'mentions' => $tags['mentions'],
394 'implicit_mentions' => $tags['implicit_mentions'],
395 'txt_cats' => L10n::t('Categories:'),
396 'txt_folders' => L10n::t('Filed under:'),
397 'has_cats' => ((count($categories)) ? 'true' : ''),
398 'has_folders' => ((count($folders)) ? 'true' : ''),
399 'categories' => $categories,
400 'folders' => $folders,
403 'id' => $this->getId(),
404 'guid' => urlencode($item['guid']),
405 'isevent' => $isevent,
407 'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
408 'olinktitle' => L10n::t('View %s\'s profile @ %s', $this->getOwnerName(), $item['owner-link']),
409 'to' => L10n::t('to'),
410 'via' => L10n::t('via'),
411 'wall' => L10n::t('Wall-to-Wall'),
412 'vwall' => L10n::t('via Wall-To-Wall:'),
413 'profile_url' => $profile_link,
414 'item_photo_menu' => item_photo_menu($item),
416 'thumb' => $a->removeBaseURL(ProxyUtils::proxifyUrl($item['author-avatar'], false, ProxyUtils::SIZE_THUMB)),
417 'osparkle' => $osparkle,
418 'sparkle' => $sparkle,
420 'localtime' => DateTimeFormat::local($item['created'], 'r'),
421 'ago' => $item['app'] ? L10n::t('%s from %s', $ago, $item['app']) : $ago,
422 'app' => $item['app'],
423 'created' => Temporal::getRelativeDate($item['created']),
425 'location' => $location_e,
428 'owner_self' => $item['author-link'] == Session::get('my_url'),
429 'owner_url' => $this->getOwnerUrl(),
430 'owner_photo' => $a->removeBaseURL(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
431 'owner_name' => $owner_name_e,
432 'plink' => Item::getPlink($item),
434 'ispinned' => $ispinned,
437 'isstarred' => $isstarred,
444 'like' => $responses['like']['output'],
445 'dislike' => $responses['dislike']['output'],
446 'responses' => $responses,
447 'switchcomment' => L10n::t('Comment'),
448 'reply_label' => L10n::t('Reply to %s', $name_e),
449 'comment' => $comment,
450 'previewing' => $conv->isPreview() ? ' preview ' : '',
451 'wait' => L10n::t('Please wait'),
452 'thread_level' => $thread_level,
454 'network' => $item["network"],
455 'network_name' => ContactSelector::networkToName($item['network'], $item['author-link']),
456 'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']),
457 'received' => $item['received'],
458 'commented' => $item['commented'],
459 'created_date' => $item['created'],
460 'return' => ($a->cmd) ? bin2hex($a->cmd) : '',
462 'queue_count' => $item['delivery_queue_count'],
463 'queue_done' => $item['delivery_queue_done'] + $item['delivery_queue_failed'], /// @todo Possibly display it separately in the future
464 'notifier_pending' => L10n::t('Notifier task is pending'),
465 'delivery_pending' => L10n::t('Delivery to remote servers is pending'),
466 'delivery_underway' => L10n::t('Delivery to remote servers is underway'),
467 'delivery_almost' => L10n::t('Delivery to remote servers is mostly done'),
468 'delivery_done' => L10n::t('Delivery to remote servers is done'),
472 $arr = ['item' => $item, 'output' => $tmp_item];
473 Hook::callAll('display_item', $arr);
475 $result = $arr['output'];
477 $result['children'] = [];
478 $children = $this->getChildren();
479 $nb_children = count($children);
480 if ($nb_children > 0) {
481 foreach ($children as $child) {
482 $result['children'][] = $child->getTemplateData($conv_responses, $thread_level + 1);
486 if (($nb_children > 2) || ($thread_level > 1)) {
487 $result['children'][0]['comment_firstcollapsed'] = true;
488 $result['children'][0]['num_comments'] = L10n::tt('%d comment', '%d comments', $total_children);
489 $result['children'][0]['show_text'] = L10n::t('Show more');
490 $result['children'][0]['hide_text'] = L10n::t('Show fewer');
491 if ($thread_level > 1) {
492 $result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
494 $result['children'][$nb_children - 3]['comment_lastcollapsed'] = true;
499 if ($this->isToplevel()) {
500 $result['total_comments_num'] = "$total_children";
501 $result['total_comments_text'] = L10n::tt('comment', 'comments', $total_children);
504 $result['private'] = $item['private'];
505 $result['toplevel'] = ($this->isToplevel() ? 'toplevel_item' : '');
507 if ($this->isThreaded()) {
508 $result['flatten'] = false;
509 $result['threaded'] = true;
511 $result['flatten'] = true;
512 $result['threaded'] = false;
521 public function getId()
523 return $this->getDataValue('id');
529 public function isThreaded()
531 return $this->threaded;
537 * @param Post $item The child item to add
542 public function addChild(Post $item)
544 $item_id = $item->getId();
546 Logger::log('[ERROR] Post::addChild : Item has no ID!!', Logger::DEBUG);
548 } elseif ($this->getChild($item->getId())) {
549 Logger::log('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').', Logger::DEBUG);
553 /** @var Activity $activity */
554 $activity = self::getClass(Activity::class);
557 * Only add what will be displayed
559 if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
561 } elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) ||
562 $activity->match($item->getDataValue('verb'), Activity::DISLIKE)) {
566 $item->setParent($this);
567 $this->children[] = $item;
569 return end($this->children);
573 * Get a child by its ID
575 * @param integer $id The child id
579 public function getChild($id)
581 foreach ($this->getChildren() as $child) {
582 if ($child->getId() == $id) {
591 * Get all our children
595 public function getChildren()
597 return $this->children;
603 * @param Post $item The item to set as parent
607 protected function setParent(Post $item)
609 $parent = $this->getParent();
611 $parent->removeChild($this);
614 $this->parent = $item;
615 $this->setThread($item->getThread());
623 protected function removeParent()
625 $this->parent = null;
626 $this->thread = null;
632 * @param Post $item The child to be removed
634 * @return boolean Success or failure
637 public function removeChild(Post $item)
639 $id = $item->getId();
640 foreach ($this->getChildren() as $key => $child) {
641 if ($child->getId() == $id) {
642 $child->removeParent();
643 unset($this->children[$key]);
644 // Reindex the array, in order to make sure there won't be any trouble on loops using count()
645 $this->children = array_values($this->children);
649 Logger::log('[WARN] Item::removeChild : Item is not a child (' . $id . ').', Logger::DEBUG);
658 protected function getParent()
660 return $this->parent;
664 * Set conversation thread
666 * @param Thread $thread
670 public function setThread(Thread $thread = null)
672 $this->thread = $thread;
674 // Set it on our children too
675 foreach ($this->getChildren() as $child) {
676 $child->setThread($thread);
685 public function getThread()
687 return $this->thread;
693 * We shouldn't need this
697 public function getData()
705 * @param string $name key
707 * @return mixed value on success
710 public function getDataValue($name)
712 if (!isset($this->data[$name])) {
713 // Logger::log('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".', Logger::DEBUG);
717 return $this->data[$name];
723 * @param string $name template name
727 private function setTemplate($name)
729 if (empty($this->available_templates[$name])) {
730 Logger::log('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', Logger::DEBUG);
734 $this->template = $this->available_templates[$name];
744 private function getTemplate()
746 return $this->template;
750 * Check if this is a toplevel post
754 private function isToplevel()
756 return $this->toplevel;
760 * Check if this is writable
764 private function isWritable()
766 $conv = $this->getThread();
769 // This will allow us to comment on wall-to-wall items owned by our friends
770 // and community forums even if somebody else wrote the post.
771 // bug #517 - this fixes for conversation owner
772 if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == local_user()) {
776 // this fixes for visitors
777 return ($this->writable || ($this->isVisiting() && $conv->getMode() == 'profile'));
779 return $this->writable;
783 * Count the total of our descendants
787 private function countDescendants()
789 $children = $this->getChildren();
790 $total = count($children);
792 foreach ($children as $child) {
793 $total += $child->countDescendants();
801 * Get the template for the comment box
805 private function getCommentBoxTemplate()
807 return $this->comment_box_template;
811 * Get default text for the comment box
814 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
816 private function getDefaultText()
824 $owner = User::getOwnerDataById($a->user['uid']);
826 if (!Feature::isEnabled(local_user(), 'explicit_mentions')) {
830 $item = Item::selectFirst(['author-addr'], ['id' => $this->getId()]);
831 if (!DBA::isResult($item) || empty($item['author-addr'])) {
836 if ($item['author-addr'] != $owner['addr']) {
837 $text = '@' . $item['author-addr'] . ' ';
842 $terms = Term::tagArrayFromItemId($this->getId(), [Term::MENTION, Term::IMPLICIT_MENTION]);
843 foreach ($terms as $term) {
844 $profile = Contact::getDetailsByURL($term['url']);
845 if (!empty($profile['addr']) && ((($profile['contact-type'] ?? '') ?: Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&
846 ($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) {
847 $text .= '@' . $profile['addr'] . ' ';
855 * Get the comment box
857 * @param string $indent Indent value
859 * @return mixed The comment box string (empty if no comment box)
863 private function getCommentBox($indent)
868 $conv = $this->getThread();
870 if (($conv->getMode() === 'network') && $this->isWallToWall()) {
874 if ($conv->isWritable() && $this->isWritable()) {
878 * Hmmm, code depending on the presence of a particular addon?
879 * This should be better if done by a hook
881 if (Addon::isEnabled('qcomment')) {
882 $qc = ((local_user()) ? PConfig::get(local_user(), 'qcomment', 'words') : null);
883 $qcomment = (($qc) ? explode("\n", $qc) : null);
886 // Fetch the user id from the parent when the owner user is empty
887 $uid = $conv->getProfileOwner();
888 $parent_uid = $this->getDataValue('uid');
890 $default_text = $this->getDefaultText();
892 if (!is_null($parent_uid) && ($uid != $parent_uid)) {
896 $template = Renderer::getMarkupTemplate($this->getCommentBoxTemplate());
897 $comment_box = Renderer::replaceMacros($template, [
898 '$return_path' => $a->query_string,
899 '$threaded' => $this->isThreaded(),
901 '$wall' => ($conv->getMode() === 'profile'),
902 '$id' => $this->getId(),
903 '$parent' => $this->getId(),
904 '$qcomment' => $qcomment,
905 '$default' => $default_text,
906 '$profile_uid' => $uid,
907 '$mylink' => $a->removeBaseURL($a->contact['url']),
908 '$mytitle' => L10n::t('This is you'),
909 '$myphoto' => $a->removeBaseURL($a->contact['thumb']),
910 '$comment' => L10n::t('Comment'),
911 '$submit' => L10n::t('Submit'),
912 '$edbold' => L10n::t('Bold'),
913 '$editalic' => L10n::t('Italic'),
914 '$eduline' => L10n::t('Underline'),
915 '$edquote' => L10n::t('Quote'),
916 '$edcode' => L10n::t('Code'),
917 '$edimg' => L10n::t('Image'),
918 '$edurl' => L10n::t('Link'),
919 '$edattach' => L10n::t('Link or Media'),
920 '$prompttext' => L10n::t('Please enter a image/video/audio/webpage URL:'),
921 '$preview' => L10n::t('Preview'),
922 '$indent' => $indent,
923 '$sourceapp' => L10n::t($a->sourcename),
924 '$ww' => $conv->getMode() === 'network' ? $ww : '',
925 '$rand_num' => Crypto::randomDigits(12)
935 private function getRedirectUrl()
937 return $this->redirect_url;
941 * Check if we are a wall to wall item and set the relevant properties
946 protected function checkWallToWall()
949 $conv = $this->getThread();
950 $this->wall_to_wall = false;
952 if ($this->isToplevel()) {
953 if ($conv->getMode() !== 'profile') {
954 if ($this->getDataValue('wall') && !$this->getDataValue('self')) {
955 // On the network page, I am the owner. On the display page it will be the profile owner.
956 // This will have been stored in $a->page_contact by our calling page.
957 // Put this person as the wall owner of the wall-to-wall notice.
959 $this->owner_url = Contact::magicLink($a->page_contact['url']);
960 $this->owner_photo = $a->page_contact['thumb'];
961 $this->owner_name = $a->page_contact['name'];
962 $this->wall_to_wall = true;
963 } elseif ($this->getDataValue('owner-link')) {
964 $owner_linkmatch = (($this->getDataValue('owner-link')) && Strings::compareLink($this->getDataValue('owner-link'), $this->getDataValue('author-link')));
965 $alias_linkmatch = (($this->getDataValue('alias')) && Strings::compareLink($this->getDataValue('alias'), $this->getDataValue('author-link')));
966 $owner_namematch = (($this->getDataValue('owner-name')) && $this->getDataValue('owner-name') == $this->getDataValue('author-name'));
968 if (!$owner_linkmatch && !$alias_linkmatch && !$owner_namematch) {
969 // The author url doesn't match the owner (typically the contact)
970 // and also doesn't match the contact alias.
971 // The name match is a hack to catch several weird cases where URLs are
972 // all over the park. It can be tricked, but this prevents you from
973 // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
974 // well that it's the same Bob Smith.
975 // But it could be somebody else with the same name. It just isn't highly likely.
978 $this->owner_photo = $this->getDataValue('owner-avatar');
979 $this->owner_name = $this->getDataValue('owner-name');
980 $this->wall_to_wall = true;
982 $owner = ['uid' => 0, 'id' => $this->getDataValue('owner-id'),
983 'network' => $this->getDataValue('owner-network'),
984 'url' => $this->getDataValue('owner-link')];
985 $this->owner_url = Contact::magicLinkByContact($owner);
991 if (!$this->wall_to_wall) {
992 $this->setTemplate('wall');
993 $this->owner_url = '';
994 $this->owner_photo = '';
995 $this->owner_name = '';
1002 private function isWallToWall()
1004 return $this->wall_to_wall;
1010 private function getOwnerUrl()
1012 return $this->owner_url;
1018 private function getOwnerName()
1020 return $this->owner_name;
1026 private function isVisiting()
1028 return $this->visiting;