4 function network_init(&$a) {
9 function network_content(&$a) {
14 require_once("include/bbcode.php");
16 $contact_id = $a->cid;
19 $tpl = file_get_contents('view/jot-header.tpl');
21 $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
23 require_once('view/acl_selectors.php');
25 $tpl = file_get_contents("view/jot.tpl");
27 $o .= replace_macros($tpl,array(
28 '$return_path' => $a->cmd,
29 '$baseurl' => $a->get_baseurl(),
30 '$visitor' => 'block',
31 '$lockstate' => 'unlock',
32 '$acl' => populate_acl(),
33 '$profile_uid' => $_SESSION['uid']
40 $r = q("SELECT COUNT(*) AS `total`
41 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
42 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
43 AND `contact`.`blocked` = 0
45 intval($_SESSION['uid'])
49 $a->set_pager_total($r[0]['total']);
51 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
52 `contact`.`name`, `contact`.`photo`, `contact`.`url`,
53 `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
54 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
55 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
56 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
57 AND `contact`.`blocked` = 0
59 ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
60 intval($_SESSION['uid']),
61 intval($a->pager['start']),
62 intval($a->pager['itemspage'])
66 $cmnt_tpl = file_get_contents('view/comment_item.tpl');
68 $tpl = file_get_contents('view/wall_item.tpl');
69 $wallwall = file_get_contents('view/wallwall_item.tpl');
72 foreach($r as $item) {
78 $profile_url = $item['url'];
79 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
82 // Top-level wall post not written by the wall owner (wall-to-wall)
83 // First figure out who owns it.
85 if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
87 if($item['type'] == 'wall') {
88 // I do. Put me on the left of the wall-to-wall notice.
89 $owner_url = $a->contact['url'];
90 $owner_photo = $a->contact['thumb'];
91 $owner_name = $a->contact['name'];
92 $template = $wallwall;
95 if($item['type'] == 'remote' && ($item['owner-link'] != $item['remote-link'])) {
97 $owner_url = $item['owner-link'];
98 $owner_photo = $item['owner-avatar'];
99 $owner_name = $item['owner-name'];
100 $template = $wallwall;
102 // If it is our contact, use a friendly redirect link
103 if($item['owner-link'] == $item['url'])
104 $owner_url = $redirect_url;
109 if($item['last-child']) {
110 $comment = replace_macros($cmnt_tpl,array(
111 '$id' => $item['item_id'],
112 '$parent' => $item['parent'],
113 '$profile_uid' => $_SESSION['uid'],
119 if(($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] ))
120 $profile_url = $redirect_url;
122 $photo = $item['photo'];
123 $thumb = $item['thumb'];
125 // Post was remotely authored.
127 $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']);
128 $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $thumb);
130 $profile_link = $profile_url;
132 // Can we use our special contact URL for this author?
134 if(strlen($item['remote-link'])) {
135 if($item['remote-link'] == $item['url'])
136 $profile_link = $redirect_url;
138 $profile_link = $item['remote-link'];
143 $o .= replace_macros($template,array(
144 '$id' => $item['item_id'],
145 '$profile_url' => $profile_link,
146 '$name' => $profile_name,
147 '$thumb' => $profile_avatar,
148 '$body' => bbcode($item['body']),
149 '$ago' => relative_date($item['created']),
150 '$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''),
151 '$owner_url' => $owner_url,
152 '$owner_photo' => $owner_photo,
153 '$owner_name' => $owner_name,
154 '$comment' => $comment