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