]> git.mxchange.org Git - friendica.git/blob - object/Item.php
Merge https://github.com/friendica/friendica into pull
[friendica.git] / object / Item.php
1 <?php
2 if(class_exists('Item'))
3         return;
4
5 require_once('object/BaseObject.php');
6 require_once('include/text.php');
7 require_once('boot.php');
8
9 /**
10  * An item
11  */
12 class Item extends BaseObject {
13         private $data = array();
14         private $template = null;
15         private $available_templates = array(
16                 'wall' => 'wall_thread.tpl',
17                 'wall2wall' => 'wallwall_thread.tpl'
18         );
19         private $comment_box_template = 'comment_item.tpl';
20         private $toplevel = false;
21         private $writable = false;
22         private $children = array();
23         private $parent = null;
24         private $conversation = null;
25         private $redirect_url = null;
26         private $owner_url = '';
27         private $owner_photo = '';
28         private $owner_name = '';
29         private $wall_to_wall = false;
30         private $threaded = false;
31         private $visiting = false;
32
33         public function __construct($data) {
34                 $a = $this->get_app();
35                 
36                 $this->data = $data;
37                 $this->set_template('wall');
38                 $this->toplevel = ($this->get_id() == $this->get_data_value('parent'));
39
40                 if(is_array($_SESSION['remote'])) {
41                         foreach($_SESSION['remote'] as $visitor) {
42                                 if($visitor['cid'] == $this->get_data_value('contact-id')) {
43                                         $this->visiting = true;
44                                         break;
45                                 }
46                         }
47                 }
48                 
49                 $this->writable = ($this->get_data_value('writable') || $this->get_data_value('self'));
50
51                 $ssl_state = ((local_user()) ? true : false);
52                 $this->redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $this->get_data_value('cid') ;
53
54                 if(get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel())
55                         $this->threaded = true;
56
57                 // Prepare the children
58                 if(count($data['children'])) {
59                         foreach($data['children'] as $item) {
60                                 /*
61                                  * Only add will be displayed
62                                  */
63                                 if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
64                                         continue;
65                                 }
66                                 if(! visible_activity($item)) {
67                                         continue;
68                                 }
69                                 $item['pagedrop'] = $data['pagedrop'];
70                                 $child = new Item($item);
71                                 $this->add_child($child);
72                         }
73                 }
74         }
75
76         /**
77          * Get data in a form usable by a conversation template
78          *
79          * Returns:
80          *      _ The data requested on success
81          *      _ false on failure
82          */
83         public function get_template_data($alike, $dlike, $thread_level=1) {
84                 $result = array();
85
86                 $a = $this->get_app();
87
88                 $item = $this->get_data();
89                 $edited = false;
90                 if (strcmp($item['created'], $item['edited'])<>0) {
91                       $edited = array(
92                           'label' => t('This entry was edited'),
93                           'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'),
94                           'relative' => relative_date($item['edited'])
95                       );
96                 }
97                 $commentww = '';
98                 $sparkle = '';
99                 $buttons = '';
100                 $dropping = false;
101                 $star = false;
102                 $isstarred = "unstarred";
103                 $indent = '';
104                 $shiny = '';
105                 $osparkle = '';
106                 $total_children = $this->count_descendants();
107
108                 $conv = $this->get_conversation();
109
110
111                 $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) 
112                         || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
113                         ? t('Private Message')
114                         : false);
115                 $shareable = ((($conv->get_profile_owner() == local_user()) && ($item['private'] != 1)) ? true : false);
116                 if(local_user() && link_compare($a->contact['url'],$item['author-link']))
117                         $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
118                 else
119                         $edpost = false;
120                 if(($this->get_data_value('uid') == local_user()) || $this->is_visiting())
121                         $dropping = true;
122
123                 $drop = array(
124                         'dropping' => $dropping,
125                         'pagedrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $item['pagedrop'] : ''),
126                         'select' => t('Select'),
127                         'delete' => t('Delete'),
128                 );
129
130                 $filer = (($conv->get_profile_owner() == local_user()) ? t("save to folder") : false);
131
132                 $diff_author    = ((link_compare($item['url'],$item['author-link'])) ? false : true);
133                 $profile_name   = (((strlen($item['author-name']))   && $diff_author) ? $item['author-name']   : $item['name']);
134                 if($item['author-link'] && (! $item['author-name']))
135                         $profile_name = $item['author-link'];
136
137                 $sp = false;
138                 $profile_link = best_link_url($item,$sp);
139                 if($profile_link === 'mailbox')
140                         $profile_link = '';
141                 if($sp)
142                         $sparkle = ' sparkle';
143                 else
144                         $profile_link = zrl($profile_link);
145
146                 $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
147                 if(($normalised != 'mailbox') && (x($a->contacts,$normalised)))
148                         $profile_avatar = $a->contacts[$normalised]['thumb'];
149                 else
150                         $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $a->get_cached_avatar_image($this->get_data_value('thumb')));
151
152                 $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
153                 call_hooks('render_location',$locate);
154                 $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate));
155
156                 $searchpath = $a->get_baseurl()."/search?tag=";
157                 $tags=array();
158                 $hashtags = array();
159                 $mentions = array();
160
161                 if (!get_config('system','suppress_tags')) {
162                         $taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`",
163                                         intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
164
165                         foreach($taglist as $tag) {
166
167                                 if ($tag["url"] == "")
168                                         $tag["url"] = $searchpath.strtolower($tag["term"]);
169
170                                 if ($tag["type"] == TERM_HASHTAG) {
171                                         $hashtags[] = "#<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
172                                         $prefix = "#";
173                                 } elseif ($tag["type"] == TERM_MENTION) {
174                                         $mentions[] = "@<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
175                                         $prefix = "@";
176                                 }
177                                 $tags[] = $prefix."<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
178                         }
179                 }
180
181                 /*foreach(explode(',',$item['tag']) as $tag){
182                         $tag = trim($tag);
183                         if ($tag!="") {
184                                 $t = bbcode($tag);
185                                 $tags[] = $t;
186                                 if($t[0] == '#')
187                                         $hashtags[] = $t;
188                                 elseif($t[0] == '@')
189                                         $mentions[] = $t;
190                         }
191                 }*/
192
193                 $like    = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
194                 $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : '');
195
196                 /*
197                  * We should avoid doing this all the time, but it depends on the conversation mode
198                  * And the conv mode may change when we change the conv, or it changes its mode
199                  * Maybe we should establish a way to be notified about conversation changes
200                  */
201                 $this->check_wall_to_wall();
202
203                 if($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url()))
204                         $osparkle = ' sparkle';
205
206                 if($this->is_toplevel()) {
207                         if($conv->get_profile_owner() == local_user()) {
208                                 $isstarred = (($item['starred']) ? "starred" : "unstarred");
209
210                                 $star = array(
211                                         'do' => t("add star"),
212                                         'undo' => t("remove star"),
213                                         'toggle' => t("toggle star status"),
214                                         'classdo' => (($item['starred']) ? "hidden" : ""),
215                                         'classundo' => (($item['starred']) ? "" : "hidden"),
216                                         'starred' =>  t('starred'),
217                                 );
218                                 $tagger = '';
219                                 if(feature_enabled($conv->get_profile_owner(),'commtag')) {
220                                         $tagger = array(
221                                                 'add' => t("add tag"),
222                                                 'class' => "",
223                                         );
224                                 }
225                         }
226                 } else {
227                         $indent = 'comment';
228                 }
229
230                 if($conv->is_writable()) {
231                         $buttons = array(
232                                 'like' => array( t("I like this \x28toggle\x29"), t("like")),
233                                 'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''),
234                         );
235                         if ($shareable) $buttons['share'] = array( t('Share this'), t('share'));
236                 }
237
238                 if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0){
239                         $shiny = 'shiny';
240                 }
241
242                 localize_item($item);
243
244                 if ($item["postopts"] and !get_config("system", "suppress_language")) {
245                         //$langdata = explode(";", $item["postopts"]);
246                         //$langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)";
247                         $langstr = "";
248                         if (substr($item["postopts"], 0, 5) == "lang=") {
249                                 $postopts = substr($item["postopts"], 5);
250
251                                 $languages = explode(":", $postopts);
252
253                                 if (sizeof($languages) == 1) {
254                                         $languages = array();
255                                         $languages[] = $postopts;
256                                 }
257
258                                 foreach ($languages as $language) {
259                                         $langdata = explode(";", $language);
260                                         if ($langstr != "")
261                                                 $langstr .= ", ";
262
263                                         //$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)";
264                                         $langstr .= round($langdata[1]*100, 1)."% ".$langdata[0];
265                                 }
266                         }
267                 }
268
269                 $body = prepare_body($item,true);
270
271                 list($categories, $folders) = get_cats_and_terms($item);
272
273                 if($a->theme['template_engine'] === 'internal') {
274                         $body_e = template_escape($body);
275                         $text_e = strip_tags(template_escape($body));
276                         $name_e = template_escape($profile_name);
277                         $title_e = template_escape($item['title']);
278                         $location_e = template_escape($location);
279                         $owner_name_e = template_escape($this->get_owner_name());
280                 }
281                 else {
282                         $body_e = $body;
283                         $text_e = strip_tags($body);
284                         $name_e = $profile_name;
285                         $title_e = $item['title'];
286                         $location_e = $location;
287                         $owner_name_e = $this->get_owner_name();
288                 }
289
290                 $tmp_item = array(
291                         'template' => $this->get_template(),
292
293                         'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
294                         'tags' => $tags,
295                         'hashtags' => $hashtags,
296                         'mentions' => $mentions,
297                         'txt_cats' => t('Categories:'),
298                         'txt_folders' => t('Filed under:'),
299                         'has_cats' => ((count($categories)) ? 'true' : ''),
300                         'has_folders' => ((count($folders)) ? 'true' : ''),
301                         'categories' => $categories,
302                         'folders' => $folders,
303                         'body' => $body_e,
304                         'text' => $text_e,
305                         'id' => $this->get_id(),
306                         'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
307                         'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $this->get_owner_name(), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
308                         'to' => t('to'),
309                         'via' => t('via'),
310                         'wall' => t('Wall-to-Wall'),
311                         'vwall' => t('via Wall-To-Wall:'),
312                         'profile_url' => $profile_link,
313                         'item_photo_menu' => item_photo_menu($item),
314                         'name' => $name_e,
315                         'thumb' => $profile_avatar,
316                         'osparkle' => $osparkle,
317                         'sparkle' => $sparkle,
318                         'title' => $title_e,
319                         'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'),
320                         'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
321                         'lock' => $lock,
322                         'location' => $location_e,
323                         'indent' => $indent,
324                         'shiny' => $shiny,
325                         'owner_url' => $this->get_owner_url(),
326                         'owner_photo' => $this->get_owner_photo(),
327                         'owner_name' => $owner_name_e,
328                         'plink' => get_plink($item),
329                         'edpost'    => ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''),
330                         'isstarred' => $isstarred,
331                         'star'      => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''),
332                         'tagger'        => $tagger,
333                         'filer'     => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''),
334                         'drop' => $drop,
335                         'vote' => $buttons,
336                         'like' => $like,
337                         'dislike'   => $dislike,
338                         'switchcomment' => t('Comment'),
339                         'comment' => $this->get_comment_box($indent),
340                         'previewing' => ($conv->is_preview() ? ' preview ' : ''),
341                         'wait' => t('Please wait'),
342                         'thread_level' => $thread_level,
343                         'postopts' => $langstr,
344                         'edited' => $edited
345                 );
346
347                 $arr = array('item' => $item, 'output' => $tmp_item);
348                 call_hooks('display_item', $arr);
349
350                 $result = $arr['output'];
351
352                 $result['children'] = array();
353                 $children = $this->get_children();
354                 $nb_children = count($children);
355                 if($nb_children > 0) {
356                         foreach($children as $child) {
357                                 $result['children'][] = $child->get_template_data($alike, $dlike, $thread_level + 1);
358                         }
359                         // Collapse
360                         if(($nb_children > 2) || ($thread_level > 1)) {
361                                 $result['children'][0]['comment_firstcollapsed'] = true;
362                                 $result['children'][0]['num_comments'] = sprintf( tt('%d comment','%d comments',$total_children),$total_children );
363                                 $result['children'][0]['hidden_comments_num'] = $total_children;
364                                 $result['children'][0]['hidden_comments_text'] = tt('comment', 'comments', $total_children);
365                                 $result['children'][0]['hide_text'] = t('show more');
366                                 if($thread_level > 1) {
367                                         $result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
368                                 }
369                                 else {
370                                         $result['children'][$nb_children - 3]['comment_lastcollapsed'] = true;
371                                 }
372                         }
373                 }
374
375         if ($this->is_toplevel()) {
376             $result['total_comments_num'] = "$total_children";
377             $result['total_comments_text'] = tt('comment', 'comments', $total_children);
378         }
379
380                 $result['private'] = $item['private'];
381                 $result['toplevel'] = ($this->is_toplevel() ? 'toplevel_item' : '');
382
383                 if($this->is_threaded()) {
384                         $result['flatten'] = false;
385                         $result['threaded'] = true;
386                 }
387                 else {
388                         $result['flatten'] = true;
389                         $result['threaded'] = false;
390                 }
391
392                 return $result;
393         }
394         
395         public function get_id() {
396                 return $this->get_data_value('id');
397         }
398
399         public function is_threaded() {
400                 return $this->threaded;
401         }
402
403         /**
404          * Add a child item
405          */
406         public function add_child($item) {
407                 $item_id = $item->get_id();
408                 if(!$item_id) {
409                         logger('[ERROR] Item::add_child : Item has no ID!!', LOGGER_DEBUG);
410                         return false;
411                 }
412                 if($this->get_child($item->get_id())) {
413                         logger('[WARN] Item::add_child : Item already exists ('. $item->get_id() .').', LOGGER_DEBUG);
414                         return false;
415                 }
416                 /*
417                  * Only add what will be displayed
418                  */
419                 if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
420                         return false;
421                 }
422                 if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
423                         return false;
424                 }
425                 
426                 $item->set_parent($this);
427                 $this->children[] = $item;
428                 return end($this->children);
429         }
430
431         /**
432          * Get a child by its ID
433          */
434         public function get_child($id) {
435                 foreach($this->get_children() as $child) {
436                         if($child->get_id() == $id)
437                                 return $child;
438                 }
439                 return null;
440         }
441
442         /**
443          * Get all ou children
444          */
445         public function get_children() {
446                 return $this->children;
447         }
448
449         /**
450          * Set our parent
451          */
452         protected function set_parent($item) {
453                 $parent = $this->get_parent();
454                 if($parent) {
455                         $parent->remove_child($this);
456                 }
457                 $this->parent = $item;
458                 $this->set_conversation($item->get_conversation());
459         }
460
461         /**
462          * Remove our parent
463          */
464         protected function remove_parent() {
465                 $this->parent = null;
466                 $this->conversation = null;
467         }
468
469         /**
470          * Remove a child
471          */
472         public function remove_child($item) {
473                 $id = $item->get_id();
474                 foreach($this->get_children() as $key => $child) {
475                         if($child->get_id() == $id) {
476                                 $child->remove_parent();
477                                 unset($this->children[$key]);
478                                 // Reindex the array, in order to make sure there won't be any trouble on loops using count()
479                                 $this->children = array_values($this->children);
480                                 return true;
481                         }
482                 }
483                 logger('[WARN] Item::remove_child : Item is not a child ('. $id .').', LOGGER_DEBUG);
484                 return false;
485         }
486
487         /**
488          * Get parent item
489          */
490         protected function get_parent() {
491                 return $this->parent;
492         }
493
494         /**
495          * set conversation
496          */
497         public function set_conversation($conv) {
498                 $previous_mode = ($this->conversation ? $this->conversation->get_mode() : '');
499                 
500                 $this->conversation = $conv;
501
502                 // Set it on our children too
503                 foreach($this->get_children() as $child)
504                         $child->set_conversation($conv);
505         }
506
507         /**
508          * get conversation
509          */
510         public function get_conversation() {
511                 return $this->conversation;
512         }
513
514         /**
515          * Get raw data
516          *
517          * We shouldn't need this
518          */
519         public function get_data() {
520                 return $this->data;
521         }
522
523         /**
524          * Get a data value
525          *
526          * Returns:
527          *      _ value on success
528          *      _ false on failure
529          */
530         public function get_data_value($name) {
531                 if(!isset($this->data[$name])) {
532 //                      logger('[ERROR] Item::get_data_value : Item has no value name "'. $name .'".', LOGGER_DEBUG);
533                         return false;
534                 }
535
536                 return $this->data[$name];
537         }
538
539         /**
540          * Set template
541          */
542         private function set_template($name) {
543                 $a = get_app();
544
545                 if(!x($this->available_templates, $name)) {
546                         logger('[ERROR] Item::set_template : Template not available ("'. $name .'").', LOGGER_DEBUG);
547                         return false;
548                 }
549
550                 $this->template = $this->available_templates[$name];
551         }
552
553         /**
554          * Get template
555          */
556         private function get_template() {
557                 return $this->template;
558         }
559
560         /**
561          * Check if this is a toplevel post
562          */
563         private function is_toplevel() {
564                 return $this->toplevel;
565         }
566
567         /**
568          * Check if this is writable
569          */
570         private function is_writable() {
571                 $conv = $this->get_conversation();
572
573                 if($conv) {
574                         // This will allow us to comment on wall-to-wall items owned by our friends
575                         // and community forums even if somebody else wrote the post.
576
577                         // bug #517 - this fixes for conversation owner
578                         if($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user())
579                                 return true; 
580
581                         // this fixes for visitors
582                         return ($this->writable || ($this->is_visiting() && $conv->get_mode() == 'profile'));
583                 }
584                 return $this->writable;
585         }
586
587         /**
588          * Count the total of our descendants
589          */
590         private function count_descendants() {
591                 $children = $this->get_children();
592                 $total = count($children);
593                 if($total > 0) {
594                         foreach($children as $child) {
595                                 $total += $child->count_descendants();
596                         }
597                 }
598                 return $total;
599         }
600
601         /**
602          * Get the template for the comment box
603          */
604         private function get_comment_box_template() {
605                 return $this->comment_box_template;
606         }
607
608         /**
609          * Get the comment box
610          *
611          * Returns:
612          *      _ The comment box string (empty if no comment box)
613          *      _ false on failure
614          */
615         private function get_comment_box($indent) {
616                 $a = $this->get_app();
617                 if(!$this->is_toplevel() && !(get_config('system','thread_allow') && $a->theme_thread_allow)) {
618                         return '';
619                 }
620                 
621                 $comment_box = '';
622                 $conv = $this->get_conversation();
623                 $template = get_markup_template($this->get_comment_box_template());
624                 $ww = '';
625                 if( ($conv->get_mode() === 'network') && $this->is_wall_to_wall() )
626                         $ww = 'ww';
627
628                 if($conv->is_writable() && $this->is_writable()) {
629                         $qc = $qcomment =  null;
630
631                         /*
632                          * Hmmm, code depending on the presence of a particular plugin?
633                          * This should be better if done by a hook
634                          */
635                         if(in_array('qcomment',$a->plugins)) {
636                                 $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
637                                 $qcomment = (($qc) ? explode("\n",$qc) : null);
638                         }
639                         $comment_box = replace_macros($template,array(
640                                 '$return_path' => $a->query_string,
641                                 '$threaded' => $this->is_threaded(),
642 //                              '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''),
643                                 '$jsreload' => '',
644                                 '$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'),
645                                 '$id' => $this->get_id(),
646                                 '$parent' => $this->get_id(),
647                                 '$qcomment' => $qcomment,
648                                 '$profile_uid' =>  $conv->get_profile_owner(),
649                                 '$mylink' => $a->contact['url'],
650                                 '$mytitle' => t('This is you'),
651                                 '$myphoto' => $a->contact['thumb'],
652                                 '$comment' => t('Comment'),
653                                 '$submit' => t('Submit'),
654                                 '$edbold' => t('Bold'),
655                                 '$editalic' => t('Italic'),
656                                 '$eduline' => t('Underline'),
657                                 '$edquote' => t('Quote'),
658                                 '$edcode' => t('Code'),
659                                 '$edimg' => t('Image'),
660                                 '$edurl' => t('Link'),
661                                 '$edvideo' => t('Video'),
662                                 '$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''),
663                                 '$indent' => $indent,
664                                 '$sourceapp' => t($a->sourcename),
665                                 '$ww' => (($conv->get_mode() === 'network') ? $ww : ''),
666                                 '$rand_num' => random_digits(12)
667                         ));
668                 }
669
670                 return $comment_box;
671         }
672
673         private function get_redirect_url() {
674                 return $this->redirect_url;
675         }
676
677         /**
678          * Check if we are a wall to wall item and set the relevant properties
679          */
680         protected function check_wall_to_wall() {
681                 $a = $this->get_app();
682                 $conv = $this->get_conversation();
683                 $this->wall_to_wall = false;
684                 
685                 if($this->is_toplevel()) {
686                         if( (! $this->get_data_value('self')) && ($conv->get_mode() !== 'profile')) {
687                                 if($this->get_data_value('wall')) {
688
689                                         // On the network page, I am the owner. On the display page it will be the profile owner.
690                                         // This will have been stored in $a->page_contact by our calling page.
691                                         // Put this person as the wall owner of the wall-to-wall notice.
692
693                                         $this->owner_url = zrl($a->page_contact['url']);
694                                         $this->owner_photo = $a->page_contact['thumb'];
695                                         $this->owner_name = $a->page_contact['name'];
696                                         $this->wall_to_wall = true;
697                                 }
698                                 else if($this->get_data_value('owner-link')) {
699
700                                         $owner_linkmatch = (($this->get_data_value('owner-link')) && link_compare($this->get_data_value('owner-link'),$this->get_data_value('author-link')));
701                                         $alias_linkmatch = (($this->get_data_value('alias')) && link_compare($this->get_data_value('alias'),$this->get_data_value('author-link')));
702                                         $owner_namematch = (($this->get_data_value('owner-name')) && $this->get_data_value('owner-name') == $this->get_data_value('author-name'));
703                                         if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
704
705                                                 // The author url doesn't match the owner (typically the contact)
706                                                 // and also doesn't match the contact alias. 
707                                                 // The name match is a hack to catch several weird cases where URLs are 
708                                                 // all over the park. It can be tricked, but this prevents you from
709                                                 // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
710                                                 // well that it's the same Bob Smith. 
711
712                                                 // But it could be somebody else with the same name. It just isn't highly likely. 
713                                                 
714
715                                                 $this->owner_photo = $this->get_data_value('owner-avatar');
716                                                 $this->owner_name = $this->get_data_value('owner-name');
717                                                 $this->wall_to_wall = true;
718                                                 // If it is our contact, use a friendly redirect link
719                                                 if((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url'))) 
720                                                         && ($this->get_data_value('network') === NETWORK_DFRN)) {
721                                                         $this->owner_url = $this->get_redirect_url();
722                                                 }
723                                                 else
724                                                         $this->owner_url = zrl($this->get_data_value('owner-link'));
725                                         }
726                                 }
727                         }
728                 }
729
730                 if(!$this->wall_to_wall) {
731                         $this->set_template('wall');
732                         $this->owner_url = '';
733                         $this->owner_photo = '';
734                         $this->owner_name = '';
735                 }
736         }
737
738         private function is_wall_to_wall() {
739                 return $this->wall_to_wall;
740         }
741
742         private function get_owner_url() {
743                 return $this->owner_url;
744         }
745
746         private function get_owner_photo() {
747                 return $this->owner_photo;
748         }
749
750         private function get_owner_name() {
751                 return $this->owner_name;
752         }
753
754         private function is_visiting() {
755                 return $this->visiting;
756         }
757
758
759
760
761 }
762 ?>