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` = %d )
96 ORDER BY `parent` DESC, `id` ASC ",
97 intval($a->profile['uid']),
102 $cmnt_tpl = file_get_contents('view/comment_item.tpl');
104 $tpl = file_get_contents('view/wall_item.tpl');
106 $return_url = $_SESSION['return_url'] = $a->cmd;
109 foreach($r as $item) {
113 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
116 if(can_write_wall($a,$a->profile['uid'])) {
117 if($item['last-child']) {
118 $comment = replace_macros($cmnt_tpl,array(
119 '$return_path' => $_SESSION['return_url'],
120 '$type' => 'wall-comment',
121 '$id' => $item['item_id'],
122 '$parent' => $item['parent'],
123 '$profile_uid' => $a->profile['uid'],
124 '$mylink' => $contact['url'],
125 '$mytitle' => t('Me'),
126 '$myphoto' => $contact['thumb'],
133 $profile_url = $item['url'];
136 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
139 // Top-level wall post not written by the wall owner (wall-to-wall)
140 // First figure out who owns it.
142 if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
144 if($item['type'] == 'wall') {
145 // I do. Put me on the left of the wall-to-wall notice.
146 $owner_url = $a->contact['url'];
147 $owner_photo = $a->contact['thumb'];
148 $owner_name = $a->contact['name'];
149 $template = $wallwall;
152 if($item['type'] == 'remote' && ($item['owner-link'] != $item['author-link'])) {
154 $owner_url = $item['owner-link'];
155 $owner_photo = $item['owner-avatar'];
156 $owner_name = $item['owner-name'];
157 $template = $wallwall;
159 // If it is our contact, use a friendly redirect link
160 if(($item['owner-link'] == $item['url']) && ($item['rel'] == DIRECTION_IN || $item['rel'] == DIRECTION_BOTH))
161 $owner_url = $redirect_url;
162 $owner_url = $redirect_url;
170 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
171 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
172 $profile_link = $profile_url;
176 if(($item['contact-id'] == $_SESSION['visitor_id']) || ($item['uid'] == get_uid()))
177 $drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id']));
180 $o .= replace_macros($template,array(
181 '$id' => $item['item_id'],
182 '$profile_url' => $profile_link,
183 '$name' => $profile_name,
184 '$thumb' => $profile_avatar,
185 '$title' => $item['title'],
186 '$body' => bbcode($item['body']),
187 '$ago' => relative_date($item['created']),
188 '$location' => (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : ''),
189 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
191 '$comment' => $comment