4 use Friendica\Core\Config;
6 function community_init(App $a) {
8 unset($_SESSION['theme']);
9 unset($_SESSION['mobile-theme']);
13 function community_content(App $a, $update = 0) {
17 if ((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
18 notice( t('Public access denied.') . EOL);
22 if (Config::get('system','community_page_style') == CP_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 $r = community_getitems($a->pager['start'], $a->pager['itemspage']);
49 if (! dbm::is_result($r)) {
50 info( t('No results.') . EOL);
54 $maxpostperauthor = Config::get('system','max_author_posts_community_page');
56 if ($maxpostperauthor != 0) {
63 foreach ($r AS $row=>$item) {
64 if ($previousauthor == $item["author-link"]) {
69 $previousauthor = $item["author-link"];
71 if (($numposts < $maxpostperauthor) AND (sizeof($s) < $a->pager['itemspage'])) {
75 if ((sizeof($s) < $a->pager['itemspage'])) {
76 $r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']);
78 } while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
82 // we behave the same in message lists as the search module
84 $o .= conversation($a, $s, 'community', $update);
86 $o .= alt_pager($a, count($r));
91 function community_getitems($start, $itemspage) {
92 if (Config::get('system','community_page_style') == CP_GLOBAL_COMMUNITY) {
93 return(community_getpublicitems($start, $itemspage));
97 INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
98 INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
99 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
100 AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
101 %s AND `contact`.`self`
102 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
103 AND NOT `thread`.`private` AND `thread`.`wall`
104 ORDER BY `thread`.`received` DESC LIMIT %d, %d",
105 item_fieldlists(), item_joins(),
106 intval($start), intval($itemspage)
113 function community_getpublicitems($start, $itemspage) {
117 INNER JOIN `item` ON `item`.`id` = `thread`.`iid` %s
118 WHERE `thread`.`uid` = 0
119 ORDER BY `thread`.`created` DESC LIMIT %d, %d",
120 item_fieldlists(), item_joins(),
121 intval($start), intval($itemspage)