4 function network_init(&$a) {
5 require_once('include/group.php');
6 $a->page['aside'] .= group_side('network','network');
10 function network_content(&$a, $update = false) {
15 require_once("include/bbcode.php");
17 $contact_id = $a->cid;
22 // pull out the group here because the updater might have different args
24 $group = intval($a->argv[1]);
26 $_SESSION['return_url'] = $a->cmd;
28 $tpl = file_get_contents('view/jot-header.tpl');
30 $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
32 require_once('view/acl_selectors.php');
34 $tpl = file_get_contents("view/jot.tpl");
36 $o .= replace_macros($tpl,array(
37 '$return_path' => $a->cmd,
38 '$baseurl' => $a->get_baseurl(),
39 '$visitor' => 'block',
40 '$lockstate' => 'unlock',
41 '$acl' => populate_acl($a->user),
42 '$profile_uid' => $_SESSION['uid']
46 // The special div is needed for liveUpdate to kick in for this page.
47 // We only launch liveUpdate if you are on the front page, you aren't
48 // filtering by group and also you aren't writing a comment (the last
49 // criteria is discovered in javascript).
51 if($a->pager['start'] == 0 && $a->argc == 1)
52 $o .= '<div id="live-network"></div>' . "\r\n";
55 // We aren't going to try and figure out at the item, group, and page level
56 // which items you've seen and which you haven't. You're looking at some
57 // subset of items, so just mark everything seen.
59 $r = q("UPDATE `item` SET `unseen` = 0
60 WHERE `unseen` = 1 AND `uid` = %d",
61 intval($_SESSION['uid'])
64 // We don't have to deal with ACL's on this page. You're looking at everything
65 // that belongs to you, hence you can see all of it. We will filter by group if
68 // TODO: Perhaps we should limit the group filter to those with the group in the ACL,
69 // rather than just the contact-id of the post.
70 // Otherwise we're not showing complete conversations, unless all the conversants
71 // happen to be in the group.
76 $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
78 intval($_SESSION['uid'])
81 notice("No such group");
82 goaway($a->get_baseurl() . '/network');
86 $contacts = expand_groups(array($group));
87 $contacts[] = $_SESSION['cid'];
88 $contact_str = implode(',',$contacts);
89 $sql_extra = dbesc(" AND `contact`.`id` IN ( $contact_str ) ");
90 $o = '<h4>' . t('Group: ') . $r[0]['name'] . '</h4>' . $o;
94 $r = q("SELECT COUNT(*) AS `total`
95 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
96 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
97 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
99 intval($_SESSION['uid'])
103 $a->set_pager_total($r[0]['total']);
105 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
106 `contact`.`name`, `contact`.`photo`, `contact`.`url`,
107 `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
108 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
109 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
110 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
111 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
113 ORDER BY `parent` DESC, `created` ASC LIMIT %d ,%d ",
114 intval($_SESSION['uid']),
115 intval($a->pager['start']),
116 intval($a->pager['itemspage'])
120 $cmnt_tpl = file_get_contents('view/comment_item.tpl');
122 $tpl = file_get_contents('view/wall_item.tpl');
123 $wallwall = file_get_contents('view/wallwall_item.tpl');
126 foreach($r as $item) {
132 $profile_url = $item['url'];
133 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
136 // Top-level wall post not written by the wall owner (wall-to-wall)
137 // First figure out who owns it.
139 if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
141 if($item['type'] == 'wall') {
142 // I do. Put me on the left of the wall-to-wall notice.
143 $owner_url = $a->contact['url'];
144 $owner_photo = $a->contact['thumb'];
145 $owner_name = $a->contact['name'];
146 $template = $wallwall;
149 if($item['type'] == 'remote' && ($item['owner-link'] != $item['author-link'])) {
151 $owner_url = $item['owner-link'];
152 $owner_photo = $item['owner-avatar'];
153 $owner_name = $item['owner-name'];
154 $template = $wallwall;
156 // If it is our contact, use a friendly redirect link
157 if($item['owner-link'] == $item['url'])
158 $owner_url = $redirect_url;
164 $return_url = $_SESSION['return_url'];
166 $return_url = $_SESSION['return_url'] = $a->cmd;
169 if($item['last-child']) {
170 $comment = replace_macros($cmnt_tpl,array(
171 '$return_path' => $_SESSION['return_url'],
172 '$type' => 'net-comment',
173 '$id' => $item['item_id'],
174 '$parent' => $item['parent'],
175 '$profile_uid' => $_SESSION['uid'],
176 '$mylink' => $a->contact['url'],
177 '$mytitle' => t('Me'),
178 '$myphoto' => $a->contact['thumb'],
184 $drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id']));
188 if(($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] ))
189 $profile_url = $redirect_url;
191 $photo = $item['photo'];
192 $thumb = $item['thumb'];
194 // Post was remotely authored.
196 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
197 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $thumb);
199 $profile_link = $profile_url;
201 // Can we use our special contact URL for this author?
203 if(strlen($item['author-link'])) {
204 if($item['author-link'] == $item['url'])
205 $profile_link = $redirect_url;
207 $profile_link = $item['author-link'];
212 $o .= replace_macros($template,array(
213 '$id' => $item['item_id'],
214 '$profile_url' => $profile_link,
215 '$name' => $profile_name,
216 '$thumb' => $profile_avatar,
217 '$title' => $item['title'],
218 '$body' => bbcode($item['body']),
219 '$ago' => relative_date($item['created']),
220 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
221 '$owner_url' => $owner_url,
222 '$owner_photo' => $owner_photo,
223 '$owner_name' => $owner_name,
225 '$comment' => $comment