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',true);
28 function network_content(&$a, $update = 0) {
30 require_once('include/conversation.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 . '>');
58 if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
59 $plural_form = sprintf( tt('%d member', '%d members', $t), $t);
60 notice( sprintf( t('Warning: This group contains %s from an insecure network.'), $plural_form ) . EOL);
61 notice( t('Private messages to this group are at risk of public disclosure.') . EOL);
65 $o .= '<script> $(document).ready(function() { $(\'#nav-network-link\').addClass(\'nav-selected\'); });</script>';
67 $_SESSION['return_url'] = $a->cmd;
69 $geotag = (($a->user['allow_location']) ? load_view_file('view/jot_geotag.tpl') : '');
71 $tpl = load_view_file('view/jot-header.tpl');
73 $a->page['htmlhead'] .= replace_macros($tpl, array(
74 '$baseurl' => $a->get_baseurl(),
76 '$nickname' => $a->user['nickname'],
77 '$linkurl' => t('Please enter a link URL:'),
78 '$utubeurl' => t('Please enter a YouTube link:'),
79 '$vidurl' => t("Please enter a video\x28.ogg\x29 link/URL:"),
80 '$audurl' => t("Please enter an audio\x28.ogg\x29 link/URL:"),
81 '$whereareu' => t('Where are you right now?'),
82 '$title' => t('Enter a title for this item')
86 $tpl = load_view_file("view/jot.tpl");
88 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'])))))
91 $lockstate = 'unlock';
93 $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
97 call_hooks('jot_tool', $jotplugins);
98 call_hooks('jot_networks', $jotnets);
100 $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
102 $o .= replace_macros($tpl,array(
103 '$return_path' => $a->cmd,
105 '$share' => t('Share'),
106 '$upload' => t('Upload photo'),
107 '$weblink' => t('Insert web link'),
108 '$youtube' => t('Insert YouTube video'),
109 '$video' => t('Insert Vorbis [.ogg] video'),
110 '$audio' => t('Insert Vorbis [.ogg] audio'),
111 '$setloc' => t('Set your location'),
112 '$noloc' => t('Clear browser location'),
113 '$title' => t('Set title'),
114 '$wait' => t('Please wait'),
115 '$permset' => t('Permission settings'),
118 '$baseurl' => $a->get_baseurl(),
119 '$defloc' => $a->user['default-location'],
120 '$visitor' => 'block',
121 '$emailcc' => t('CC: email addresses'),
122 '$jotnets' => $jotnets,
123 '$emtitle' => t('Example: bob@example.com, mary@example.com'),
124 '$lockstate' => $lockstate,
125 '$acl' => populate_acl((($group) ? $group_acl : $a->user), $celeb),
126 '$bang' => (($group) ? '!' : ''),
127 '$profile_uid' => local_user()
131 // The special div is needed for liveUpdate to kick in for this page.
132 // We only launch liveUpdate if you are on the front page, you aren't
133 // filtering by group and also you aren't writing a comment (the last
134 // criteria is discovered in javascript).
136 $o .= '<div id="live-network"></div>' . "\r\n";
137 $o .= "<script> var profile_uid = " . $_SESSION['uid']
138 . "; var netargs = '" . substr($a->cmd,8)
139 . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
143 // We aren't going to try and figure out at the item, group, and page level
144 // which items you've seen and which you haven't. You're looking at some
145 // subset of items, so just mark everything seen.
147 $r = q("UPDATE `item` SET `unseen` = 0
148 WHERE `unseen` = 1 AND `uid` = %d",
149 intval($_SESSION['uid'])
152 // We don't have to deal with ACL's on this page. You're looking at everything
153 // that belongs to you, hence you can see all of it. We will filter by group if
156 $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` ) ";
159 $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
161 intval($_SESSION['uid'])
166 notice( t('No such group') . EOL );
167 goaway($a->get_baseurl() . '/network');
168 return; // NOTREACHED
171 $contacts = expand_groups(array($group));
172 if((is_array($contacts)) && count($contacts)) {
173 $contact_str = implode(',',$contacts);
176 $contact_str = ' 0 ';
177 notice( t('Group is empty'));
180 $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `contact-id` IN ( $contact_str )) ";
181 $o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
184 if((! $group) && (! $update))
185 $o .= get_birthdays();
188 $r = q("SELECT COUNT(*) AS `total`
189 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
190 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
191 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
193 intval($_SESSION['uid'])
197 $a->set_pager_total($r[0]['total']);
198 $a->set_pager_itemspage(40);
204 // "New Item View" - show all items unthreaded in reverse created date order
206 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
207 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
208 `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
209 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
210 FROM `item`, `contact`
211 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
212 AND `contact`.`id` = `item`.`contact-id`
213 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
215 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
216 intval($_SESSION['uid']),
217 intval($a->pager['start']),
218 intval($a->pager['itemspage'])
224 // Normal conversation view
225 // First fetch a known number of parent items
227 $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`
228 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
229 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
230 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
231 AND `item`.`parent` = `item`.`id`
233 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
234 intval(local_user()),
235 intval($a->pager['start']),
236 intval($a->pager['itemspage'])
240 // Then fetch all the children of the parents that are on this page
242 $parents_arr = array();
247 $parents_arr[] = $rr['item_id'];
248 $parents_str = implode(', ', $parents_arr);
250 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
251 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
252 `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
253 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
254 FROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent`=`p`.`id`) as `parentitem`, `contact`
255 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
256 AND `contact`.`id` = `item`.`contact-id`
257 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
258 AND `item`.`parent` = `parentitem`.`id` AND `item`.`parent` IN ( %s )
260 ORDER BY `parentitem`.`created` DESC, `item`.`gravity` ASC, `item`.`created` ASC ",
261 intval(local_user()),
267 // Set this so that the conversation function can find out contact info for our wall-wall items
268 $a->page_contact = $a->contact;
270 $mode = (($nouveau) ? 'network-new' : 'network');
272 $o .= conversation($a,$r,$mode,$update);
277 $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>';