]> git.mxchange.org Git - friendica.git/blob - mod/community.php
Merge branch 'master', remote-tracking branch 'remotes/upstream/master'
[friendica.git] / mod / community.php
1 <?php
2
3 function community_init(&$a) {
4         if(! local_user())
5                 unset($_SESSION['theme']);
6
7
8 }
9
10
11 function community_content(&$a, $update = 0) {
12
13         $o = '';
14
15         if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
16                 notice( t('Public access denied.') . EOL);
17                 return;
18         }
19
20         if(get_config('system','no_community_page')) {
21                 notice( t('Not available.') . EOL);
22                 return;
23         }
24
25         require_once("include/bbcode.php");
26         require_once('include/security.php');
27         require_once('include/conversation.php');
28
29
30         $o .= '<h3>' . t('Community') . '</h3>';
31         if(! $update) {
32                 nav_set_selected('community');
33                 $o .= '<div id="live-community"></div>' . "\r\n";
34                 $o .= "<script> var profile_uid = -1; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
35         }
36
37         if(x($a->data,'search'))
38                 $search = notags(trim($a->data['search']));
39         else
40                 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
41
42
43         // Here is the way permissions work in this module...
44         // Only public wall posts can be shown
45         // OR your own posts if you are a logged in member
46
47
48         $r = q("SELECT COUNT(*) AS `total`
49                 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
50                 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
51                 AND `wall` = 1 AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = '' 
52                 AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = '' AND `user`.`hidewall` = 0 
53                 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 "
54         );
55
56         if(count($r))
57                 $a->set_pager_total($r[0]['total']);
58
59         if(! $r[0]['total']) {
60                 info( t('No results.') . EOL);
61                 return $o;
62         }
63
64         $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
65                 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
66                 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, 
67                 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
68                 `user`.`nickname`, `user`.`hidewall`
69                 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
70                 LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
71                 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
72                 AND `wall` = 1 AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = '' 
73                 AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = '' AND `user`.`hidewall` = 0 
74                 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
75                 ORDER BY `received` DESC LIMIT %d, %d ",
76                 intval($a->pager['start']),
77                 intval($a->pager['itemspage'])
78
79         );
80
81         // we behave the same in message lists as the search module
82
83         $o .= conversation($a,$r,'community',$update);
84
85         $o .= paginate($a);
86
87         return $o;
88 }
89