4 function display_content(&$a) {
6 require_once('mod/profile.php');
9 $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
13 notice( t('Item not found.') . EOL);
17 require_once("include/bbcode.php");
18 require_once('include/security.php');
27 $remote_contact = false;
30 $contact_id = $_SESSION['visitor_id'];
31 $groups = init_groups_visitor($contact_id);
32 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
34 intval($a->profile['uid'])
38 $remote_contact = true;
42 if(! $remote_contact) {
44 $contact_id = $_SESSION['cid'];
45 $contact = $a->contact;
58 // Profile owner - everything is visible
60 if(local_user() && (get_uid() == $a->profile['uid'])) {
64 // authenticated visitor - here lie dragons
65 // If $remotecontact is true, we know that not only is this a remotely authenticated
66 // person, but that it is *our* contact, which is important in multi-user mode.
68 elseif($remote_contact) {
69 $gs = '<<>>'; // should be impossible to match
71 foreach($groups as $g)
72 $gs .= '|<' . intval($g) . '>';
75 " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
76 AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
77 AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
78 AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
80 intval($_SESSION['visitor_id']),
81 intval($_SESSION['visitor_id']),
87 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
88 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
89 `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
90 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
91 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
92 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
93 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
94 AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))
96 ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
97 intval($a->profile['uid']),
103 $cmnt_tpl = load_view_file('view/comment_item.tpl');
104 $like_tpl = load_view_file('view/like.tpl');
105 $tpl = load_view_file('view/wall_item.tpl');
106 $wallwall = load_view_file('view/wallwall_item.tpl');
108 $return_url = $_SESSION['return_url'] = $a->cmd;
115 foreach($r as $item) {
117 if(($item['verb'] == ACTIVITY_LIKE) && ($item['id'] != $item['parent'])) {
119 if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self'])) {
120 $url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
121 $sparkle = ' class="sparkle"';
123 if(! is_array($alike[$item['parent'] . '-l']))
124 $alike[$item['parent'] . '-l'] = array();
125 $alike[$item['parent']] ++;
126 $alike[$item['parent'] . '-l'][] = '<a href="'. $url . '"' . $sparkle . '>' . $item['name'] . '</a>';
128 if(($item['verb'] == ACTIVITY_DISLIKE) && ($item['id'] != $item['parent'])) {
130 if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self'])) {
131 $url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
132 $sparkle = ' class="sparkle"';
134 if(! is_array($dlike[$item['parent'] . '-l']))
135 $dlike[$item['parent'] . '-l'] = array();
136 $dlike[$item['parent']] ++;
137 $dlike[$item['parent'] . '-l'][] = '<a href="'. $url . '"' . $sparkle . '>' . $item['name'] . '</a>';
143 foreach($r as $item) {
147 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
149 if((($item['verb'] == ACTIVITY_LIKE) || ($item['verb'] == ACTIVITY_DISLIKE)) && ($item['id'] != $item['parent']))
152 $lock = (($item['uid'] == get_uid()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
153 || strlen($item['deny_cid']) || strlen($item['deny_gid']))
154 ? '<div class="wall-item-lock"><img src="images/lock_icon.gif" alt="Private Message" /></div>'
155 : '<div class="wall-item-lock"></div>');
158 if(can_write_wall($a,$a->profile['uid'])) {
159 if($item['last-child']) {
160 $comment = replace_macros($cmnt_tpl,array(
161 '$return_path' => $_SESSION['return_url'],
162 '$type' => 'wall-comment',
163 '$id' => $item['item_id'],
164 '$parent' => $item['parent'],
165 '$profile_uid' => $a->profile['uid'],
166 '$mylink' => $contact['url'],
167 '$mytitle' => t('This is you'),
168 '$myphoto' => $contact['thumb'],
175 $profile_url = $item['url'];
179 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
181 if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self'] )) {
182 $profile_url = $redirect_url;
183 $sparkle = ' sparkle';
187 // Top-level wall post not written by the wall owner (wall-to-wall)
188 // First figure out who owns it.
192 if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
194 if($item['type'] === 'wall') {
195 // I do. Put me on the left of the wall-to-wall notice.
196 $owner_url = $a->contact['url'];
197 $owner_photo = $a->contact['thumb'];
198 $owner_name = $a->contact['name'];
199 $template = $wallwall;
202 if($item['type'] === 'remote' && ($item['owner-link'] != $item['author-link'])) {
204 $owner_url = $item['owner-link'];
205 $owner_photo = $item['owner-avatar'];
206 $owner_name = $item['owner-name'];
207 $template = $wallwall;
209 // If it is our contact, use a friendly redirect link
210 if(($item['owner-link'] == $item['url']) && ($item['rel'] == REL_VIP || $item['rel'] == REL_BUD)) {
211 $owner_url = $redirect_url;
212 $osparkle = ' sparkle';
219 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
220 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
221 $profile_link = $profile_url;
225 if(($item['contact-id'] == $_SESSION['visitor_id']) || ($item['uid'] == get_uid()))
226 $drop = replace_macros(load_view_file('view/wall_item_drop.tpl'), array('$id' => $item['id']));
228 $like = (($alike[$item['id']]) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
229 $dislike = (($dlike[$item['id']]) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
232 if($item['id'] == $item['parent']) {
233 $likebuttons = replace_macros($like_tpl,array('$id' => $item['id']));
238 $o .= replace_macros($template,array(
239 '$id' => $item['item_id'],
240 '$profile_url' => $profile_link,
241 '$name' => $profile_name,
242 '$sparkle' => $sparkle,
243 '$osparkle' => $osparkle,
244 '$thumb' => $profile_avatar,
245 '$title' => $item['title'],
246 '$body' => bbcode($item['body']),
247 '$ago' => relative_date($item['created']),
249 '$location' => (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : ''),
250 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
251 '$owner_url' => $owner_url,
252 '$owner_photo' => $owner_photo,
253 '$owner_name' => $owner_name,
255 '$vote' => $likebuttons,
257 '$dislike' => $dislike,
258 '$comment' => $comment
264 $r = q("SELECT `id` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
269 if($r[0]['deleted']) {
270 notice( t('Item has been removed.') . EOL );
273 notice( t('Permission denied.') . EOL );
277 notice( t('Item not found.') . EOL );