diff --git a/include/conversation.php b/include/conversation.php index 684532345f..1f337859b5 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -481,7 +481,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o $body_html = Item::prepareBody($item, true, $preview); - list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); + list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, local_user()); if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) { $title = ucfirst($item['content-warning']); diff --git a/mod/display.php b/mod/display.php index 5e24bd4b43..bb69a611cb 100644 --- a/mod/display.php +++ b/mod/display.php @@ -173,7 +173,7 @@ function display_content(App $a, $update = false, $update_uid = 0) if ($update) { $uri_id = $_REQUEST['uri_id']; - $item = Post::selectFirst(['uid', 'parent-uri-id'], ['uri-id' => $uri_id, 'uid' => $update_uid]); + $item = Post::selectFirst(['uid', 'parent-uri-id'], ['uri-id' => $uri_id, 'uid' => [0, $update_uid]]); if (!empty($item)) { if ($item['uid'] != 0) { $a->setProfileOwner($item['uid']); diff --git a/src/Content/Item.php b/src/Content/Item.php index 56836903b3..daff88dcda 100644 --- a/src/Content/Item.php +++ b/src/Content/Item.php @@ -35,6 +35,7 @@ class Item * Return array with details for categories and folders for an item * * @param array $item + * @param int $uid * @return [array, array] * * [ @@ -58,13 +59,15 @@ class Item * ] * ] */ - public function determineCategoriesTerms(array $item) + public function determineCategoriesTerms(array $item, int $uid = 0) { $categories = []; $folders = []; $first = true; - foreach (Post\Category::getArrayByURIId($item['uri-id'], $item['uid'], Post\Category::CATEGORY) as $savedFolderName) { + $uid = ($item['uid'] != 0) ? $item['uid'] : $uid; + + foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::CATEGORY) as $savedFolderName) { if (!empty($item['author-link'])) { $url = $item['author-link'] . "?category=" . rawurlencode($savedFolderName); } else { @@ -73,7 +76,7 @@ class Item $categories[] = [ 'name' => $savedFolderName, 'url' => $url, - 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : ""), + 'removeurl' => ((local_user() == $uid) ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : ""), 'first' => $first, 'last' => false ]; @@ -84,12 +87,12 @@ class Item $categories[count($categories) - 1]['last'] = true; } - if (local_user() == $item['uid']) { - foreach (Post\Category::getArrayByURIId($item['uri-id'], $item['uid'], Post\Category::FILE) as $savedFolderName) { + if (local_user() == $uid) { + foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) { $folders[] = [ 'name' => $savedFolderName, 'url' => "#", - 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : ""), + 'removeurl' => ((local_user() == $uid) ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : ""), 'first' => $first, 'last' => false ]; diff --git a/src/Module/Item/Star.php b/src/Module/Item/Star.php index 47dfe18750..cb8d7f57fc 100644 --- a/src/Module/Item/Star.php +++ b/src/Module/Item/Star.php @@ -22,8 +22,10 @@ namespace Friendica\Module\Item; use Friendica\BaseModule; +use Friendica\Core\Logger; use Friendica\Core\Session; use Friendica\Core\System; +use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; use Friendica\Model\Post; @@ -48,11 +50,25 @@ class Star extends BaseModule $itemId = intval($parameters['id']); - $item = Post::selectFirstForUser(local_user(), ['starred'], ['uid' => local_user(), 'id' => $itemId]); + + $item = Post::selectFirstForUser(local_user(), ['uid', 'uri-id', 'starred'], ['uid' => [0, local_user()], 'id' => $itemId]); if (empty($item)) { throw new HTTPException\NotFoundException(); } + if ($item['uid'] == 0) { + $stored = Item::storeForUserByUriId($item['uri-id'], local_user()); + if (!empty($stored)) { + $item = Post::selectFirst(['starred'], ['id' => $stored]); + if (!DBA::isResult($item)) { + throw new HTTPException\NotFoundException(); + } + $itemId = $stored; + } else { + throw new HTTPException\NotFoundException(); + } + } + $starred = !(bool)$item['starred']; Item::update(['starred' => $starred], ['id' => $itemId]); diff --git a/src/Module/Search/Filed.php b/src/Module/Search/Filed.php index d62c3feb20..f5ec0d70f1 100644 --- a/src/Module/Search/Filed.php +++ b/src/Module/Search/Filed.php @@ -74,8 +74,8 @@ class Filed extends BaseSearch if (count($posts) == 0) { return ''; } - $item_condition = ['uid' => local_user(), 'uri-id' => $posts]; - $item_params = ['order' => ['uri-id' => true]]; + $item_condition = ['uid' => [0, local_user()], 'uri-id' => $posts]; + $item_params = ['order' => ['uri-id' => true, 'uid' => true]]; $items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params)); diff --git a/src/Object/Post.php b/src/Object/Post.php index dcb7ad208b..628cc95f7a 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -236,7 +236,7 @@ class Post ]; } - $filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? DI::l10n()->t('Save to folder') : false); + $filer = local_user() ? DI::l10n()->t('Save to folder') : false; $profile_name = $item['author-name']; if (!empty($item['author-link']) && empty($item['author-name'])) { @@ -296,7 +296,7 @@ class Post $tagger = ''; if ($this->isToplevel()) { - if(local_user()) { + if (local_user()) { $ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], local_user()); if ($item['mention'] || $ignored) { $ignore = [ @@ -309,6 +309,17 @@ class Post ]; } + $isstarred = (($item['starred']) ? "starred" : "unstarred"); + + $star = [ + 'do' => DI::l10n()->t('Add star'), + 'undo' => DI::l10n()->t('Remove star'), + 'toggle' => DI::l10n()->t('Toggle star status'), + 'classdo' => $item['starred'] ? "hidden" : "", + 'classundo' => $item['starred'] ? "" : "hidden", + 'starred' => DI::l10n()->t('Starred'), + ]; + if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) { if ($origin) { $ispinned = ($item['pinned'] ? 'pinned' : 'unpinned'); @@ -323,17 +334,6 @@ class Post ]; } - $isstarred = (($item['starred']) ? "starred" : "unstarred"); - - $star = [ - 'do' => DI::l10n()->t('Add star'), - 'undo' => DI::l10n()->t('Remove star'), - 'toggle' => DI::l10n()->t('Toggle star status'), - 'classdo' => $item['starred'] ? "hidden" : "", - 'classundo' => $item['starred'] ? "" : "hidden", - 'starred' => DI::l10n()->t('Starred'), - ]; - $tagger = [ 'add' => DI::l10n()->t('Add tag'), 'class' => "", @@ -366,7 +366,7 @@ class Post $body_html = Item::prepareBody($item, true); - list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); + list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, local_user()); if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) { $title = ucfirst($item['content-warning']); diff --git a/view/templates/jot-header.tpl b/view/templates/jot-header.tpl index ba186bc825..700d12ace1 100644 --- a/view/templates/jot-header.tpl +++ b/view/templates/jot-header.tpl @@ -210,6 +210,7 @@ function enableOnUser(){ // if(timer) clearTimeout(timer); // timer = setTimeout(NavUpdate,3000); liking = 1; + force_update = true; $.colorbox.close(); } else { $("#id_term").css("border-color","#FF0000"); diff --git a/view/theme/frio/templates/jot-header.tpl b/view/theme/frio/templates/jot-header.tpl index fdc49f54a5..8eb76ccc69 100644 --- a/view/theme/frio/templates/jot-header.tpl +++ b/view/theme/frio/templates/jot-header.tpl @@ -273,6 +273,7 @@ // if(timer) clearTimeout(timer); // timer = setTimeout(NavUpdate,3000); liking = 1; + force_update = true; $.colorbox.close(); } else { $("#id_term").css("border-color","#FF0000"); diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index 5304d3fd46..3d4a993e45 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -313,7 +313,7 @@ function frio_display_item(App $a, &$arr) $followThread = []; if ( local_user() - && local_user() == $arr['item']['uid'] + && in_array($arr['item']['uid'], [0, local_user()]) && $arr['item']['gravity'] == GRAVITY_PARENT && !$arr['item']['self'] && !$arr['item']['mention'] diff --git a/view/theme/smoothly/templates/jot-header.tpl b/view/theme/smoothly/templates/jot-header.tpl index 7acb8812e9..08028be820 100644 --- a/view/theme/smoothly/templates/jot-header.tpl +++ b/view/theme/smoothly/templates/jot-header.tpl @@ -240,6 +240,7 @@ function enableOnUser(){ // if(timer) clearTimeout(timer); // timer = setTimeout(NavUpdate,3000); liking = 1; + force_update = true; $.colorbox.close(); } else { $("#id_term").css("border-color","#FF0000");