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