3 function community_init(App $a) {
5 unset($_SESSION['theme']);
6 unset($_SESSION['mobile-theme']);
13 function community_content(App $a, $update = 0) {
17 // Currently the community page isn't able to handle update requests
21 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
22 notice( t('Public access denied.') . EOL);
26 if(get_config('system','community_page_style') == CP_NO_COMMUNITY_PAGE) {
27 notice( t('Not available.') . EOL);
31 require_once("include/bbcode.php");
32 require_once('include/security.php');
33 require_once('include/conversation.php');
36 $o .= '<h3>' . t('Community') . '</h3>';
38 nav_set_selected('community');
41 if(x($a->data,'search'))
42 $search = notags(trim($a->data['search']));
44 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
47 // Here is the way permissions work in this module...
48 // Only public posts can be shown
49 // OR your own posts if you are a logged in member
51 if(get_config('system', 'old_pager')) {
52 $r = qu("SELECT COUNT(distinct(`item`.`uri`)) AS `total`
53 FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
54 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
55 INNER JOIN `user` ON `user`.`uid` = `item`.`uid` AND `user`.`hidewall` = 0
56 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
57 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
58 AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
59 AND `item`.`private` = 0 AND `item`.`wall` = 1"
62 if (dbm::is_result($r))
63 $a->set_pager_total($r[0]['total']);
65 if(! $r[0]['total']) {
66 info( t('No results.') . EOL);
72 $r = community_getitems($a->pager['start'], $a->pager['itemspage']);
74 if (! dbm::is_result($r)) {
75 info( t('No results.') . EOL);
79 $maxpostperauthor = get_config('system','max_author_posts_community_page');
81 if ($maxpostperauthor != 0) {
88 foreach ($r AS $row=>$item) {
89 if ($previousauthor == $item["author-link"])
94 $previousauthor = $item["author-link"];
96 if (($numposts < $maxpostperauthor) AND (sizeof($s) < $a->pager['itemspage']))
99 if ((sizeof($s) < $a->pager['itemspage']))
100 $r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']);
102 } while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
106 // we behave the same in message lists as the search module
108 $o .= conversation($a,$s,'community',$update);
110 if(!get_config('system', 'old_pager')) {
111 $o .= alt_pager($a,count($r));
119 function community_getitems($start, $itemspage) {
120 if (get_config('system','community_page_style') == CP_GLOBAL_COMMUNITY)
121 return(community_getpublicitems($start, $itemspage));
125 INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
126 INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
127 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
128 AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
129 %s AND `contact`.`self`
130 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
131 AND NOT `thread`.`private` AND `thread`.`wall`
132 ORDER BY `thread`.`received` DESC LIMIT %d, %d",
133 item_fieldlists(), item_joins(),
134 intval($start), intval($itemspage)
141 function community_getpublicitems($start, $itemspage) {
145 INNER JOIN `item` ON `item`.`id` = `thread`.`iid` %s
146 WHERE `thread`.`uid` = 0
147 ORDER BY `thread`.`created` DESC LIMIT %d, %d",
148 item_fieldlists(), item_joins(),
149 intval($start), intval($itemspage)