]> git.mxchange.org Git - friendica.git/blob - mod/network.php
added network page
[friendica.git] / mod / network.php
1 <?php
2
3
4 function network_init(&$a) {
5
6 }
7
8
9 function network_content(&$a) {
10
11         if(! local_user())
12                 return;
13
14         require_once("include/bbcode.php");
15
16
17         $contact_id = $a->cid;
18
19
20         $tpl = file_get_contents('view/jot-header.tpl');
21         
22         $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
23         require_once('view/acl_selectors.php');
24
25         $tpl = file_get_contents("view/jot.tpl");
26
27         $o .= replace_macros($tpl,array(
28                 '$baseurl' => $a->get_baseurl(),
29                 '$visitor' => 'block',
30                 '$lockstate' => 'unlock',
31                 '$acl' => populate_acl(),
32                 '$profile_uid' => $_SESSION['uid']
33         ));
34
35
36         // TODO 
37         // Alter registration and settings 
38         // and profile to update contact table when names and  photos change.  
39         // work on item_display and can_write_wall
40
41         // Add comments. 
42
43
44         $sql_extra = ''; 
45
46
47         $r = q("SELECT COUNT(*) AS `total`
48                 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
49                 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
50                 AND `contact`.`blocked` = 0 
51                 $sql_extra ",
52                 intval($_SESSION['uid'])
53
54         );
55
56         if(count($r))
57                 $a->set_pager_total($r[0]['total']);
58 dbg(2);
59
60         $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
61                 `contact`.`name`, `contact`.`photo`, `contact`.`url`, 
62                 `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, 
63                 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
64                 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
65                 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
66                 AND `contact`.`blocked` = 0 
67                 $sql_extra
68                 ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
69                 intval($_SESSION['uid']),
70                 intval($a->pager['start']),
71                 intval($a->pager['itemspage'])
72
73         );
74
75
76         $cmnt_tpl = file_get_contents('view/comment_item.tpl');
77
78
79         $tpl = file_get_contents('view/wall_item.tpl');
80         $wallwall = file_get_contents('view/wallwall_item.tpl');
81
82         if(count($r)) {
83                 foreach($r as $rr) {
84                         $comment = '';
85
86                         if($rr['last-child']) {
87                                 $comment = replace_macros($cmnt_tpl,array(
88                                         '$id' => $rr['item_id'],
89                                         '$parent' => $rr['parent'],
90                                         '$profile_uid' =>  $_SESSION['uid']
91                                 ));
92                         }
93
94                         $item = $rr;
95                         $template = $tpl;
96         
97                         $profile_url = $item['url'];
98
99                         if(($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] ))
100                                 $profile_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
101
102                         $photo = $item['photo'];
103                         $thumb = $item['thumb'];
104         
105                         $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']);
106                         $profile_link = ((strlen($item['remote-link'])) ? $item['remote-link'] : $profile_url);
107                         $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $thumb);
108
109                         if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
110                                 $template = $wallwall;                  // FIXME also if remote owner
111                                 $owner_url = $a->contact['url'];
112                                 $owner_photo = $a->contact['thumb'];
113                                 $owner_name = $a->contact['name'];
114                         }
115
116                         $o .= replace_macros($template,array(
117                                 '$id' => $item['item_id'],
118                                 '$profile_url' => $profile_link,
119                                 '$name' => $profile_name,
120                                 '$thumb' => $profile_avatar,
121                                 '$body' => bbcode($item['body']),
122                                 '$ago' => relative_date($item['created']),
123                                 '$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''),
124                                 '$owner_url' => $owner_url,
125                                 '$owner_photo' => $owner_photo,
126                                 '$owner_name' => $owner_name,
127                                 '$comment' => $comment
128                         ));
129
130                 }
131         }
132
133         $o .= paginate($a);
134
135         return $o;
136
137
138 }