4 function display_content(&$a) {
6 $o = '<div id="live-display"></div>' . "\r\n";
10 $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
14 notice( t('Item not found.') . EOL);
18 require_once("include/bbcode.php");
19 require_once('include/security.php');
28 $remote_contact = false;
31 $contact_id = $_SESSION['visitor_id'];
32 $groups = init_groups_visitor($contact_id);
33 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
35 intval($a->profile['uid'])
39 $remote_contact = true;
43 if(! $remote_contact) {
45 $contact_id = $_SESSION['cid'];
46 $contact = $a->contact;
59 // Profile owner - everything is visible
61 if(local_user() && (local_user() == $a->profile['uid'])) {
65 // authenticated visitor - here lie dragons
66 // If $remotecontact is true, we know that not only is this a remotely authenticated
67 // person, but that it is *our* contact, which is important in multi-user mode.
69 elseif($remote_contact) {
70 $gs = '<<>>'; // should be impossible to match
72 foreach($groups as $g)
73 $gs .= '|<' . intval($g) . '>';
76 " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
77 AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
78 AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
79 AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
81 intval($_SESSION['visitor_id']),
82 intval($_SESSION['visitor_id']),
88 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
89 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
90 `contact`.`network`, `contact`.`thumb`, `contact`.`self`,
91 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
92 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
93 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
94 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
95 AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ) AND `type` != 'remote' )
97 ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
98 intval($a->profile['uid']),
105 $cmnt_tpl = load_view_file('view/comment_item.tpl');
106 $like_tpl = load_view_file('view/like.tpl');
107 $tpl = load_view_file('view/wall_item.tpl');
108 $wallwall = load_view_file('view/wallwall_item.tpl');
110 $return_url = $_SESSION['return_url'] = $a->cmd;
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'])
124 foreach($r as $item) {
125 like_puller($a,$item,$alike,'like');
126 like_puller($a,$item,$dlike,'dislike');
129 foreach($r as $item) {
138 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
140 if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
141 && ($item['id'] != $item['parent']))
144 $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
145 || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
146 ? '<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="' . t('Private Message') . '" onclick="lockview(event,' . $item['id'] . ');" /></div>'
147 : '<div class="wall-item-lock"></div>');
149 if(can_write_wall($a,$a->profile['uid'])) {
150 if($item['id'] == $item['parent']) {
151 $likebuttons = replace_macros($like_tpl,array('$id' => $item['id']));
153 if($item['last-child']) {
154 $comment = replace_macros($cmnt_tpl,array(
155 '$return_path' => $_SESSION['return_url'],
156 '$type' => 'wall-comment',
157 '$id' => $item['item_id'],
158 '$parent' => $item['parent'],
159 '$profile_uid' => $a->profile['uid'],
160 '$mylink' => $contact['url'],
161 '$mytitle' => t('This is you'),
162 '$myphoto' => $contact['thumb'],
169 $profile_url = $item['url'];
173 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
175 if(($item['network'] === 'dfrn') && (! $item['self'] )) {
176 $profile_url = $redirect_url;
177 $sparkle = ' sparkle';
181 // Top-level wall post not written by the wall owner (wall-to-wall)
182 // First figure out who owns it.
186 if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
188 if($item['type'] === 'wall') {
189 // I do. Put me on the left of the wall-to-wall notice.
190 $owner_url = $a->contact['url'];
191 $owner_photo = $a->contact['thumb'];
192 $owner_name = $a->contact['name'];
193 $template = $wallwall;
196 if($item['type'] === 'remote' && ($item['owner-link'] != $item['author-link'])) {
198 $owner_url = $item['owner-link'];
199 $owner_photo = $item['owner-avatar'];
200 $owner_name = $item['owner-name'];
201 $template = $wallwall;
203 // If it is our contact, use a friendly redirect link
204 if(($item['owner-link'] == $item['url']) && ($item['network'] === 'dfrn')) {
205 $owner_url = $redirect_url;
206 $osparkle = ' sparkle';
213 $diff_author = (($item['url'] !== $item['author-link']) ? true : false);
215 $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
216 $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $item['thumb']);
218 $profile_link = $profile_url;
220 if(($item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
221 $drop = replace_macros(load_view_file('view/wall_item_drop.tpl'), array('$id' => $item['id']));
223 $drop = replace_macros(load_view_file('view/wall_fake_drop.tpl'), array('$id' => $item['id']));
225 $like = ((isset($alike[$item['id']])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
226 $dislike = ((isset($dlike[$item['id']])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
228 $location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
229 $coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
232 $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
234 $location = '<span class="smalltext">' . $coord . '</span>';
237 $indent = (($item['parent'] != $item['item_id']) ? ' comment' : '');
239 if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
243 $o .= replace_macros($template,array(
244 '$id' => $item['item_id'],
245 '$profile_url' => $profile_link,
246 '$name' => $profile_name,
247 '$sparkle' => $sparkle,
248 '$osparkle' => $osparkle,
249 '$thumb' => $profile_avatar,
250 '$title' => $item['title'],
251 '$body' => smilies(bbcode($item['body'])),
252 '$ago' => relative_date($item['created']),
254 '$location' => $location,
255 '$indent' => $indent,
256 '$owner_url' => $owner_url,
257 '$owner_photo' => $owner_photo,
258 '$owner_name' => $owner_name,
260 '$vote' => $likebuttons,
262 '$dislike' => $dislike,
263 '$comment' => $comment
269 $r = q("SELECT `id` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
274 if($r[0]['deleted']) {
275 notice( t('Item has been removed.') . EOL );
278 notice( t('Permission denied.') . EOL );
282 notice( t('Item not found.') . EOL );