]> git.mxchange.org Git - friendica.git/blob - mod/display.php
convert ent_quotes for jquery calendar title/summary
[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         require_once('include/acl_selectors.php');
15
16
17         $o = '<div id="live-display"></div>' . "\r\n";
18
19         $a->page['htmlhead'] .= <<<EOT
20 <script>
21 $(document).ready(function() {
22         $(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
23         // make auto-complete work in more places
24         $(".wall-item-comment-wrapper textarea").contact_autocomplete(baseurl+"/acl");
25 });
26 </script>
27 EOT;
28
29
30         $nick = (($a->argc > 1) ? $a->argv[1] : '');
31         profile_load($a,$nick);
32
33         $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
34
35         if(! $item_id) {
36                 $a->error = 404;
37                 notice( t('Item not found.') . EOL);
38                 return;
39         }
40
41         $groups = array();
42
43         $contact = null;
44         $remote_contact = false;
45
46         if(remote_user()) {
47                 $contact_id = $_SESSION['visitor_id'];
48                 $groups = init_groups_visitor($contact_id);
49                 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
50                         intval($contact_id),
51                         intval($a->profile['uid'])
52                 );
53                 if(count($r)) {
54                         $contact = $r[0];
55                         $remote_contact = true;
56                 }
57         }
58
59         if(! $remote_contact) {
60                 if(local_user()) {
61                         $contact_id = $_SESSION['cid'];
62                         $contact = $a->contact;
63                 }
64         }
65
66         $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
67                 intval($a->profile['uid'])
68         );
69         if(count($r))
70                 $a->page_contact = $r[0];
71
72         $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
73
74         if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
75                 notice( t('Access to this profile has been restricted.') . EOL);
76                 return;
77         }
78         
79         if ($is_owner)
80                 $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
81
82                 $x = array(
83                         'is_owner' => true,
84                         'allow_location' => $a->user['allow_location'],
85                         'default_location' => $a->user['default-location'],
86                         'nickname' => $a->user['nickname'],
87                         'lockstate' => ( (is_array($a->user)) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))) ? 'lock' : 'unlock'),
88                         'acl' => populate_acl($a->user, $celeb),
89                         'bang' => '',
90                         'visitor' => 'block',
91                         'profile_uid' => local_user()
92                 );      
93                 $o .= status_editor($a,$x,0,true);
94
95
96         $sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups);
97
98         $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
99                 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
100                 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, 
101                 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
102                 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
103                 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
104                 and `item`.`moderated` = 0
105                 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
106                 AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))
107                 $sql_extra
108                 ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
109                 intval($a->profile['uid']),
110                 dbesc($item_id),
111                 dbesc($item_id)
112         );
113
114
115         if(count($r)) {
116
117                 if((local_user()) && (local_user() == $a->profile['uid'])) {
118                         q("UPDATE `item` SET `unseen` = 0 
119                                 WHERE `parent` = %d AND `unseen` = 1",
120                                 intval($r[0]['parent'])
121                         );
122                 }
123
124
125                 $o .= conversation($a,$r,'display', false);
126
127         }
128         else {
129                 $r = q("SELECT `id` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
130                         dbesc($item_id),
131                         dbesc($item_id)
132                 );
133                 if(count($r)) {
134                         if($r[0]['deleted']) {
135                                 notice( t('Item has been removed.') . EOL );
136                         }
137                         else {  
138                                 notice( t('Permission denied.') . EOL ); 
139                         }
140                 }
141                 else {
142                         notice( t('Item not found.') . EOL );
143                 }
144
145         }
146
147         return $o;
148 }
149