4 function display_init(&$a) {
6 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
10 $nick = (($a->argc > 1) ? $a->argv[1] : '');
11 profile_load($a,$nick);
16 function display_content(&$a, $update = 0) {
18 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
19 notice( t('Public access denied.') . EOL);
23 require_once("include/bbcode.php");
24 require_once('include/security.php');
25 require_once('include/conversation.php');
26 require_once('include/acl_selectors.php');
31 $a->page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), array());
35 $nick = $_REQUEST['nick'];
38 $nick = (($a->argc > 1) ? $a->argv[1] : '');
42 $item_id = $_REQUEST['item_id'];
43 $a->profile = array('uid' => intval($update), 'profile_uid' => intval($update));
46 $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
51 notice( t('Item not found.') . EOL);
58 $remote_contact = false;
62 if(is_array($_SESSION['remote'])) {
63 foreach($_SESSION['remote'] as $v) {
64 if($v['uid'] == $a->profile['uid']) {
65 $contact_id = $v['cid'];
72 $groups = init_groups_visitor($contact_id);
73 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
75 intval($a->profile['uid'])
79 $remote_contact = true;
83 if(! $remote_contact) {
85 $contact_id = $_SESSION['cid'];
86 $contact = $a->contact;
90 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
91 intval($a->profile['uid'])
94 $a->page_contact = $r[0];
96 $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
98 if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
99 notice( t('Access to this profile has been restricted.') . EOL);
104 $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
108 'allow_location' => $a->user['allow_location'],
109 'default_location' => $a->user['default-location'],
110 'nickname' => $a->user['nickname'],
111 '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'),
112 'acl' => populate_acl($a->user, $celeb),
114 'visitor' => 'block',
115 'profile_uid' => local_user()
117 $o .= status_editor($a,$x,0,true);
120 $sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups);
125 $r = q("SELECT id FROM item WHERE item.uid = %d
126 AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))
127 $sql_extra AND unseen = 1",
128 intval($a->profile['uid']),
137 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
138 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
139 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
140 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
141 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
142 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
143 and `item`.`moderated` = 0
144 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
145 AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))
147 ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
148 intval($a->profile['uid']),
156 if((local_user()) && (local_user() == $a->profile['uid'])) {
157 q("UPDATE `item` SET `unseen` = 0
158 WHERE `parent` = %d AND `unseen` = 1",
159 intval($r[0]['parent'])
163 $items = conv_sort($r,"`commented`");
166 $o .= "<script> var netargs = '?f=&nick=" . $nick . "&item_id=" . $item_id . "'; </script>";
167 $o .= conversation($a,$items,'display', $update);
171 $r = q("SELECT `id`,`deleted` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
176 if($r[0]['deleted']) {
177 notice( t('Item has been removed.') . EOL );
180 notice( t('Permission denied.') . EOL );
184 notice( t('Item not found.') . EOL );