4 function network_init(&$a) {
9 function network_content(&$a) {
14 require_once("include/bbcode.php");
16 $contact_id = $a->cid;
18 $r = q("UPDATE `item` SET `unseen` = 0
19 WHERE `unseen` = 1 AND `uid` = %d",
20 intval($_SESSION['uid'])
24 $tpl = file_get_contents('view/jot-header.tpl');
26 $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
28 require_once('view/acl_selectors.php');
30 $tpl = file_get_contents("view/jot.tpl");
32 $o .= replace_macros($tpl,array(
33 '$return_path' => $a->cmd,
34 '$baseurl' => $a->get_baseurl(),
35 '$visitor' => 'block',
36 '$lockstate' => 'unlock',
37 '$acl' => populate_acl(),
38 '$profile_uid' => $_SESSION['uid']
45 $r = q("SELECT COUNT(*) AS `total`
46 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
47 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
48 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
50 intval($_SESSION['uid'])
54 $a->set_pager_total($r[0]['total']);
56 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
57 `contact`.`name`, `contact`.`photo`, `contact`.`url`,
58 `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
59 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
60 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
61 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
62 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
64 ORDER BY `parent` DESC, `created` ASC LIMIT %d ,%d ",
65 intval($_SESSION['uid']),
66 intval($a->pager['start']),
67 intval($a->pager['itemspage'])
71 $cmnt_tpl = file_get_contents('view/comment_item.tpl');
73 $tpl = file_get_contents('view/wall_item.tpl');
74 $wallwall = file_get_contents('view/wallwall_item.tpl');
77 foreach($r as $item) {
83 $profile_url = $item['url'];
84 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
87 // Top-level wall post not written by the wall owner (wall-to-wall)
88 // First figure out who owns it.
90 if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
92 if($item['type'] == 'wall') {
93 // I do. Put me on the left of the wall-to-wall notice.
94 $owner_url = $a->contact['url'];
95 $owner_photo = $a->contact['thumb'];
96 $owner_name = $a->contact['name'];
97 $template = $wallwall;
100 if($item['type'] == 'remote' && ($item['owner-link'] != $item['author-link'])) {
102 $owner_url = $item['owner-link'];
103 $owner_photo = $item['owner-avatar'];
104 $owner_name = $item['owner-name'];
105 $template = $wallwall;
107 // If it is our contact, use a friendly redirect link
108 if($item['owner-link'] == $item['url'])
109 $owner_url = $redirect_url;
114 if($item['last-child']) {
115 $comment = replace_macros($cmnt_tpl,array(
116 '$return_path' => $a->cmd,
117 '$id' => $item['item_id'],
118 '$parent' => $item['parent'],
119 '$profile_uid' => $_SESSION['uid'],
125 if(($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] ))
126 $profile_url = $redirect_url;
128 $photo = $item['photo'];
129 $thumb = $item['thumb'];
131 // Post was remotely authored.
133 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
134 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $thumb);
136 $profile_link = $profile_url;
138 // Can we use our special contact URL for this author?
140 if(strlen($item['author-link'])) {
141 if($item['author-link'] == $item['url'])
142 $profile_link = $redirect_url;
144 $profile_link = $item['author-link'];
149 $o .= replace_macros($template,array(
150 '$id' => $item['item_id'],
151 '$profile_url' => $profile_link,
152 '$name' => $profile_name,
153 '$thumb' => $profile_avatar,
154 '$body' => bbcode($item['body']),
155 '$ago' => relative_date($item['created']),
156 '$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''),
157 '$owner_url' => $owner_url,
158 '$owner_photo' => $owner_photo,
159 '$owner_name' => $owner_name,
160 '$comment' => $comment