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