4 function network_init(&$a) {
6 notice( t('Permission denied.') . EOL);
11 require_once('include/group.php');
12 if(! x($a->page,'aside'))
13 $a->page['aside'] = '';
15 $a->page['aside'] .= '<div id="network-new-link">';
17 if(($a->argc > 1 && $a->argv[1] === 'new') || ($a->argc > 2 && $a->argv[2] === 'new'))
18 $a->page['aside'] .= '<a href="' . $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . '">' . t('Normal View') . '</a>';
20 $a->page['aside'] .= '<a href="' . $a->get_baseurl() . '/' . $a->cmd . '/new' . '">' . t('New Item View') . '</a>';
22 $a->page['aside'] .= '</div>';
24 $a->page['aside'] .= group_side('network','network');
28 function network_content(&$a, $update = 0) {
35 require_once("include/bbcode.php");
37 $contact_id = $a->cid;
42 require_once('include/acl_selectors.php');
44 if(($a->argc > 2) && $a->argv[2] === 'new')
48 if($a->argv[1] === 'new')
51 $group = intval($a->argv[1]);
52 $group_acl = array('allow_gid' => '<' . $group . '>');
57 $o .= '<script> $(document).ready(function() { $(\'#nav-network-link\').addClass(\'nav-selected\'); });</script>';
59 $_SESSION['return_url'] = $a->cmd;
61 $geotag = (($a->user['allow_location']) ? load_view_file('view/jot_geotag.tpl') : '');
63 $tpl = load_view_file('view/jot-header.tpl');
65 $a->page['htmlhead'] .= replace_macros($tpl, array(
66 '$baseurl' => $a->get_baseurl(),
68 '$nickname' => $a->user['nickname']
72 $tpl = load_view_file("view/jot.tpl");
74 if(($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))))
77 $lockstate = 'unlock';
79 $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
83 call_hooks('jot_tool', $jotplugins);
84 call_hooks('jot_networks', $jotnets);
86 $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
88 $o .= replace_macros($tpl,array(
89 '$return_path' => $a->cmd,
91 '$share' => t('Share'),
92 '$upload' => t('Upload photo'),
93 '$weblink' => t('Insert web link'),
94 '$youtube' => t('Insert YouTube video'),
95 '$video' => t('Insert Vorbis [.ogg] video'),
96 '$audio' => t('Insert Vorbis [.ogg] audio'),
97 '$setloc' => t('Set your location'),
98 '$noloc' => t('Clear browser location'),
99 '$wait' => t('Please wait'),
100 '$permset' => t('Permission settings'),
103 '$baseurl' => $a->get_baseurl(),
104 '$defloc' => $a->user['default-location'],
105 '$visitor' => 'block',
106 '$emailcc' => t('CC: email addresses'),
107 '$jotnets' => $jotnets,
108 '$emtitle' => t('Example: bob@example.com, mary@example.com'),
109 '$lockstate' => $lockstate,
110 '$acl' => populate_acl((($group) ? $group_acl : $a->user), $celeb),
111 '$bang' => (($group) ? '!' : ''),
112 '$profile_uid' => $_SESSION['uid']
116 // The special div is needed for liveUpdate to kick in for this page.
117 // We only launch liveUpdate if you are on the front page, you aren't
118 // filtering by group and also you aren't writing a comment (the last
119 // criteria is discovered in javascript).
121 $o .= '<div id="live-network"></div>' . "\r\n";
122 $o .= "<script> var profile_uid = " . $_SESSION['uid']
123 . "; var netargs = '" . substr($a->cmd,8)
124 . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
128 // We aren't going to try and figure out at the item, group, and page level
129 // which items you've seen and which you haven't. You're looking at some
130 // subset of items, so just mark everything seen.
132 $r = q("UPDATE `item` SET `unseen` = 0
133 WHERE `unseen` = 1 AND `uid` = %d",
134 intval($_SESSION['uid'])
137 // We don't have to deal with ACL's on this page. You're looking at everything
138 // that belongs to you, hence you can see all of it. We will filter by group if
141 $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` ) ";
144 $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
146 intval($_SESSION['uid'])
151 notice( t('No such group') . EOL );
152 goaway($a->get_baseurl() . '/network');
153 return; // NOTREACHED
156 $contacts = expand_groups(array($group));
157 if((is_array($contacts)) && count($contacts)) {
158 $contact_str = implode(',',$contacts);
161 $contact_str = ' 0 ';
162 notice( t('Group is empty'));
165 $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `contact-id` IN ( $contact_str )) ";
166 $o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
169 if((! $group) && (! $update))
170 $o .= get_birthdays();
173 $r = q("SELECT COUNT(*) AS `total`
174 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
175 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
176 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
178 intval($_SESSION['uid'])
182 $a->set_pager_total($r[0]['total']);
185 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
186 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
187 `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
188 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
189 FROM `item`, `contact`
190 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
191 AND `contact`.`id` = `item`.`contact-id`
192 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
194 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
195 intval($_SESSION['uid']),
196 intval($a->pager['start']),
197 intval($a->pager['itemspage'])
201 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
202 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
203 `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
204 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
205 FROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent`=`p`.`id`) as `parentitem`, `contact`
206 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
207 AND `contact`.`id` = `item`.`contact-id`
208 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
209 AND `item`.`parent` = `parentitem`.`id`
211 ORDER BY `parentitem`.`created` DESC, `item`.`gravity` ASC, `item`.`created` ASC LIMIT %d ,%d ",
212 intval(local_user()),
213 intval($a->pager['start']),
214 intval($a->pager['itemspage'])
218 $author_contacts = extract_item_authors($r,local_user());
220 $cmnt_tpl = load_view_file('view/comment_item.tpl');
221 $like_tpl = load_view_file('view/like.tpl');
222 $tpl = load_view_file('view/wall_item.tpl');
223 $wallwall = load_view_file('view/wallwall_item.tpl');
232 $tpl = load_view_file('view/search_item.tpl');
233 $droptpl = load_view_file('view/wall_fake_drop.tpl');
235 foreach($r as $item) {
243 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
244 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
245 $profile_link = ((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
247 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
249 if(strlen($item['author-link'])) {
250 if(link_compare($item['author-link'],$item['url']) && ($item['network'] === 'dfrn') && (! $item['self'])) {
251 $profile_link = $redirect_url;
252 $sparkle = ' sparkle';
254 elseif(isset($author_contacts[$item['author-link']])) {
255 $profile_link = $a->get_baseurl() . '/redir/' . $author_contacts[$item['author-link']];
256 $sparkle = ' sparkle';
260 $location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
261 $coord = (($item['coord']) ? '<a target="map" title="' . $item['coord'] . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
264 $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
266 $location = '<span class="smalltext">' . $coord . '</span>';
269 $drop = replace_macros($droptpl,array('$id' => $item['id']));
270 $lock = '<div class="wall-item-lock"></div>';
272 $o .= replace_macros($tpl,array(
273 '$id' => $item['item_id'],
274 '$linktitle' => t('View $name\'s profile'),
275 '$profile_url' => $profile_link,
276 '$name' => $profile_name,
277 '$sparkle' => $sparkle,
279 '$thumb' => $profile_avatar,
280 '$title' => $item['title'],
281 '$body' => smilies(bbcode($item['body'])),
282 '$ago' => relative_date($item['created']),
283 '$location' => $location,
285 '$owner_url' => $owner_url,
286 '$owner_photo' => $owner_photo,
287 '$owner_name' => $owner_name,
289 '$conv' => '<a href="' . $a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $item['id'] . '">' . t('View in context') . '</a>'
301 foreach($r as $item) {
302 like_puller($a,$item,$alike,'like');
303 like_puller($a,$item,$dlike,'dislike');
306 foreach($r as $item) {
312 $owner_url = $owner_photo = $owner_name = '';
314 if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent']))
317 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
321 $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
322 || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
323 ? '<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="' . t('Private Message') . '" onclick="lockview(event,' . $item['id'] . ');" /></div>'
324 : '<div class="wall-item-lock"></div>');
327 // Top-level wall post not written by the wall owner (wall-to-wall)
328 // First figure out who owns it.
332 if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
334 if($item['type'] === 'wall') {
335 // I do. Put me on the left of the wall-to-wall notice.
336 $owner_url = $a->contact['url'];
337 $owner_photo = $a->contact['thumb'];
338 $owner_name = $a->contact['name'];
339 $template = $wallwall;
342 if(($item['type'] === 'remote') && (strlen($item['owner-link'])) && ($item['owner-link'] != $item['author-link'])) {
344 $owner_url = $item['owner-link'];
345 $owner_photo = $item['owner-avatar'];
346 $owner_name = $item['owner-name'];
347 $template = $wallwall;
349 // If it is our contact, use a friendly redirect link
350 if((link_compare($item['owner-link'],$item['url']))
351 && ($item['network'] === 'dfrn')) {
352 $owner_url = $redirect_url;
353 $osparkle = ' sparkle';
359 $return_url = $_SESSION['return_url'];
361 $return_url = $_SESSION['return_url'] = $a->cmd;
364 if($item['id'] == $item['parent']) {
365 $likebuttons = replace_macros($like_tpl,array(
366 '$id' => $item['id'],
367 '$likethis' => t("I like this \x28toggle\x29"),
368 '$nolike' => t("I don't like this \x28toggle\x29"),
369 '$share' => t('Share'),
370 '$wait' => t('Please wait')
374 if($item['last-child']) {
375 $comment = replace_macros($cmnt_tpl,array(
376 '$return_path' => '',
377 '$jsreload' => '', // $_SESSION['return_url'],
378 '$type' => 'net-comment',
379 '$id' => $item['item_id'],
380 '$parent' => $item['parent'],
381 '$profile_uid' => $_SESSION['uid'],
382 '$mylink' => $a->contact['url'],
383 '$mytitle' => t('This is you'),
384 '$myphoto' => $a->contact['thumb'],
389 $drop = replace_macros(load_view_file('view/wall_item_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
391 $photo = $item['photo'];
392 $thumb = $item['thumb'];
394 // Post was remotely authored.
396 $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true);
398 $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
399 $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $thumb);
401 if(strlen($item['author-link'])) {
402 $profile_link = $item['author-link'];
403 if(link_compare($item['author-link'],$item['url']) && ($item['network'] === 'dfrn') && (! $item['self'])) {
404 $profile_link = $redirect_url;
405 $sparkle = ' sparkle';
407 elseif(isset($author_contacts[$item['author-link']])) {
408 $profile_link = $a->get_baseurl() . '/redir/' . $author_contacts[$item['author-link']];
409 $sparkle = ' sparkle';
413 $profile_link = $item['url'];
415 $like = ((x($alike,$item['id'])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
416 $dislike = ((x($dlike,$item['id'])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
418 $location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
419 $coord = (($item['coord']) ? '<a target="map" title="' . $item['coord'] . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
422 $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
424 $location = '<span class="smalltext">' . $coord . '</span>';
427 $indent = (($item['parent'] != $item['item_id']) ? ' comment' : '');
429 if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
435 $tmp_item = replace_macros($template,array(
436 '$id' => $item['item_id'],
437 '$linktitle' => t('View $name\'s profile'),
438 '$olinktitle' => t('View $owner_name\'s profile'),
440 '$wall' => t('Wall-to-Wall'),
441 '$vwall' => t('via Wall-To-Wall:'),
442 '$profile_url' => $profile_link,
443 '$name' => $profile_name,
444 '$thumb' => $profile_avatar,
445 '$osparkle' => $osparkle,
446 '$sparkle' => $sparkle,
447 '$title' => $item['title'],
448 '$body' => smilies(bbcode($item['body'])),
449 '$ago' => relative_date($item['created']),
451 '$location' => $location,
452 '$indent' => $indent,
453 '$owner_url' => $owner_url,
454 '$owner_photo' => $owner_photo,
455 '$owner_name' => $owner_name,
456 '$plink' => get_plink($item),
458 '$vote' => $likebuttons,
460 '$dislike' => $dislike,
461 '$comment' => $comment
464 $arr = array('item' => $item, 'output' => $tmp_item);
465 call_hooks('display_item', $arr);
467 $o .= $arr['output'];
474 $o .= '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>';