4 function network_init(&$a) {
9 function network_content(&$a, $update = false) {
14 require_once("include/bbcode.php");
16 $contact_id = $a->cid;
22 $tpl = file_get_contents('view/jot-header.tpl');
24 $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
26 require_once('view/acl_selectors.php');
28 $tpl = file_get_contents("view/jot.tpl");
30 $o .= replace_macros($tpl,array(
31 '$return_path' => $a->cmd,
32 '$baseurl' => $a->get_baseurl(),
33 '$visitor' => 'block',
34 '$lockstate' => 'unlock',
35 '$acl' => populate_acl(),
36 '$profile_uid' => $_SESSION['uid']
40 $o .= '<div id="live-network"></div>' . "\r\n";
43 $r = q("UPDATE `item` SET `unseen` = 0
44 WHERE `unseen` = 1 AND `uid` = %d",
45 intval($_SESSION['uid'])
53 $r = q("SELECT COUNT(*) AS `total`
54 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
55 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
56 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
58 intval($_SESSION['uid'])
62 $a->set_pager_total($r[0]['total']);
64 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
65 `contact`.`name`, `contact`.`photo`, `contact`.`url`,
66 `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
67 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
68 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
69 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
70 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
72 ORDER BY `parent` DESC, `created` ASC LIMIT %d ,%d ",
73 intval($_SESSION['uid']),
74 intval($a->pager['start']),
75 intval($a->pager['itemspage'])
79 $cmnt_tpl = file_get_contents('view/comment_item.tpl');
81 $tpl = file_get_contents('view/wall_item.tpl');
82 $wallwall = file_get_contents('view/wallwall_item.tpl');
85 foreach($r as $item) {
91 $profile_url = $item['url'];
92 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
95 // Top-level wall post not written by the wall owner (wall-to-wall)
96 // First figure out who owns it.
98 if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
100 if($item['type'] == 'wall') {
101 // I do. Put me on the left of the wall-to-wall notice.
102 $owner_url = $a->contact['url'];
103 $owner_photo = $a->contact['thumb'];
104 $owner_name = $a->contact['name'];
105 $template = $wallwall;
108 if($item['type'] == 'remote' && ($item['owner-link'] != $item['author-link'])) {
110 $owner_url = $item['owner-link'];
111 $owner_photo = $item['owner-avatar'];
112 $owner_name = $item['owner-name'];
113 $template = $wallwall;
115 // If it is our contact, use a friendly redirect link
116 if($item['owner-link'] == $item['url'])
117 $owner_url = $redirect_url;
122 if($item['last-child']) {
123 $comment = replace_macros($cmnt_tpl,array(
124 '$return_path' => $a->cmd,
125 '$id' => $item['item_id'],
126 '$parent' => $item['parent'],
127 '$profile_uid' => $_SESSION['uid'],
133 if(($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] ))
134 $profile_url = $redirect_url;
136 $photo = $item['photo'];
137 $thumb = $item['thumb'];
139 // Post was remotely authored.
141 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
142 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $thumb);
144 $profile_link = $profile_url;
146 // Can we use our special contact URL for this author?
148 if(strlen($item['author-link'])) {
149 if($item['author-link'] == $item['url'])
150 $profile_link = $redirect_url;
152 $profile_link = $item['author-link'];
157 $o .= replace_macros($template,array(
158 '$id' => $item['item_id'],
159 '$profile_url' => $profile_link,
160 '$name' => $profile_name,
161 '$thumb' => $profile_avatar,
162 '$body' => bbcode($item['body']),
163 '$ago' => relative_date($item['created']),
164 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
165 '$owner_url' => $owner_url,
166 '$owner_photo' => $owner_photo,
167 '$owner_name' => $owner_name,
168 '$comment' => $comment