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\Protocol;
15 use Friendica\Core\Renderer;
16 use Friendica\Core\Session;
17 use Friendica\Database\DBA;
19 use Friendica\Model\Contact;
20 use Friendica\Model\Item;
21 use Friendica\Model\Term;
22 use Friendica\Model\User;
23 use Friendica\Protocol\Activity;
24 use Friendica\Util\Crypto;
25 use Friendica\Util\DateTimeFormat;
26 use Friendica\Util\Proxy as ProxyUtils;
27 use Friendica\Util\Strings;
28 use Friendica\Util\Temporal;
36 private $template = null;
37 private $available_templates = [
38 'wall' => 'wall_thread.tpl',
39 'wall2wall' => 'wallwall_thread.tpl'
41 private $comment_box_template = 'comment_item.tpl';
42 private $toplevel = false;
43 private $writable = false;
47 private $children = [];
48 private $parent = null;
53 private $thread = null;
54 private $redirect_url = null;
55 private $owner_url = '';
56 private $owner_photo = '';
57 private $owner_name = '';
58 private $wall_to_wall = false;
59 private $threaded = false;
60 private $visiting = false;
65 * @param array $data data array
68 public function __construct(array $data)
71 $this->setTemplate('wall');
72 $this->toplevel = $this->getId() == $this->getDataValue('parent');
74 if (!empty(Session::getUserIDForVisitorContactID($this->getDataValue('contact-id')))) {
75 $this->visiting = true;
78 $this->writable = $this->getDataValue('writable') || $this->getDataValue('self');
79 $author = ['uid' => 0, 'id' => $this->getDataValue('author-id'),
80 'network' => $this->getDataValue('author-network'),
81 'url' => $this->getDataValue('author-link')];
82 $this->redirect_url = Contact::magicLinkByContact($author);
83 if (!$this->isToplevel()) {
84 $this->threaded = true;
87 // Prepare the children
88 if (!empty($data['children'])) {
89 foreach ($data['children'] as $item) {
90 // Only add will be displayed
91 if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
93 } elseif (!visible_activity($item)) {
97 // You can always comment on Diaspora and OStatus items
98 if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (local_user() == $item['uid'])) {
99 $item['writable'] = true;
102 $item['pagedrop'] = $data['pagedrop'];
103 $child = new Post($item);
104 $this->addChild($child);
110 * Get data in a form usable by a conversation template
112 * @param array $conv_responses conversation responses
113 * @param integer $thread_level default = 1
115 * @return mixed The data requested on success
117 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
118 * @throws \ImagickException
120 public function getTemplateData(array $conv_responses, $thread_level = 1)
124 $item = $this->getData();
126 // If the time between "created" and "edited" differs we add
127 // a notice that the post was edited.
128 // Note: In some networks reshared items seem to have (sometimes) a difference
129 // between creation time and edit time of a second. Thats why we add the notice
130 // only if the difference is more than 1 second.
131 if (strtotime($item['edited']) - strtotime($item['created']) > 1) {
133 'label' => DI::l10n()->t('This entry was edited'),
134 'date' => DateTimeFormat::local($item['edited'], 'r'),
135 'relative' => Temporal::getRelativeDate($item['edited'])
145 $ispinned = "unpinned";
146 $isstarred = "unstarred";
150 $total_children = $this->countDescendants();
152 $conv = $this->getThread();
154 $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
155 || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
156 ? DI::l10n()->t('Private Message')
159 $shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != 1;
164 if (Strings::compareLink($a->contact['url'], $item['author-link'])) {
165 if ($item["event-id"] != 0) {
166 $edpost = ["events/event/" . $item['event-id'], DI::l10n()->t("Edit")];
168 $edpost = ["editpost/" . $item['id'], DI::l10n()->t("Edit")];
171 $dropping = in_array($item['uid'], [0, local_user()]);
174 // Editing on items of not subscribed users isn't currently possible
175 // There are some issues on editing that prevent this.
176 // But also it is an issue of the supported protocols that doesn't allow editing at all.
177 if ($item['uid'] == 0) {
181 if (($this->getDataValue('uid') == local_user()) || $this->isVisiting()) {
185 $origin = $item['origin'];
188 /// @todo This shouldn't be done as query here, but better during the data creation.
189 // it is now done here, since during the RC phase we shouldn't make to intense changes.
190 $parent = Item::selectFirst(['origin'], ['id' => $item['parent']]);
191 if (DBA::isResult($parent)) {
192 $origin = $parent['origin'];
194 } elseif ($item['pinned']) {
195 $pinned = DI::l10n()->t('pinned item');
198 if ($origin && ($item['id'] != $item['parent']) && ($item['network'] == Protocol::ACTIVITYPUB)) {
199 // ActivityPub doesn't allow removal of remote comments
200 $delete = DI::l10n()->t('Delete locally');
202 // Showing the one or the other text, depending upon if we can only hide it or really delete it.
203 $delete = $origin ? DI::l10n()->t('Delete globally') : DI::l10n()->t('Remove locally');
207 'dropping' => $dropping,
208 'pagedrop' => $item['pagedrop'],
209 'select' => DI::l10n()->t('Select'),
217 $filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? DI::l10n()->t("save to folder") : false);
219 $profile_name = $item['author-name'];
220 if (!empty($item['author-link']) && empty($item['author-name'])) {
221 $profile_name = $item['author-link'];
224 $author = ['uid' => 0, 'id' => $item['author-id'],
225 'network' => $item['author-network'], 'url' => $item['author-link']];
227 if (Session::isAuthenticated()) {
228 $profile_link = Contact::magicLinkByContact($author);
230 $profile_link = $item['author-link'];
233 if (strpos($profile_link, 'redir/') === 0) {
234 $sparkle = ' sparkle';
237 $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
238 Hook::callAll('render_location', $locate);
239 $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
241 // process action responses - e.g. like/dislike/attend/agree/whatever
242 $response_verbs = ['like', 'dislike', 'announce'];
246 if ($item['object-type'] === Activity\ObjectType::EVENT) {
247 $response_verbs[] = 'attendyes';
248 $response_verbs[] = 'attendno';
249 $response_verbs[] = 'attendmaybe';
250 if ($conv->isWritable()) {
252 $attend = [DI::l10n()->t('I will attend'), DI::l10n()->t('I will not attend'), DI::l10n()->t('I might attend')];
256 $responses = get_responses($conv_responses, $response_verbs, $item, $this);
258 foreach ($response_verbs as $value => $verbs) {
259 $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']) : '';
263 * We should avoid doing this all the time, but it depends on the conversation mode
264 * And the conv mode may change when we change the conv, or it changes its mode
265 * Maybe we should establish a way to be notified about conversation changes
267 $this->checkWallToWall();
269 if ($this->isWallToWall() && ($this->getOwnerUrl() == $this->getRedirectUrl())) {
270 $osparkle = ' sparkle';
275 if ($this->isToplevel()) {
277 $thread = Item::selectFirstThreadForUser(local_user(), ['ignored'], ['iid' => $item['id']]);
278 if (DBA::isResult($thread)) {
280 'do' => DI::l10n()->t("ignore thread"),
281 'undo' => DI::l10n()->t("unignore thread"),
282 'toggle' => DI::l10n()->t("toggle ignore status"),
283 'classdo' => $thread['ignored'] ? "hidden" : "",
284 'classundo' => $thread['ignored'] ? "" : "hidden",
285 'ignored' => DI::l10n()->t('ignored'),
289 if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
291 $ispinned = ($item['pinned'] ? 'pinned' : 'unpinned');
294 'do' => DI::l10n()->t('pin'),
295 'undo' => DI::l10n()->t('unpin'),
296 'toggle' => DI::l10n()->t('toggle pin status'),
297 'classdo' => $item['pinned'] ? 'hidden' : '',
298 'classundo' => $item['pinned'] ? '' : 'hidden',
299 'pinned' => DI::l10n()->t('pinned'),
303 $isstarred = (($item['starred']) ? "starred" : "unstarred");
306 'do' => DI::l10n()->t("add star"),
307 'undo' => DI::l10n()->t("remove star"),
308 'toggle' => DI::l10n()->t("toggle star status"),
309 'classdo' => $item['starred'] ? "hidden" : "",
310 'classundo' => $item['starred'] ? "" : "hidden",
311 'starred' => DI::l10n()->t('starred'),
315 'add' => DI::l10n()->t("add tag"),
324 if ($conv->isWritable()) {
326 'like' => [DI::l10n()->t("I like this \x28toggle\x29"), DI::l10n()->t("like")],
327 'dislike' => [DI::l10n()->t("I don't like this \x28toggle\x29"), DI::l10n()->t("dislike")],
330 $buttons['share'] = [DI::l10n()->t('Share this'), DI::l10n()->t('share')];
334 $comment = $this->getCommentBox($indent);
336 if (strcmp(DateTimeFormat::utc($item['created']), DateTimeFormat::utc('now - 12 hours')) > 0) {
340 localize_item($item);
342 $body = Item::prepareBody($item, true);
344 list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);
347 $text_e = strip_tags($body);
348 $name_e = $profile_name;
350 if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) {
351 $title_e = ucfirst($item['content-warning']);
353 $title_e = $item['title'];
356 $location_e = $location;
357 $owner_name_e = $this->getOwnerName();
359 // Disable features that aren't available in several networks
360 if (!in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA]) && isset($buttons["dislike"])) {
361 unset($buttons["dislike"]);
366 if (($item["network"] == Protocol::FEED) && isset($buttons["like"])) {
367 unset($buttons["like"]);
370 if (($item["network"] == Protocol::MAIL) && isset($buttons["like"])) {
371 unset($buttons["like"]);
374 $tags = Term::populateTagsFromItem($item);
376 $ago = Temporal::getRelativeDate($item['created']);
377 $ago_received = Temporal::getRelativeDate($item['received']);
378 if (Config::get('system', 'show_received') && (abs(strtotime($item['created']) - strtotime($item['received'])) > Config::get('system', 'show_received_seconds')) && ($ago != $ago_received)) {
379 $ago = DI::l10n()->t('%s (Received %s)', $ago, $ago_received);
383 'template' => $this->getTemplate(),
384 'type' => implode("", array_slice(explode("/", $item['verb']), -1)),
385 'suppress_tags' => Config::get('system', 'suppress_tags'),
386 'tags' => $tags['tags'],
387 'hashtags' => $tags['hashtags'],
388 'mentions' => $tags['mentions'],
389 'implicit_mentions' => $tags['implicit_mentions'],
390 'txt_cats' => DI::l10n()->t('Categories:'),
391 'txt_folders' => DI::l10n()->t('Filed under:'),
392 'has_cats' => ((count($categories)) ? 'true' : ''),
393 'has_folders' => ((count($folders)) ? 'true' : ''),
394 'categories' => $categories,
395 'folders' => $folders,
398 'id' => $this->getId(),
399 'guid' => urlencode($item['guid']),
400 'isevent' => $isevent,
402 'linktitle' => DI::l10n()->t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
403 'olinktitle' => DI::l10n()->t('View %s\'s profile @ %s', $this->getOwnerName(), $item['owner-link']),
404 'to' => DI::l10n()->t('to'),
405 'via' => DI::l10n()->t('via'),
406 'wall' => DI::l10n()->t('Wall-to-Wall'),
407 'vwall' => DI::l10n()->t('via Wall-To-Wall:'),
408 'profile_url' => $profile_link,
409 'item_photo_menu' => item_photo_menu($item),
411 'thumb' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['author-avatar'], false, ProxyUtils::SIZE_THUMB)),
412 'osparkle' => $osparkle,
413 'sparkle' => $sparkle,
415 'localtime' => DateTimeFormat::local($item['created'], 'r'),
416 'ago' => $item['app'] ? DI::l10n()->t('%s from %s', $ago, $item['app']) : $ago,
417 'app' => $item['app'],
420 'location' => $location_e,
423 'owner_self' => $item['author-link'] == Session::get('my_url'),
424 'owner_url' => $this->getOwnerUrl(),
425 'owner_photo' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
426 'owner_name' => $owner_name_e,
427 'plink' => Item::getPlink($item),
429 'ispinned' => $ispinned,
432 'isstarred' => $isstarred,
439 'like' => $responses['like']['output'],
440 'dislike' => $responses['dislike']['output'],
441 'responses' => $responses,
442 'switchcomment' => DI::l10n()->t('Comment'),
443 'reply_label' => DI::l10n()->t('Reply to %s', $name_e),
444 'comment' => $comment,
445 'previewing' => $conv->isPreview() ? ' preview ' : '',
446 'wait' => DI::l10n()->t('Please wait'),
447 'thread_level' => $thread_level,
449 'network' => $item["network"],
450 'network_name' => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network']),
451 'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']),
452 'received' => $item['received'],
453 'commented' => $item['commented'],
454 'created_date' => $item['created'],
455 'return' => (DI::args()->getCommand()) ? bin2hex(DI::args()->getCommand()) : '',
457 'queue_count' => $item['delivery_queue_count'],
458 'queue_done' => $item['delivery_queue_done'] + $item['delivery_queue_failed'], /// @todo Possibly display it separately in the future
459 'notifier_pending' => DI::l10n()->t('Notifier task is pending'),
460 'delivery_pending' => DI::l10n()->t('Delivery to remote servers is pending'),
461 'delivery_underway' => DI::l10n()->t('Delivery to remote servers is underway'),
462 'delivery_almost' => DI::l10n()->t('Delivery to remote servers is mostly done'),
463 'delivery_done' => DI::l10n()->t('Delivery to remote servers is done'),
467 $arr = ['item' => $item, 'output' => $tmp_item];
468 Hook::callAll('display_item', $arr);
470 $result = $arr['output'];
472 $result['children'] = [];
473 $children = $this->getChildren();
474 $nb_children = count($children);
475 if ($nb_children > 0) {
476 foreach ($children as $child) {
477 $result['children'][] = $child->getTemplateData($conv_responses, $thread_level + 1);
481 if (($nb_children > 2) || ($thread_level > 1)) {
482 $result['children'][0]['comment_firstcollapsed'] = true;
483 $result['children'][0]['num_comments'] = DI::l10n()->tt('%d comment', '%d comments', $total_children);
484 $result['children'][0]['show_text'] = DI::l10n()->t('Show more');
485 $result['children'][0]['hide_text'] = DI::l10n()->t('Show fewer');
486 if ($thread_level > 1) {
487 $result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
489 $result['children'][$nb_children - 3]['comment_lastcollapsed'] = true;
494 if ($this->isToplevel()) {
495 $result['total_comments_num'] = "$total_children";
496 $result['total_comments_text'] = DI::l10n()->tt('comment', 'comments', $total_children);
499 $result['private'] = $item['private'];
500 $result['toplevel'] = ($this->isToplevel() ? 'toplevel_item' : '');
502 if ($this->isThreaded()) {
503 $result['flatten'] = false;
504 $result['threaded'] = true;
506 $result['flatten'] = true;
507 $result['threaded'] = false;
516 public function getId()
518 return $this->getDataValue('id');
524 public function isThreaded()
526 return $this->threaded;
532 * @param Post $item The child item to add
537 public function addChild(Post $item)
539 $item_id = $item->getId();
541 Logger::log('[ERROR] Post::addChild : Item has no ID!!', Logger::DEBUG);
543 } elseif ($this->getChild($item->getId())) {
544 Logger::log('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').', Logger::DEBUG);
548 $activity = DI::activity();
551 * Only add what will be displayed
553 if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
555 } elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) ||
556 $activity->match($item->getDataValue('verb'), Activity::DISLIKE)) {
560 $item->setParent($this);
561 $this->children[] = $item;
563 return end($this->children);
567 * Get a child by its ID
569 * @param integer $id The child id
573 public function getChild($id)
575 foreach ($this->getChildren() as $child) {
576 if ($child->getId() == $id) {
585 * Get all our children
589 public function getChildren()
591 return $this->children;
597 * @param Post $item The item to set as parent
601 protected function setParent(Post $item)
603 $parent = $this->getParent();
605 $parent->removeChild($this);
608 $this->parent = $item;
609 $this->setThread($item->getThread());
617 protected function removeParent()
619 $this->parent = null;
620 $this->thread = null;
626 * @param Post $item The child to be removed
628 * @return boolean Success or failure
631 public function removeChild(Post $item)
633 $id = $item->getId();
634 foreach ($this->getChildren() as $key => $child) {
635 if ($child->getId() == $id) {
636 $child->removeParent();
637 unset($this->children[$key]);
638 // Reindex the array, in order to make sure there won't be any trouble on loops using count()
639 $this->children = array_values($this->children);
643 Logger::log('[WARN] Item::removeChild : Item is not a child (' . $id . ').', Logger::DEBUG);
652 protected function getParent()
654 return $this->parent;
658 * Set conversation thread
660 * @param Thread $thread
664 public function setThread(Thread $thread = null)
666 $this->thread = $thread;
668 // Set it on our children too
669 foreach ($this->getChildren() as $child) {
670 $child->setThread($thread);
679 public function getThread()
681 return $this->thread;
687 * We shouldn't need this
691 public function getData()
699 * @param string $name key
701 * @return mixed value on success
704 public function getDataValue($name)
706 if (!isset($this->data[$name])) {
707 // Logger::log('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".', Logger::DEBUG);
711 return $this->data[$name];
717 * @param string $name template name
721 private function setTemplate($name)
723 if (empty($this->available_templates[$name])) {
724 Logger::log('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', Logger::DEBUG);
728 $this->template = $this->available_templates[$name];
738 private function getTemplate()
740 return $this->template;
744 * Check if this is a toplevel post
748 private function isToplevel()
750 return $this->toplevel;
754 * Check if this is writable
758 private function isWritable()
760 $conv = $this->getThread();
763 // This will allow us to comment on wall-to-wall items owned by our friends
764 // and community forums even if somebody else wrote the post.
765 // bug #517 - this fixes for conversation owner
766 if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == local_user()) {
770 // this fixes for visitors
771 return ($this->writable || ($this->isVisiting() && $conv->getMode() == 'profile'));
773 return $this->writable;
777 * Count the total of our descendants
781 private function countDescendants()
783 $children = $this->getChildren();
784 $total = count($children);
786 foreach ($children as $child) {
787 $total += $child->countDescendants();
795 * Get the template for the comment box
799 private function getCommentBoxTemplate()
801 return $this->comment_box_template;
805 * Get default text for the comment box
808 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
810 private function getDefaultText()
818 $owner = User::getOwnerDataById($a->user['uid']);
820 if (!Feature::isEnabled(local_user(), 'explicit_mentions')) {
824 $item = Item::selectFirst(['author-addr'], ['id' => $this->getId()]);
825 if (!DBA::isResult($item) || empty($item['author-addr'])) {
830 if ($item['author-addr'] != $owner['addr']) {
831 $text = '@' . $item['author-addr'] . ' ';
836 $terms = Term::tagArrayFromItemId($this->getId(), [Term::MENTION, Term::IMPLICIT_MENTION]);
837 foreach ($terms as $term) {
838 $profile = Contact::getDetailsByURL($term['url']);
839 if (!empty($profile['addr']) && ((($profile['contact-type'] ?? '') ?: Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&
840 ($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) {
841 $text .= '@' . $profile['addr'] . ' ';
849 * Get the comment box
851 * @param string $indent Indent value
853 * @return mixed The comment box string (empty if no comment box)
857 private function getCommentBox($indent)
862 $conv = $this->getThread();
864 if (($conv->getMode() === 'network') && $this->isWallToWall()) {
868 if ($conv->isWritable() && $this->isWritable()) {
872 * Hmmm, code depending on the presence of a particular addon?
873 * This should be better if done by a hook
875 if (Addon::isEnabled('qcomment')) {
876 $qc = ((local_user()) ? DI::pConfig()->get(local_user(), 'qcomment', 'words') : null);
877 $qcomment = (($qc) ? explode("\n", $qc) : null);
880 // Fetch the user id from the parent when the owner user is empty
881 $uid = $conv->getProfileOwner();
882 $parent_uid = $this->getDataValue('uid');
884 $default_text = $this->getDefaultText();
886 if (!is_null($parent_uid) && ($uid != $parent_uid)) {
890 $template = Renderer::getMarkupTemplate($this->getCommentBoxTemplate());
891 $comment_box = Renderer::replaceMacros($template, [
892 '$return_path' => DI::args()->getQueryString(),
893 '$threaded' => $this->isThreaded(),
895 '$wall' => ($conv->getMode() === 'profile'),
896 '$id' => $this->getId(),
897 '$parent' => $this->getId(),
898 '$qcomment' => $qcomment,
899 '$default' => $default_text,
900 '$profile_uid' => $uid,
901 '$mylink' => DI::baseUrl()->remove($a->contact['url']),
902 '$mytitle' => DI::l10n()->t('This is you'),
903 '$myphoto' => DI::baseUrl()->remove($a->contact['thumb']),
904 '$comment' => DI::l10n()->t('Comment'),
905 '$submit' => DI::l10n()->t('Submit'),
906 '$edbold' => DI::l10n()->t('Bold'),
907 '$editalic' => DI::l10n()->t('Italic'),
908 '$eduline' => DI::l10n()->t('Underline'),
909 '$edquote' => DI::l10n()->t('Quote'),
910 '$edcode' => DI::l10n()->t('Code'),
911 '$edimg' => DI::l10n()->t('Image'),
912 '$edurl' => DI::l10n()->t('Link'),
913 '$edattach' => DI::l10n()->t('Link or Media'),
914 '$prompttext' => DI::l10n()->t('Please enter a image/video/audio/webpage URL:'),
915 '$preview' => DI::l10n()->t('Preview'),
916 '$indent' => $indent,
917 '$sourceapp' => DI::l10n()->t($a->sourcename),
918 '$ww' => $conv->getMode() === 'network' ? $ww : '',
919 '$rand_num' => Crypto::randomDigits(12)
929 private function getRedirectUrl()
931 return $this->redirect_url;
935 * Check if we are a wall to wall item and set the relevant properties
940 protected function checkWallToWall()
943 $conv = $this->getThread();
944 $this->wall_to_wall = false;
946 if ($this->isToplevel()) {
947 if ($conv->getMode() !== 'profile') {
948 if ($this->getDataValue('wall') && !$this->getDataValue('self')) {
949 // On the network page, I am the owner. On the display page it will be the profile owner.
950 // This will have been stored in $a->page_contact by our calling page.
951 // Put this person as the wall owner of the wall-to-wall notice.
953 $this->owner_url = Contact::magicLink($a->page_contact['url']);
954 $this->owner_photo = $a->page_contact['thumb'];
955 $this->owner_name = $a->page_contact['name'];
956 $this->wall_to_wall = true;
957 } elseif ($this->getDataValue('owner-link')) {
958 $owner_linkmatch = (($this->getDataValue('owner-link')) && Strings::compareLink($this->getDataValue('owner-link'), $this->getDataValue('author-link')));
959 $alias_linkmatch = (($this->getDataValue('alias')) && Strings::compareLink($this->getDataValue('alias'), $this->getDataValue('author-link')));
960 $owner_namematch = (($this->getDataValue('owner-name')) && $this->getDataValue('owner-name') == $this->getDataValue('author-name'));
962 if (!$owner_linkmatch && !$alias_linkmatch && !$owner_namematch) {
963 // The author url doesn't match the owner (typically the contact)
964 // and also doesn't match the contact alias.
965 // The name match is a hack to catch several weird cases where URLs are
966 // all over the park. It can be tricked, but this prevents you from
967 // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
968 // well that it's the same Bob Smith.
969 // But it could be somebody else with the same name. It just isn't highly likely.
972 $this->owner_photo = $this->getDataValue('owner-avatar');
973 $this->owner_name = $this->getDataValue('owner-name');
974 $this->wall_to_wall = true;
976 $owner = ['uid' => 0, 'id' => $this->getDataValue('owner-id'),
977 'network' => $this->getDataValue('owner-network'),
978 'url' => $this->getDataValue('owner-link')];
979 $this->owner_url = Contact::magicLinkByContact($owner);
985 if (!$this->wall_to_wall) {
986 $this->setTemplate('wall');
987 $this->owner_url = '';
988 $this->owner_photo = '';
989 $this->owner_name = '';
996 private function isWallToWall()
998 return $this->wall_to_wall;
1004 private function getOwnerUrl()
1006 return $this->owner_url;
1012 private function getOwnerName()
1014 return $this->owner_name;
1020 private function isVisiting()
1022 return $this->visiting;