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