]> git.mxchange.org Git - friendica.git/blob - mod/display.php
79eaf371782a3c2f00985a89b2531d1e5a662979
[friendica.git] / mod / display.php
1 <?php
2
3
4 function display_content(&$a) {
5
6         if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
7                 notice( t('Public access denied.') . EOL);
8                 return;
9         }
10
11         require_once("include/bbcode.php");
12         require_once('include/security.php');
13         require_once('include/conversation.php');
14
15
16         $o = '<div id="live-display"></div>' . "\r\n";
17
18         $a->page['htmlhead'] .= '<script>$(document).ready(function() { $(".comment-edit-wrapper  textarea").contact_autocomplete(baseurl+"/acl"); });</script>';
19
20
21         $nick = (($a->argc > 1) ? $a->argv[1] : '');
22         profile_load($a,$nick);
23
24         $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
25
26         if(! $item_id) {
27                 $a->error = 404;
28                 notice( t('Item not found.') . EOL);
29                 return;
30         }
31
32         $groups = array();
33
34         $contact = null;
35         $remote_contact = false;
36
37         if(remote_user()) {
38                 $contact_id = $_SESSION['visitor_id'];
39                 $groups = init_groups_visitor($contact_id);
40                 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
41                         intval($contact_id),
42                         intval($a->profile['uid'])
43                 );
44                 if(count($r)) {
45                         $contact = $r[0];
46                         $remote_contact = true;
47                 }
48         }
49
50         if(! $remote_contact) {
51                 if(local_user()) {
52                         $contact_id = $_SESSION['cid'];
53                         $contact = $a->contact;
54                 }
55         }
56
57         $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
58                 intval($a->profile['uid'])
59         );
60         if(count($r))
61                 $a->page_contact = $r[0];
62
63         $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
64
65         if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
66                 notice( t('Access to this profile has been restricted.') . EOL);
67                 return;
68         }
69         
70         if ($is_owner)
71                 $o .= status_editor($a,$x,0,true);
72
73
74         $sql_extra = permissions_sql($a->profile['uid'],$remote_contact,$groups);
75
76         $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
77                 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
78                 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, 
79                 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
80                 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
81                 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
82                 and `item`.`moderated` = 0
83                 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
84                 AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))
85                 $sql_extra
86                 ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
87                 intval($a->profile['uid']),
88                 dbesc($item_id),
89                 dbesc($item_id)
90         );
91
92
93         if(count($r)) {
94
95                 if((local_user()) && (local_user() == $a->profile['uid'])) {
96                         q("UPDATE `item` SET `unseen` = 0 
97                                 WHERE `parent` = %d AND `unseen` = 1",
98                                 intval($r[0]['parent'])
99                         );
100                 }
101
102
103                 $o .= conversation($a,$r,'display', false);
104
105         }
106         else {
107                 $r = q("SELECT `id` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
108                         dbesc($item_id),
109                         dbesc($item_id)
110                 );
111                 if(count($r)) {
112                         if($r[0]['deleted']) {
113                                 notice( t('Item has been removed.') . EOL );
114                         }
115                         else {  
116                                 notice( t('Permission denied.') . EOL ); 
117                         }
118                 }
119                 else {
120                         notice( t('Item not found.') . EOL );
121                 }
122
123         }
124
125         return $o;
126 }
127