4 function display_content(&$a) {
6 $o = '<div id="live-display"></div>' . "\r\n";
8 require_once('mod/profile.php');
11 $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
15 notice( t('Item not found.') . EOL);
19 require_once("include/bbcode.php");
20 require_once('include/security.php');
29 $remote_contact = false;
32 $contact_id = $_SESSION['visitor_id'];
33 $groups = init_groups_visitor($contact_id);
34 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
36 intval($a->profile['uid'])
40 $remote_contact = true;
44 if(! $remote_contact) {
46 $contact_id = $_SESSION['cid'];
47 $contact = $a->contact;
60 // Profile owner - everything is visible
62 if(local_user() && (local_user() == $a->profile['uid'])) {
66 // authenticated visitor - here lie dragons
67 // If $remotecontact is true, we know that not only is this a remotely authenticated
68 // person, but that it is *our* contact, which is important in multi-user mode.
70 elseif($remote_contact) {
71 $gs = '<<>>'; // should be impossible to match
73 foreach($groups as $g)
74 $gs .= '|<' . intval($g) . '>';
77 " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
78 AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
79 AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
80 AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
82 intval($_SESSION['visitor_id']),
83 intval($_SESSION['visitor_id']),
89 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
90 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
91 `contact`.`network`, `contact`.`thumb`, `contact`.`self`,
92 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
93 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
94 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
95 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
96 AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))
98 ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
99 intval($a->profile['uid']),
106 $cmnt_tpl = load_view_file('view/comment_item.tpl');
107 $like_tpl = load_view_file('view/like.tpl');
108 $tpl = load_view_file('view/wall_item.tpl');
109 $wallwall = load_view_file('view/wallwall_item.tpl');
111 $return_url = $_SESSION['return_url'] = $a->cmd;
118 if((local_user()) && (local_user() == $a->profile['uid'])) {
119 q("UPDATE `item` SET `unseen` = 0
120 WHERE `parent` = %d AND `unseen` = 1",
121 intval($r[0]['parent'])
125 foreach($r as $item) {
126 like_puller($a,$item,$alike,'like');
127 like_puller($a,$item,$dlike,'dislike');
130 foreach($r as $item) {
134 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
136 if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
137 && ($item['id'] != $item['parent']))
140 $lock = (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
141 || strlen($item['deny_cid']) || strlen($item['deny_gid']))
142 ? '<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="' . t('Private Message') . '" onclick="lockview(event,' . $item['id'] . ');" /></div>'
143 : '<div class="wall-item-lock"></div>');
145 if(can_write_wall($a,$a->profile['uid'])) {
146 if($item['id'] == $item['parent']) {
147 $likebuttons = replace_macros($like_tpl,array('$id' => $item['id']));
149 if($item['last-child']) {
150 $comment = replace_macros($cmnt_tpl,array(
151 '$return_path' => $_SESSION['return_url'],
152 '$type' => 'wall-comment',
153 '$id' => $item['item_id'],
154 '$parent' => $item['parent'],
155 '$profile_uid' => $a->profile['uid'],
156 '$mylink' => $contact['url'],
157 '$mytitle' => t('This is you'),
158 '$myphoto' => $contact['thumb'],
165 $profile_url = $item['url'];
169 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
171 if(($item['network'] === 'dfrn') && (! $item['self'] )) {
172 $profile_url = $redirect_url;
173 $sparkle = ' sparkle';
177 // Top-level wall post not written by the wall owner (wall-to-wall)
178 // First figure out who owns it.
182 if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
184 if($item['type'] === 'wall') {
185 // I do. Put me on the left of the wall-to-wall notice.
186 $owner_url = $a->contact['url'];
187 $owner_photo = $a->contact['thumb'];
188 $owner_name = $a->contact['name'];
189 $template = $wallwall;
192 if($item['type'] === 'remote' && ($item['owner-link'] != $item['author-link'])) {
194 $owner_url = $item['owner-link'];
195 $owner_photo = $item['owner-avatar'];
196 $owner_name = $item['owner-name'];
197 $template = $wallwall;
199 // If it is our contact, use a friendly redirect link
200 if(($item['owner-link'] == $item['url']) && ($item['network'] === 'dfrn')) {
201 $owner_url = $redirect_url;
202 $osparkle = ' sparkle';
209 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
210 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
211 $profile_link = $profile_url;
213 if(($item['contact-id'] == $_SESSION['visitor_id']) || ($item['uid'] == local_user()))
214 $drop = replace_macros(load_view_file('view/wall_item_drop.tpl'), array('$id' => $item['id']));
216 $drop = replace_macros(load_view_file('view/wall_fake_drop.tpl'), array('$id' => $item['id']));
218 $like = (($alike[$item['id']]) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
219 $dislike = (($dlike[$item['id']]) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
220 $location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
221 $coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
224 $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
226 $location = '<span class="smalltext">' . $coord . '</span>';
229 $o .= replace_macros($template,array(
230 '$id' => $item['item_id'],
231 '$profile_url' => $profile_link,
232 '$name' => $profile_name,
233 '$sparkle' => $sparkle,
234 '$osparkle' => $osparkle,
235 '$thumb' => $profile_avatar,
236 '$title' => $item['title'],
237 '$body' => bbcode($item['body']),
238 '$ago' => relative_date($item['created']),
240 '$location' => $location,
241 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
242 '$owner_url' => $owner_url,
243 '$owner_photo' => $owner_photo,
244 '$owner_name' => $owner_name,
246 '$vote' => $likebuttons,
248 '$dislike' => $dislike,
249 '$comment' => $comment
255 $r = q("SELECT `id` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
260 if($r[0]['deleted']) {
261 notice( t('Item has been removed.') . EOL );
264 notice( t('Permission denied.') . EOL );
268 notice( t('Item not found.') . EOL );