4 function display_content(&$a, $update = 0) {
6 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
7 notice( t('Public access denied.') . EOL);
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');
19 $a->page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), array());
23 $nick = $_REQUEST['nick'];
26 $nick = (($a->argc > 1) ? $a->argv[1] : '');
28 profile_load($a,$nick);
31 $item_id = $_REQUEST['item_id'];
34 $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
39 notice( t('Item not found.') . EOL);
46 $remote_contact = false;
50 if(is_array($_SESSION['remote'])) {
51 foreach($_SESSION['remote'] as $v) {
52 if($v['uid'] == $a->profile['uid']) {
53 $contact_id = $v['cid'];
60 $groups = init_groups_visitor($contact_id);
61 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
63 intval($a->profile['uid'])
67 $remote_contact = true;
71 if(! $remote_contact) {
73 $contact_id = $_SESSION['cid'];
74 $contact = $a->contact;
78 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
79 intval($a->profile['uid'])
82 $a->page_contact = $r[0];
84 $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
86 if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
87 notice( t('Access to this profile has been restricted.') . EOL);
92 $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
96 'allow_location' => $a->user['allow_location'],
97 'default_location' => $a->user['default-location'],
98 'nickname' => $a->user['nickname'],
99 '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'),
100 'acl' => populate_acl($a->user, $celeb),
102 'visitor' => 'block',
103 'profile_uid' => local_user()
105 $o .= status_editor($a,$x,0,true);
108 $sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups);
111 $r = q("SELECT id FROM item WHERE item.uid = %d
112 AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))
113 $sql_extra AND unseen = 1",
114 intval($a->profile['uid']),
122 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
123 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
124 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
125 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
126 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
127 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
128 and `item`.`moderated` = 0
129 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
130 AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))
132 ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
133 intval($a->profile['uid']),
141 if((local_user()) && (local_user() == $a->profile['uid'])) {
142 q("UPDATE `item` SET `unseen` = 0
143 WHERE `parent` = %d AND `unseen` = 1",
144 intval($r[0]['parent'])
148 $items = conv_sort($r,"`commented`");
151 $o .= "<script> var netargs = '?f=&nick=" . $nick . "&item_id=" . $item_id . "'; </script>";
152 $o .= conversation($a,$items,'display', $update);
156 $r = q("SELECT `id`,`deleted` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
161 if($r[0]['deleted']) {
162 notice( t('Item has been removed.') . EOL );
165 notice( t('Permission denied.') . EOL );
169 notice( t('Item not found.') . EOL );