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