3 function community_init(&$a) {
5 unset($_SESSION['theme']);
6 unset($_SESSION['mobile-theme']);
13 function community_content(&$a, $update = 0) {
17 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
18 notice( t('Public access denied.') . EOL);
22 if(get_config('system','no_community_page')) {
23 notice( t('Not available.') . EOL);
27 require_once("include/bbcode.php");
28 require_once('include/security.php');
29 require_once('include/conversation.php');
32 $o .= '<h3>' . t('Community') . '</h3>';
34 nav_set_selected('community');
37 if(x($a->data,'search'))
38 $search = notags(trim($a->data['search']));
40 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
43 // Here is the way permissions work in this module...
44 // Only public posts can be shown
45 // OR your own posts if you are a logged in member
47 if( (! get_config('alt_pager', 'global')) && (! get_pconfig(local_user(),'system','alt_pager')) ) {
48 $r = q("SELECT COUNT(distinct(`item`.`uri`)) 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 `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
52 AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
53 AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
54 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0"
58 $a->set_pager_total($r[0]['total']);
60 if(! $r[0]['total']) {
61 info( t('No results.') . EOL);
67 //$r = q("SELECT distinct(`item`.`uri`)
68 $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
69 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
70 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
71 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
72 `user`.`nickname`, `user`.`hidewall`
73 FROM `item` FORCE INDEX (`received`) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
74 LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
75 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
76 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
77 AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
78 AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`id` = `item`.`parent`
79 AND `user`.`hidewall` = 0
80 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self`
81 ORDER BY `received` DESC LIMIT %d, %d ",
82 intval($a->pager['start']),
83 intval($a->pager['itemspage'])
86 // group by `item`.`uri`
87 // AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`id` = `item`.`parent`
88 // AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self`
91 info( t('No results.') . EOL);
95 // we behave the same in message lists as the search module
97 $o .= conversation($a,$r,'community',$update);
99 if( get_config('alt_pager', 'global') || get_pconfig(local_user(),'system','alt_pager') ) {
100 $o .= alt_pager($a,count($r));