3 use Friendica\Core\Config;
5 function community_init(App $a) {
7 unset($_SESSION['theme']);
8 unset($_SESSION['mobile-theme']);
12 function community_content(App $a, $update = 0) {
16 if ((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
17 notice( t('Public access denied.') . EOL);
21 if (Config::get('system','community_page_style') == CP_NO_COMMUNITY_PAGE) {
22 notice( t('Not available.') . EOL);
26 require_once("include/bbcode.php");
27 require_once('include/security.php');
28 require_once('include/conversation.php');
31 $o .= '<h3>' . t('Community') . '</h3>';
33 nav_set_selected('community');
36 if (x($a->data,'search')) {
37 $search = notags(trim($a->data['search']));
39 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
42 // Here is the way permissions work in this module...
43 // Only public posts can be shown
44 // OR your own posts if you are a logged in member
46 $r = community_getitems($a->pager['start'], $a->pager['itemspage']);
48 if (! dbm::is_result($r)) {
49 info( t('No results.') . EOL);
53 $maxpostperauthor = Config::get('system','max_author_posts_community_page');
55 if ($maxpostperauthor != 0) {
62 foreach ($r AS $row=>$item) {
63 if ($previousauthor == $item["author-link"]) {
68 $previousauthor = $item["author-link"];
70 if (($numposts < $maxpostperauthor) AND (sizeof($s) < $a->pager['itemspage'])) {
74 if ((sizeof($s) < $a->pager['itemspage'])) {
75 $r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']);
77 } while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
81 // we behave the same in message lists as the search module
83 $o .= conversation($a, $s, 'community', $update);
85 $o .= alt_pager($a, count($r));
90 function community_getitems($start, $itemspage) {
91 if (Config::get('system','community_page_style') == CP_GLOBAL_COMMUNITY) {
92 return(community_getpublicitems($start, $itemspage));
96 INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
97 INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
98 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
99 AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
100 %s AND `contact`.`self`
101 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
102 AND NOT `thread`.`private` AND `thread`.`wall`
103 ORDER BY `thread`.`received` DESC LIMIT %d, %d",
104 item_fieldlists(), item_joins(),
105 intval($start), intval($itemspage)
112 function community_getpublicitems($start, $itemspage) {
116 INNER JOIN `item` ON `item`.`id` = `thread`.`iid` %s
117 WHERE `thread`.`uid` = 0
118 ORDER BY `thread`.`created` DESC LIMIT %d, %d",
119 item_fieldlists(), item_joins(),
120 intval($start), intval($itemspage)