2 if(! function_exists('community_init')) {
3 function community_init(&$a) {
5 unset($_SESSION['theme']);
6 unset($_SESSION['mobile-theme']);
11 if(! function_exists('community_content')) {
12 function community_content(&$a, $update = 0) {
16 // Currently the community page isn't able to handle update requests
20 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
21 notice( t('Public access denied.') . EOL);
25 if(get_config('system','community_page_style') == CP_NO_COMMUNITY_PAGE) {
26 notice( t('Not available.') . EOL);
30 require_once("include/bbcode.php");
31 require_once('include/security.php');
32 require_once('include/conversation.php');
35 $o .= '<h3>' . t('Community') . '</h3>';
37 nav_set_selected('community');
40 if(x($a->data,'search'))
41 $search = notags(trim($a->data['search']));
43 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
46 // Here is the way permissions work in this module...
47 // Only public posts can be shown
48 // OR your own posts if you are a logged in member
50 if(get_config('system', 'old_pager')) {
51 $r = q("SELECT COUNT(distinct(`item`.`uri`)) AS `total`
52 FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
53 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
54 INNER JOIN `user` ON `user`.`uid` = `item`.`uid` AND `user`.`hidewall` = 0
55 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
56 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
57 AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
58 AND `item`.`private` = 0 AND `item`.`wall` = 1"
62 $a->set_pager_total($r[0]['total']);
64 if(! $r[0]['total']) {
65 info( t('No results.') . EOL);
71 $r = community_getitems($a->pager['start'], $a->pager['itemspage']);
74 info( t('No results.') . EOL);
78 $maxpostperauthor = get_config('system','max_author_posts_community_page');
80 if ($maxpostperauthor != 0) {
87 foreach ($r AS $row=>$item) {
88 if ($previousauthor == $item["author-link"])
93 $previousauthor = $item["author-link"];
95 if (($numposts < $maxpostperauthor) AND (sizeof($s) < $a->pager['itemspage']))
98 if ((sizeof($s) < $a->pager['itemspage']))
99 $r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']);
101 } while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
105 // we behave the same in message lists as the search module
107 $o .= conversation($a,$s,'community',$update);
109 if(!get_config('system', 'old_pager')) {
110 $o .= alt_pager($a,count($r));
119 if(! function_exists('community_getitems')) {
120 function community_getitems($start, $itemspage) {
121 if (get_config('system','community_page_style') == CP_GLOBAL_COMMUNITY)
122 return(community_getpublicitems($start, $itemspage));
124 $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
125 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
126 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
127 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
128 `user`.`nickname`, `user`.`hidewall`
129 FROM `thread` FORCE INDEX (`wall_private_received`)
130 INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND `user`.`hidewall` = 0
131 INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
132 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
133 AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
134 INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
135 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self`
136 WHERE `thread`.`visible` = 1 AND `thread`.`deleted` = 0 and `thread`.`moderated` = 0
137 AND `thread`.`private` = 0 AND `thread`.`wall` = 1
138 ORDER BY `thread`.`received` DESC LIMIT %d, %d ",
147 if(! function_exists('community_getpublicitems')) {
148 function community_getpublicitems($start, $itemspage) {
149 $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
150 `author-name` AS `name`, `owner-avatar` AS `photo`,
151 `owner-link` AS `url`, `owner-avatar` AS `thumb`
153 INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
154 WHERE `thread`.`uid` = 0
155 ORDER BY `thread`.`created` DESC LIMIT %d, %d",