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` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
50 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
51 INNER JOIN `user` ON `user`.`uid` = `item`.`uid` AND `user`.`hidewall` = 0
52 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
53 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
54 AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
55 AND `item`.`private` = 0 AND `item`.`wall` = 1"
59 $a->set_pager_total($r[0]['total']);
61 if(! $r[0]['total']) {
62 info( t('No results.') . EOL);
68 $r = community_getitems($a->pager['start'], $a->pager['itemspage']);
71 info( t('No results.') . EOL);
75 $maxpostperauthor = get_config('system','max_author_posts_community_page');
77 if ($maxpostperauthor != 0) {
84 foreach ($r AS $row=>$item) {
85 if ($previousauthor == $item["author-link"])
90 $previousauthor = $item["author-link"];
92 if (($numposts < $maxpostperauthor) AND (sizeof($s) < $a->pager['itemspage']))
95 if ((sizeof($s) < $a->pager['itemspage']))
96 $r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']);
98 } while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
102 // we behave the same in message lists as the search module
104 $o .= conversation($a,$s,'community',$update);
106 if(get_config('alt_pager', 'global') || get_pconfig(local_user(),'system','alt_pager') ) {
107 $o .= alt_pager($a,count($r));
116 function community_getitems($start, $itemspage) {
118 if (get_config('system', 'global_community'))
119 return(community_getpublicitems($start, $itemspage));
121 $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
122 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
123 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
124 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
125 `user`.`nickname`, `user`.`hidewall`
126 FROM `thread` FORCE INDEX (`wall_private_received`)
127 INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND `user`.`hidewall` = 0
128 INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
129 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
130 AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
131 INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
132 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self`
133 WHERE `thread`.`visible` = 1 AND `thread`.`deleted` = 0 and `thread`.`moderated` = 0
134 AND `thread`.`private` = 0 AND `thread`.`wall` = 1
135 ORDER BY `thread`.`received` DESC LIMIT %d, %d ",
144 function community_getpublicitems($start, $itemspage) {
145 $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
146 `author-name` AS `name`, `owner-avatar` AS `photo`,
147 `owner-link` AS `url`, `owner-avatar` AS `thumb`
148 FROM `item` WHERE `item`.`uid` = 0
149 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
150 AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
151 ORDER BY `item`.`received` DESC LIMIT %d, %d",