From ba35b19af644d375acc4a99e535e92afd2e7ab51 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 23 Apr 2018 11:14:25 +0000 Subject: [PATCH] Public federated items now always are having an entry with "uid=0" --- boot.php | 9 +++++---- mod/admin.php | 1 + mod/community.php | 5 +++++ src/Content/Nav.php | 3 ++- src/Model/Item.php | 22 ++-------------------- 5 files changed, 15 insertions(+), 25 deletions(-) diff --git a/boot.php b/boot.php index 217a5f4e1d..1ca8b8d8d8 100644 --- a/boot.php +++ b/boot.php @@ -232,10 +232,11 @@ define('ACCOUNT_TYPE_RELAY', 4); * Type of the community page * @{ */ -define('CP_NO_COMMUNITY_PAGE', -1); -define('CP_USERS_ON_SERVER', 0); -define('CP_GLOBAL_COMMUNITY', 1); -define('CP_USERS_AND_GLOBAL', 2); +define('CP_NO_INTERNAL_COMMUNITY', -2); +define('CP_NO_COMMUNITY_PAGE', -1); +define('CP_USERS_ON_SERVER', 0); +define('CP_GLOBAL_COMMUNITY', 1); +define('CP_USERS_AND_GLOBAL', 2); /** * @} */ diff --git a/mod/admin.php b/mod/admin.php index 3debb57bed..7749cff6dc 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -1262,6 +1262,7 @@ function admin_page_site(App $a) /* Community page style */ $community_page_style_choices = [ + CP_NO_INTERNAL_COMMUNITY => L10n::t("No community page for local users"), CP_NO_COMMUNITY_PAGE => L10n::t("No community page"), CP_USERS_ON_SERVER => L10n::t("Public postings from users of this site"), CP_GLOBAL_COMMUNITY => L10n::t("Public postings from the federated network"), diff --git a/mod/community.php b/mod/community.php index 40ebdbb6e0..876339dea1 100644 --- a/mod/community.php +++ b/mod/community.php @@ -30,6 +30,11 @@ function community_content(App $a, $update = 0) $page_style = Config::get('system', 'community_page_style'); + if ($page_style == CP_NO_INTERNAL_COMMUNITY) { + notice(L10n::t('Access denied.') . EOL); + return; + } + if ($a->argc > 1) { $content = $a->argv[1]; } else { diff --git a/src/Content/Nav.php b/src/Content/Nav.php index c437c6e2a1..cd2cfb3639 100644 --- a/src/Content/Nav.php +++ b/src/Content/Nav.php @@ -161,7 +161,8 @@ class Nav } } - if (local_user() || Config::get('system', 'community_page_style') != CP_NO_COMMUNITY_PAGE) { + if ((local_user() || Config::get('system', 'community_page_style') != CP_NO_COMMUNITY_PAGE) && + !(Config::get('system', 'community_page_style') == CP_NO_INTERNAL_COMMUNITY)) { $nav['community'] = ['community', L10n::t('Community'), '', L10n::t('Conversations on this and other servers')]; } diff --git a/src/Model/Item.php b/src/Model/Item.php index 499ec25c1a..248418a7c2 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -851,7 +851,7 @@ class Item extends BaseObject public static function addShadow($itemid) { $fields = ['uid', 'wall', 'private', 'moderated', 'visible', 'contact-id', 'deleted', 'network', 'author-id', 'owner-id']; - $condition = ["`id` = ? AND (`parent` = ? OR `parent` = 0)", $itemid, $itemid]; + $condition = ['id' => $itemid, 'parent' => [0, $itemid]]; $item = dba::selectFirst('item', $fields, $condition); if (!DBM::is_result($item)) { @@ -873,27 +873,9 @@ class Item extends BaseObject return; } - // Only do these checks if the post isn't a wall post - if (!$item["wall"]) { - // Check, if hide-friends is activated - then don't do a shadow entry - if (dba::exists('profile', ['is-default' => true, 'uid' => $item['uid'], 'hide-friends' => true])) { - return; - } - - // Check if the contact is hidden or blocked - if (!dba::exists('contact', ['hidden' => false, 'blocked' => false, 'id' => $item['contact-id']])) { - return; - } - } - - // Only add a shadow, if the profile isn't hidden - if (dba::exists('user', ['uid' => $item['uid'], 'hidewall' => true])) { - return; - } - $item = dba::selectFirst('item', [], ['id' => $itemid]); - if (DBM::is_result($item) && ($item["allow_cid"] == '') && ($item["allow_gid"] == '') && + if (DBM::is_result($item) && ($item["allow_cid"] == '') && ($item["allow_gid"] == '') && ($item["deny_cid"] == '') && ($item["deny_gid"] == '')) { if (!dba::exists('item', ['uri' => $item['uri'], 'uid' => 0])) {