From 03aafa8228bbdb0a294265f5865bcc0fb0f82ce1 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 Jan 2018 23:22:41 +0000 Subject: [PATCH 1/3] Public commenting is now always enabled --- include/conversation.php | 22 +++++----------------- mod/community.php | 39 +++++++++++++++++---------------------- mod/network.php | 2 +- 3 files changed, 23 insertions(+), 40 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index af4bb0559..442ce4b8b 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -578,9 +578,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { . " var profile_page = 1; "; } } elseif ($mode === 'community') { - if (!$community_readonly) { - $items = community_add_items($items); - } + $items = community_add_items($items); $profile_owner = 0; if (!$update) { $live_update_div = '
' . "\r\n" @@ -614,33 +612,23 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $page_template = get_markup_template("conversation.tpl"); if ($items && count($items)) { - $community_readonly = ($mode === 'community'); - - // Currently behind a config value. This allows the commenting and sharing of every public item. - if (Config::get('system', 'comment_public')) { - if ($mode === 'community') { - $community_readonly = false; - $writable = true; - } else { - $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]); - } + if ($mode === 'community') { + $writable = true; } else { - $writable = false; + $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]); } if (!local_user()) { $writable = false; } - if (in_array($mode, ['network-new', 'search', 'contact-posts']) || $community_readonly) { + if (in_array($mode, ['network-new', 'search', 'contact-posts'])) { /* * "New Item View" on network page or search page results * - just loop through the items and format them minimally for display */ - /// @TODO old lost code? - // $tpl = get_markup_template('search_item.tpl'); $tpl = 'search_item.tpl'; foreach ($items as $item) { diff --git a/mod/community.php b/mod/community.php index 7598f96ec..f1b747917 100644 --- a/mod/community.php +++ b/mod/community.php @@ -114,24 +114,21 @@ function community_content(App $a, $update = 0) } } - if (Config::get('system', 'comment_public')) { - // check if we serve a mobile device and get the user settings - // accordingly - if ($a->is_mobile) { - $itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_mobile_network', 20); - } else { - $itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_network', 40); - } - - // now that we have the user settings, see if the theme forces - // a maximum item number which is lower then the user choice - if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network)) { - $itemspage_network = $a->force_max_items; - } - - $a->set_pager_itemspage($itemspage_network); + // check if we serve a mobile device and get the user settings accordingly + if ($a->is_mobile) { + $itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_mobile_network', 20); + } else { + $itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_network', 40); } + // now that we have the user settings, see if the theme forces + // a maximum item number which is lower then the user choice + if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network)) { + $itemspage_network = $a->force_max_items; + } + + $a->set_pager_itemspage($itemspage_network); + $r = community_getitems($a->pager['start'], $a->pager['itemspage'], $content); if (!DBM::is_result($r)) { @@ -198,12 +195,10 @@ function community_getitems($start, $itemspage, $content) ); return dba::inArray($r); } elseif ($content == 'global') { - $r = dba::p("SELECT " . item_fieldlists() . " FROM `thread` - INNER JOIN `item` ON `item`.`id` = `thread`.`iid` " . item_joins() . - "WHERE `thread`.`uid` = 0 AND `verb` = ? - ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage), - ACTIVITY_POST - ); + $r = dba::p("SELECT `uri` FROM `thread` + INNER JOIN `item` ON `item`.`id` = `thread`.`iid` + WHERE `thread`.`uid` = 0 + ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage)); return dba::inArray($r); } diff --git a/mod/network.php b/mod/network.php index 1d64fcbde..a1100352c 100644 --- a/mod/network.php +++ b/mod/network.php @@ -783,7 +783,7 @@ function networkThreadedView(App $a, $update = 0) } // Only show it when unfiltered (no groups, no networks, ...) - if (Config::get('system', 'comment_public') && in_array($nets, ['', NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) { + if (in_array($nets, ['', NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) { if (DBM::is_result($r)) { $top_limit = current($r)['order_date']; $bottom_limit = end($r)['order_date']; From 4949be60a899105aa7f125227f2767af87afceb2 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 1 Feb 2018 00:29:47 +0000 Subject: [PATCH 2/3] Improved query speed --- boot.php | 2 +- database.sql | 4 ++-- mod/community.php | 7 ++----- src/Database/DBStructure.php | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/boot.php b/boot.php index 98db95227..732816d1b 100644 --- a/boot.php +++ b/boot.php @@ -39,7 +39,7 @@ define('FRIENDICA_PLATFORM', 'Friendica'); define('FRIENDICA_CODENAME', 'Asparagus'); define('FRIENDICA_VERSION', '3.6-dev'); define('DFRN_PROTOCOL_VERSION', '2.23'); -define('DB_UPDATE_VERSION', 1247); +define('DB_UPDATE_VERSION', 1248); define('NEW_UPDATE_ROUTINE_VERSION', 1170); /** diff --git a/database.sql b/database.sql index d6a869b56..743321310 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 3.6-dev (Asparagus) --- DB_UPDATE_VERSION 1246 +-- DB_UPDATE_VERSION 1248 -- ------------------------------------------ @@ -982,7 +982,7 @@ CREATE TABLE IF NOT EXISTS `thread` ( INDEX `uid_created` (`uid`,`created`), INDEX `uid_commented` (`uid`,`commented`), INDEX `uid_wall_created` (`uid`,`wall`,`created`), - INDEX `private_wall_commented` (`private`,`wall`,`commented`) + INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`) ) DEFAULT COLLATE utf8mb4_general_ci; -- diff --git a/mod/community.php b/mod/community.php index f1b747917..29fcd4479 100644 --- a/mod/community.php +++ b/mod/community.php @@ -183,14 +183,11 @@ function community_content(App $a, $update = 0) function community_getitems($start, $itemspage, $content) { if ($content == 'local') { - $r = dba::p("SELECT " . item_fieldlists() . " FROM `thread` + $r = dba::p("SELECT `item`.`uri`, `item`.`author-link` FROM `thread` INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall` INNER JOIN `item` ON `item`.`id` = `thread`.`iid` - AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' - AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''" . - item_joins() . " AND `contact`.`self` WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated` - AND NOT `thread`.`private` AND `thread`.`wall` + AND NOT `thread`.`private` AND `thread`.`wall` AND `thread`.`origin` ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage) ); return dba::inArray($r); diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 169d84e34..6c4ceec48 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1686,7 +1686,7 @@ class DBStructure "uid_created" => ["uid","created"], "uid_commented" => ["uid","commented"], "uid_wall_created" => ["uid","wall","created"], - "private_wall_commented" => ["private","wall","commented"], + "private_wall_origin_commented" => ["private","wall","origin","commented"], ] ]; $database["tokens"] = [ From 662d2b31a1977f2ba9c43b1a980662c383d86a11 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 1 Feb 2018 06:11:56 +0000 Subject: [PATCH 3/3] Better title for the different communities --- doc/Accesskeys.md | 5 +++++ mod/community.php | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/Accesskeys.md b/doc/Accesskeys.md index b9e5f5430..550a00e5a 100644 --- a/doc/Accesskeys.md +++ b/doc/Accesskeys.md @@ -15,6 +15,11 @@ General * f: notifications * u: user menu (in themes "vier" and "quattro") +/community +-------- +* l: Local community +* g: Global community + /profile -------- * m: Status Messages and Posts diff --git a/mod/community.php b/mod/community.php index 29fcd4479..06c15d008 100644 --- a/mod/community.php +++ b/mod/community.php @@ -72,7 +72,7 @@ function community_content(App $a, $update = 0) if ((local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) && empty(Config::get('system', 'singleuser'))) { $tabs[] = [ - 'label' => L10n::t('Community'), + 'label' => L10n::t('Local Community'), 'url' => 'community/local', 'sel' => $content == 'local' ? 'active' : '', 'title' => L10n::t('Posts from local users on this server'), @@ -83,10 +83,10 @@ function community_content(App $a, $update = 0) if (local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_GLOBAL_COMMUNITY])) { $tabs[] = [ - 'label' => L10n::t('Global Timeline'), + 'label' => L10n::t('Global Community'), 'url' => 'community/global', 'sel' => $content == 'global' ? 'active' : '', - 'title' => L10n::t('Posts from users of the federated network'), + 'title' => L10n::t('Posts from users of the whole federated network'), 'id' => 'community-global-tab', 'accesskey' => 'g' ];