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