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`,
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 if(! is_array($alike[$item['parent'] . '-l']))
122 $alike[$item['parent'] . '-l'] = array();
123 $alike[$item['parent']] ++;
124 $alike[$item['parent'] . '-l'][] = '<a href="'. $url . '">' . $item['name'] . '</a>';
126 if(($item['verb'] == ACTIVITY_DISLIKE) && ($item['id'] != $item['parent'])) {
128 if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self']))
129 $url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
130 if(! is_array($dlike[$item['parent'] . '-l']))
131 $dlike[$item['parent'] . '-l'] = array();
132 $dlike[$item['parent']] ++;
133 $dlike[$item['parent'] . '-l'][] = '<a href="'. $url . '">' . $item['name'] . '</a>';
139 foreach($r as $item) {
143 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
145 if((($item['verb'] == ACTIVITY_LIKE) || ($item['verb'] == ACTIVITY_DISLIKE)) && ($item['id'] != $item['parent']))
148 if(can_write_wall($a,$a->profile['uid'])) {
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('Me'),
158 '$myphoto' => $contact['thumb'],
165 $profile_url = $item['url'];
168 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
171 // Top-level wall post not written by the wall owner (wall-to-wall)
172 // First figure out who owns it.
174 if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
176 if($item['type'] === 'wall') {
177 // I do. Put me on the left of the wall-to-wall notice.
178 $owner_url = $a->contact['url'];
179 $owner_photo = $a->contact['thumb'];
180 $owner_name = $a->contact['name'];
181 $template = $wallwall;
184 if($item['type'] === 'remote' && ($item['owner-link'] != $item['author-link'])) {
186 $owner_url = $item['owner-link'];
187 $owner_photo = $item['owner-avatar'];
188 $owner_name = $item['owner-name'];
189 $template = $wallwall;
191 // If it is our contact, use a friendly redirect link
192 if(($item['owner-link'] == $item['url']) && ($item['rel'] == REL_VIP || $item['rel'] == REL_BUD))
193 $owner_url = $redirect_url;
194 $owner_url = $redirect_url;
199 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
200 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
201 $profile_link = $profile_url;
205 if(($item['contact-id'] == $_SESSION['visitor_id']) || ($item['uid'] == get_uid()))
206 $drop = replace_macros(load_view_file('view/wall_item_drop.tpl'), array('$id' => $item['id']));
208 $like = (($alike[$item['id']]) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
209 $dislike = (($dlike[$item['id']]) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
212 if($item['id'] == $item['parent']) {
213 $likebuttons = replace_macros($like_tpl,array('$id' => $item['id']));
218 $o .= replace_macros($template,array(
219 '$id' => $item['item_id'],
220 '$profile_url' => $profile_link,
221 '$name' => $profile_name,
222 '$thumb' => $profile_avatar,
223 '$title' => $item['title'],
224 '$body' => bbcode($item['body']),
225 '$ago' => relative_date($item['created']),
226 '$location' => (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : ''),
227 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
228 '$owner_url' => $owner_url,
229 '$owner_photo' => $owner_photo,
230 '$owner_name' => $owner_name,
232 '$vote' => $likebuttons,
234 '$dislike' => $dislike,
235 '$comment' => $comment
241 $r = q("SELECT `id` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
246 if($r[0]['deleted']) {
247 notice( t('Item has been removed.') . EOL );
250 notice( t('Permission denied.') . EOL );
254 notice( t('Item not found.') . EOL );