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\Hook;
11 use Friendica\Core\Logger;
12 use Friendica\Core\Protocol;
13 use Friendica\Core\Renderer;
14 use Friendica\Core\Session;
15 use Friendica\Database\DBA;
17 use Friendica\Model\Contact;
18 use Friendica\Model\Item;
19 use Friendica\Model\Term;
20 use Friendica\Model\User;
21 use Friendica\Protocol\Activity;
22 use Friendica\Util\Crypto;
23 use Friendica\Util\DateTimeFormat;
24 use Friendica\Util\Proxy as ProxyUtils;
25 use Friendica\Util\Strings;
26 use Friendica\Util\Temporal;
34 private $template = null;
35 private $available_templates = [
36 'wall' => 'wall_thread.tpl',
37 'wall2wall' => 'wallwall_thread.tpl'
39 private $comment_box_template = 'comment_item.tpl';
40 private $toplevel = false;
41 private $writable = false;
45 private $children = [];
46 private $parent = null;
51 private $thread = null;
52 private $redirect_url = null;
53 private $owner_url = '';
54 private $owner_photo = '';
55 private $owner_name = '';
56 private $wall_to_wall = false;
57 private $threaded = false;
58 private $visiting = false;
63 * @param array $data data array
66 public function __construct(array $data)
69 $this->setTemplate('wall');
70 $this->toplevel = $this->getId() == $this->getDataValue('parent');
72 if (!empty(Session::getUserIDForVisitorContactID($this->getDataValue('contact-id')))) {
73 $this->visiting = true;
76 $this->writable = $this->getDataValue('writable') || $this->getDataValue('self');
77 $author = ['uid' => 0, 'id' => $this->getDataValue('author-id'),
78 'network' => $this->getDataValue('author-network'),
79 'url' => $this->getDataValue('author-link')];
80 $this->redirect_url = Contact::magicLinkByContact($author);
81 if (!$this->isToplevel()) {
82 $this->threaded = true;
85 // Prepare the children
86 if (!empty($data['children'])) {
87 foreach ($data['children'] as $item) {
88 // Only add will be displayed
89 if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
91 } elseif (!visible_activity($item)) {
95 // You can always comment on Diaspora and OStatus items
96 if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (local_user() == $item['uid'])) {
97 $item['writable'] = true;
100 $item['pagedrop'] = $data['pagedrop'];
101 $child = new Post($item);
102 $this->addChild($child);
108 * Get data in a form usable by a conversation template
110 * @param array $conv_responses conversation responses
111 * @param integer $thread_level default = 1
113 * @return mixed The data requested on success
115 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
116 * @throws \ImagickException
118 public function getTemplateData(array $conv_responses, $thread_level = 1)
122 $item = $this->getData();
124 // If the time between "created" and "edited" differs we add
125 // a notice that the post was edited.
126 // Note: In some networks reshared items seem to have (sometimes) a difference
127 // between creation time and edit time of a second. Thats why we add the notice
128 // only if the difference is more than 1 second.
129 if (strtotime($item['edited']) - strtotime($item['created']) > 1) {
131 'label' => DI::l10n()->t('This entry was edited'),
132 'date' => DateTimeFormat::local($item['edited'], 'r'),
133 'relative' => Temporal::getRelativeDate($item['edited'])
143 $ispinned = "unpinned";
144 $isstarred = "unstarred";
148 $total_children = $this->countDescendants();
150 $conv = $this->getThread();
152 $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
153 || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
154 ? DI::l10n()->t('Private Message')
157 $shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != 1;
162 if (Strings::compareLink($a->contact['url'], $item['author-link'])) {
163 if ($item["event-id"] != 0) {
164 $edpost = ["events/event/" . $item['event-id'], DI::l10n()->t("Edit")];
166 $edpost = ["editpost/" . $item['id'], DI::l10n()->t("Edit")];
169 $dropping = in_array($item['uid'], [0, local_user()]);
172 // Editing on items of not subscribed users isn't currently possible
173 // There are some issues on editing that prevent this.
174 // But also it is an issue of the supported protocols that doesn't allow editing at all.
175 if ($item['uid'] == 0) {
179 if (($this->getDataValue('uid') == local_user()) || $this->isVisiting()) {
183 $origin = $item['origin'];
186 /// @todo This shouldn't be done as query here, but better during the data creation.
187 // it is now done here, since during the RC phase we shouldn't make to intense changes.
188 $parent = Item::selectFirst(['origin'], ['id' => $item['parent']]);
189 if (DBA::isResult($parent)) {
190 $origin = $parent['origin'];
192 } elseif ($item['pinned']) {
193 $pinned = DI::l10n()->t('pinned item');
196 if ($origin && ($item['id'] != $item['parent']) && ($item['network'] == Protocol::ACTIVITYPUB)) {
197 // ActivityPub doesn't allow removal of remote comments
198 $delete = DI::l10n()->t('Delete locally');
200 // Showing the one or the other text, depending upon if we can only hide it or really delete it.
201 $delete = $origin ? DI::l10n()->t('Delete globally') : DI::l10n()->t('Remove locally');
205 'dropping' => $dropping,
206 'pagedrop' => $item['pagedrop'],
207 'select' => DI::l10n()->t('Select'),
215 $filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? DI::l10n()->t("save to folder") : false);
217 $profile_name = $item['author-name'];
218 if (!empty($item['author-link']) && empty($item['author-name'])) {
219 $profile_name = $item['author-link'];
222 $author = ['uid' => 0, 'id' => $item['author-id'],
223 'network' => $item['author-network'], 'url' => $item['author-link']];
225 if (Session::isAuthenticated()) {
226 $profile_link = Contact::magicLinkByContact($author);
228 $profile_link = $item['author-link'];
231 if (strpos($profile_link, 'redir/') === 0) {
232 $sparkle = ' sparkle';
235 $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
236 Hook::callAll('render_location', $locate);
237 $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
239 // process action responses - e.g. like/dislike/attend/agree/whatever
240 $response_verbs = ['like', 'dislike', 'announce'];
244 if ($item['object-type'] === Activity\ObjectType::EVENT) {
245 $response_verbs[] = 'attendyes';
246 $response_verbs[] = 'attendno';
247 $response_verbs[] = 'attendmaybe';
248 if ($conv->isWritable()) {
250 $attend = [DI::l10n()->t('I will attend'), DI::l10n()->t('I will not attend'), DI::l10n()->t('I might attend')];
254 $responses = get_responses($conv_responses, $response_verbs, $item, $this);
256 foreach ($response_verbs as $value => $verbs) {
257 $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']) : '';
261 * We should avoid doing this all the time, but it depends on the conversation mode
262 * And the conv mode may change when we change the conv, or it changes its mode
263 * Maybe we should establish a way to be notified about conversation changes
265 $this->checkWallToWall();
267 if ($this->isWallToWall() && ($this->getOwnerUrl() == $this->getRedirectUrl())) {
268 $osparkle = ' sparkle';
273 if ($this->isToplevel()) {
275 $thread = Item::selectFirstThreadForUser(local_user(), ['ignored'], ['iid' => $item['id']]);
276 if (DBA::isResult($thread)) {
278 'do' => DI::l10n()->t("ignore thread"),
279 'undo' => DI::l10n()->t("unignore thread"),
280 'toggle' => DI::l10n()->t("toggle ignore status"),
281 'classdo' => $thread['ignored'] ? "hidden" : "",
282 'classundo' => $thread['ignored'] ? "" : "hidden",
283 'ignored' => DI::l10n()->t('ignored'),
287 if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
289 $ispinned = ($item['pinned'] ? 'pinned' : 'unpinned');
292 'do' => DI::l10n()->t('pin'),
293 'undo' => DI::l10n()->t('unpin'),
294 'toggle' => DI::l10n()->t('toggle pin status'),
295 'classdo' => $item['pinned'] ? 'hidden' : '',
296 'classundo' => $item['pinned'] ? '' : 'hidden',
297 'pinned' => DI::l10n()->t('pinned'),
301 $isstarred = (($item['starred']) ? "starred" : "unstarred");
304 'do' => DI::l10n()->t("add star"),
305 'undo' => DI::l10n()->t("remove star"),
306 'toggle' => DI::l10n()->t("toggle star status"),
307 'classdo' => $item['starred'] ? "hidden" : "",
308 'classundo' => $item['starred'] ? "" : "hidden",
309 'starred' => DI::l10n()->t('starred'),
313 'add' => DI::l10n()->t("add tag"),
322 if ($conv->isWritable()) {
324 'like' => [DI::l10n()->t("I like this \x28toggle\x29"), DI::l10n()->t("like")],
325 'dislike' => [DI::l10n()->t("I don't like this \x28toggle\x29"), DI::l10n()->t("dislike")],
328 $buttons['share'] = [DI::l10n()->t('Share this'), DI::l10n()->t('share')];
332 $comment = $this->getCommentBox($indent);
334 if (strcmp(DateTimeFormat::utc($item['created']), DateTimeFormat::utc('now - 12 hours')) > 0) {
338 localize_item($item);
340 $body = Item::prepareBody($item, true);
342 list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);
345 $text_e = strip_tags($body);
346 $name_e = $profile_name;
348 if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) {
349 $title_e = ucfirst($item['content-warning']);
351 $title_e = $item['title'];
354 $location_e = $location;
355 $owner_name_e = $this->getOwnerName();
357 // Disable features that aren't available in several networks
358 if (!in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA]) && isset($buttons["dislike"])) {
359 unset($buttons["dislike"]);
364 if (($item["network"] == Protocol::FEED) && isset($buttons["like"])) {
365 unset($buttons["like"]);
368 if (($item["network"] == Protocol::MAIL) && isset($buttons["like"])) {
369 unset($buttons["like"]);
372 $tags = Term::populateTagsFromItem($item);
374 $ago = Temporal::getRelativeDate($item['created']);
375 $ago_received = Temporal::getRelativeDate($item['received']);
376 if (DI::config()->get('system', 'show_received') && (abs(strtotime($item['created']) - strtotime($item['received'])) > DI::config()->get('system', 'show_received_seconds')) && ($ago != $ago_received)) {
377 $ago = DI::l10n()->t('%s (Received %s)', $ago, $ago_received);
381 'template' => $this->getTemplate(),
382 'type' => implode("", array_slice(explode("/", $item['verb']), -1)),
383 'suppress_tags' => DI::config()->get('system', 'suppress_tags'),
384 'tags' => $tags['tags'],
385 'hashtags' => $tags['hashtags'],
386 'mentions' => $tags['mentions'],
387 'implicit_mentions' => $tags['implicit_mentions'],
388 'txt_cats' => DI::l10n()->t('Categories:'),
389 'txt_folders' => DI::l10n()->t('Filed under:'),
390 'has_cats' => ((count($categories)) ? 'true' : ''),
391 'has_folders' => ((count($folders)) ? 'true' : ''),
392 'categories' => $categories,
393 'folders' => $folders,
396 'id' => $this->getId(),
397 'guid' => urlencode($item['guid']),
398 'isevent' => $isevent,
400 'linktitle' => DI::l10n()->t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
401 'olinktitle' => DI::l10n()->t('View %s\'s profile @ %s', $this->getOwnerName(), $item['owner-link']),
402 'to' => DI::l10n()->t('to'),
403 'via' => DI::l10n()->t('via'),
404 'wall' => DI::l10n()->t('Wall-to-Wall'),
405 'vwall' => DI::l10n()->t('via Wall-To-Wall:'),
406 'profile_url' => $profile_link,
407 'item_photo_menu' => item_photo_menu($item),
409 'thumb' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['author-avatar'], false, ProxyUtils::SIZE_THUMB)),
410 'osparkle' => $osparkle,
411 'sparkle' => $sparkle,
413 'localtime' => DateTimeFormat::local($item['created'], 'r'),
414 'ago' => $item['app'] ? DI::l10n()->t('%s from %s', $ago, $item['app']) : $ago,
415 'app' => $item['app'],
418 'location' => $location_e,
421 'owner_self' => $item['author-link'] == Session::get('my_url'),
422 'owner_url' => $this->getOwnerUrl(),
423 'owner_photo' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
424 'owner_name' => $owner_name_e,
425 'plink' => Item::getPlink($item),
427 'ispinned' => $ispinned,
430 'isstarred' => $isstarred,
437 'like' => $responses['like']['output'],
438 'dislike' => $responses['dislike']['output'],
439 'responses' => $responses,
440 'switchcomment' => DI::l10n()->t('Comment'),
441 'reply_label' => DI::l10n()->t('Reply to %s', $name_e),
442 'comment' => $comment,
443 'previewing' => $conv->isPreview() ? ' preview ' : '',
444 'wait' => DI::l10n()->t('Please wait'),
445 'thread_level' => $thread_level,
447 'network' => $item["network"],
448 'network_name' => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network']),
449 'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']),
450 'received' => $item['received'],
451 'commented' => $item['commented'],
452 'created_date' => $item['created'],
453 'return' => (DI::args()->getCommand()) ? bin2hex(DI::args()->getCommand()) : '',
455 'queue_count' => $item['delivery_queue_count'],
456 'queue_done' => $item['delivery_queue_done'] + $item['delivery_queue_failed'], /// @todo Possibly display it separately in the future
457 'notifier_pending' => DI::l10n()->t('Notifier task is pending'),
458 'delivery_pending' => DI::l10n()->t('Delivery to remote servers is pending'),
459 'delivery_underway' => DI::l10n()->t('Delivery to remote servers is underway'),
460 'delivery_almost' => DI::l10n()->t('Delivery to remote servers is mostly done'),
461 'delivery_done' => DI::l10n()->t('Delivery to remote servers is done'),
465 $arr = ['item' => $item, 'output' => $tmp_item];
466 Hook::callAll('display_item', $arr);
468 $result = $arr['output'];
470 $result['children'] = [];
471 $children = $this->getChildren();
472 $nb_children = count($children);
473 if ($nb_children > 0) {
474 foreach ($children as $child) {
475 $result['children'][] = $child->getTemplateData($conv_responses, $thread_level + 1);
479 if (($nb_children > 2) || ($thread_level > 1)) {
480 $result['children'][0]['comment_firstcollapsed'] = true;
481 $result['children'][0]['num_comments'] = DI::l10n()->tt('%d comment', '%d comments', $total_children);
482 $result['children'][0]['show_text'] = DI::l10n()->t('Show more');
483 $result['children'][0]['hide_text'] = DI::l10n()->t('Show fewer');
484 if ($thread_level > 1) {
485 $result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
487 $result['children'][$nb_children - 3]['comment_lastcollapsed'] = true;
492 if ($this->isToplevel()) {
493 $result['total_comments_num'] = "$total_children";
494 $result['total_comments_text'] = DI::l10n()->tt('comment', 'comments', $total_children);
497 $result['private'] = $item['private'];
498 $result['toplevel'] = ($this->isToplevel() ? 'toplevel_item' : '');
500 if ($this->isThreaded()) {
501 $result['flatten'] = false;
502 $result['threaded'] = true;
504 $result['flatten'] = true;
505 $result['threaded'] = false;
514 public function getId()
516 return $this->getDataValue('id');
522 public function isThreaded()
524 return $this->threaded;
530 * @param Post $item The child item to add
535 public function addChild(Post $item)
537 $item_id = $item->getId();
539 Logger::log('[ERROR] Post::addChild : Item has no ID!!', Logger::DEBUG);
541 } elseif ($this->getChild($item->getId())) {
542 Logger::log('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').', Logger::DEBUG);
546 $activity = DI::activity();
549 * Only add what will be displayed
551 if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
553 } elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) ||
554 $activity->match($item->getDataValue('verb'), Activity::DISLIKE)) {
558 $item->setParent($this);
559 $this->children[] = $item;
561 return end($this->children);
565 * Get a child by its ID
567 * @param integer $id The child id
571 public function getChild($id)
573 foreach ($this->getChildren() as $child) {
574 if ($child->getId() == $id) {
583 * Get all our children
587 public function getChildren()
589 return $this->children;
595 * @param Post $item The item to set as parent
599 protected function setParent(Post $item)
601 $parent = $this->getParent();
603 $parent->removeChild($this);
606 $this->parent = $item;
607 $this->setThread($item->getThread());
615 protected function removeParent()
617 $this->parent = null;
618 $this->thread = null;
624 * @param Post $item The child to be removed
626 * @return boolean Success or failure
629 public function removeChild(Post $item)
631 $id = $item->getId();
632 foreach ($this->getChildren() as $key => $child) {
633 if ($child->getId() == $id) {
634 $child->removeParent();
635 unset($this->children[$key]);
636 // Reindex the array, in order to make sure there won't be any trouble on loops using count()
637 $this->children = array_values($this->children);
641 Logger::log('[WARN] Item::removeChild : Item is not a child (' . $id . ').', Logger::DEBUG);
650 protected function getParent()
652 return $this->parent;
656 * Set conversation thread
658 * @param Thread $thread
662 public function setThread(Thread $thread = null)
664 $this->thread = $thread;
666 // Set it on our children too
667 foreach ($this->getChildren() as $child) {
668 $child->setThread($thread);
677 public function getThread()
679 return $this->thread;
685 * We shouldn't need this
689 public function getData()
697 * @param string $name key
699 * @return mixed value on success
702 public function getDataValue($name)
704 if (!isset($this->data[$name])) {
705 // Logger::log('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".', Logger::DEBUG);
709 return $this->data[$name];
715 * @param string $name template name
719 private function setTemplate($name)
721 if (empty($this->available_templates[$name])) {
722 Logger::log('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', Logger::DEBUG);
726 $this->template = $this->available_templates[$name];
736 private function getTemplate()
738 return $this->template;
742 * Check if this is a toplevel post
746 private function isToplevel()
748 return $this->toplevel;
752 * Check if this is writable
756 private function isWritable()
758 $conv = $this->getThread();
761 // This will allow us to comment on wall-to-wall items owned by our friends
762 // and community forums even if somebody else wrote the post.
763 // bug #517 - this fixes for conversation owner
764 if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == local_user()) {
768 // this fixes for visitors
769 return ($this->writable || ($this->isVisiting() && $conv->getMode() == 'profile'));
771 return $this->writable;
775 * Count the total of our descendants
779 private function countDescendants()
781 $children = $this->getChildren();
782 $total = count($children);
784 foreach ($children as $child) {
785 $total += $child->countDescendants();
793 * Get the template for the comment box
797 private function getCommentBoxTemplate()
799 return $this->comment_box_template;
803 * Get default text for the comment box
806 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
808 private function getDefaultText()
816 $owner = User::getOwnerDataById($a->user['uid']);
818 if (!Feature::isEnabled(local_user(), 'explicit_mentions')) {
822 $item = Item::selectFirst(['author-addr'], ['id' => $this->getId()]);
823 if (!DBA::isResult($item) || empty($item['author-addr'])) {
828 if ($item['author-addr'] != $owner['addr']) {
829 $text = '@' . $item['author-addr'] . ' ';
834 $terms = Term::tagArrayFromItemId($this->getId(), [Term::MENTION, Term::IMPLICIT_MENTION]);
835 foreach ($terms as $term) {
836 $profile = Contact::getDetailsByURL($term['url']);
837 if (!empty($profile['addr']) && ((($profile['contact-type'] ?? '') ?: Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&
838 ($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) {
839 $text .= '@' . $profile['addr'] . ' ';
847 * Get the comment box
849 * @param string $indent Indent value
851 * @return mixed The comment box string (empty if no comment box)
855 private function getCommentBox($indent)
860 $conv = $this->getThread();
862 if (($conv->getMode() === 'network') && $this->isWallToWall()) {
866 if ($conv->isWritable() && $this->isWritable()) {
870 * Hmmm, code depending on the presence of a particular addon?
871 * This should be better if done by a hook
873 if (Addon::isEnabled('qcomment')) {
874 $qc = ((local_user()) ? DI::pConfig()->get(local_user(), 'qcomment', 'words') : null);
875 $qcomment = (($qc) ? explode("\n", $qc) : null);
878 // Fetch the user id from the parent when the owner user is empty
879 $uid = $conv->getProfileOwner();
880 $parent_uid = $this->getDataValue('uid');
882 $default_text = $this->getDefaultText();
884 if (!is_null($parent_uid) && ($uid != $parent_uid)) {
888 $template = Renderer::getMarkupTemplate($this->getCommentBoxTemplate());
889 $comment_box = Renderer::replaceMacros($template, [
890 '$return_path' => DI::args()->getQueryString(),
891 '$threaded' => $this->isThreaded(),
893 '$wall' => ($conv->getMode() === 'profile'),
894 '$id' => $this->getId(),
895 '$parent' => $this->getId(),
896 '$qcomment' => $qcomment,
897 '$default' => $default_text,
898 '$profile_uid' => $uid,
899 '$mylink' => DI::baseUrl()->remove($a->contact['url']),
900 '$mytitle' => DI::l10n()->t('This is you'),
901 '$myphoto' => DI::baseUrl()->remove($a->contact['thumb']),
902 '$comment' => DI::l10n()->t('Comment'),
903 '$submit' => DI::l10n()->t('Submit'),
904 '$edbold' => DI::l10n()->t('Bold'),
905 '$editalic' => DI::l10n()->t('Italic'),
906 '$eduline' => DI::l10n()->t('Underline'),
907 '$edquote' => DI::l10n()->t('Quote'),
908 '$edcode' => DI::l10n()->t('Code'),
909 '$edimg' => DI::l10n()->t('Image'),
910 '$edurl' => DI::l10n()->t('Link'),
911 '$edattach' => DI::l10n()->t('Link or Media'),
912 '$prompttext' => DI::l10n()->t('Please enter a image/video/audio/webpage URL:'),
913 '$preview' => DI::l10n()->t('Preview'),
914 '$indent' => $indent,
915 '$sourceapp' => DI::l10n()->t($a->sourcename),
916 '$ww' => $conv->getMode() === 'network' ? $ww : '',
917 '$rand_num' => Crypto::randomDigits(12)
927 private function getRedirectUrl()
929 return $this->redirect_url;
933 * Check if we are a wall to wall item and set the relevant properties
938 protected function checkWallToWall()
941 $conv = $this->getThread();
942 $this->wall_to_wall = false;
944 if ($this->isToplevel()) {
945 if ($conv->getMode() !== 'profile') {
946 if ($this->getDataValue('wall') && !$this->getDataValue('self')) {
947 // On the network page, I am the owner. On the display page it will be the profile owner.
948 // This will have been stored in $a->page_contact by our calling page.
949 // Put this person as the wall owner of the wall-to-wall notice.
951 $this->owner_url = Contact::magicLink($a->page_contact['url']);
952 $this->owner_photo = $a->page_contact['thumb'];
953 $this->owner_name = $a->page_contact['name'];
954 $this->wall_to_wall = true;
955 } elseif ($this->getDataValue('owner-link')) {
956 $owner_linkmatch = (($this->getDataValue('owner-link')) && Strings::compareLink($this->getDataValue('owner-link'), $this->getDataValue('author-link')));
957 $alias_linkmatch = (($this->getDataValue('alias')) && Strings::compareLink($this->getDataValue('alias'), $this->getDataValue('author-link')));
958 $owner_namematch = (($this->getDataValue('owner-name')) && $this->getDataValue('owner-name') == $this->getDataValue('author-name'));
960 if (!$owner_linkmatch && !$alias_linkmatch && !$owner_namematch) {
961 // The author url doesn't match the owner (typically the contact)
962 // and also doesn't match the contact alias.
963 // The name match is a hack to catch several weird cases where URLs are
964 // all over the park. It can be tricked, but this prevents you from
965 // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
966 // well that it's the same Bob Smith.
967 // But it could be somebody else with the same name. It just isn't highly likely.
970 $this->owner_photo = $this->getDataValue('owner-avatar');
971 $this->owner_name = $this->getDataValue('owner-name');
972 $this->wall_to_wall = true;
974 $owner = ['uid' => 0, 'id' => $this->getDataValue('owner-id'),
975 'network' => $this->getDataValue('owner-network'),
976 'url' => $this->getDataValue('owner-link')];
977 $this->owner_url = Contact::magicLinkByContact($owner);
983 if (!$this->wall_to_wall) {
984 $this->setTemplate('wall');
985 $this->owner_url = '';
986 $this->owner_photo = '';
987 $this->owner_name = '';
994 private function isWallToWall()
996 return $this->wall_to_wall;
1002 private function getOwnerUrl()
1004 return $this->owner_url;
1010 private function getOwnerName()
1012 return $this->owner_name;
1018 private function isVisiting()
1020 return $this->visiting;