]> git.mxchange.org Git - friendica.git/commitdiff
Mark, file and starring does now work for all items
authorMichael <heluecht@pirati.ca>
Thu, 12 Aug 2021 05:28:47 +0000 (05:28 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 12 Aug 2021 05:28:47 +0000 (05:28 +0000)
include/conversation.php
mod/display.php
src/Content/Item.php
src/Module/Item/Star.php
src/Module/Search/Filed.php
src/Object/Post.php
view/templates/jot-header.tpl
view/theme/frio/templates/jot-header.tpl
view/theme/frio/theme.php
view/theme/smoothly/templates/jot-header.tpl

index 684532345f5f0d082768dd9d1b2df6b8c717ad11..1f337859b50c0bad9543a00280694bba4465d753 100644 (file)
@@ -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']);
index 5e24bd4b43d26981d4c32dd04ebd59416058760b..bb69a611cb1029e672f7e8e399a50f15214a49c0 100644 (file)
@@ -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']);
index 56836903b3c6ff91694cf3e2df1b4ef8db4bfdda..daff88dcda32a3e3a8b9311b091fb9621b6d74a6 100644 (file)
@@ -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
                                ];
index 47dfe1875036b0a9f361f2278f7299c02b8f1510..cb8d7f57fc4ffe448a98d599f227400aafb90848 100644 (file)
 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]);
index d62c3feb209ff9969465dd02f5c96392992ded0e..f5ec0d70f16be647f14d0eaaebb446462fb61344 100644 (file)
@@ -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));
 
index dcb7ad208b2dede4e3ff95e3ceffe2ccb15eadc2..628cc95f7a6b856089d8afccd3670f17b785c415 100644 (file)
@@ -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']);
index ba186bc8257a39475f13738b39808418760e39f7..700d12ace10f3a20cfd02d894e69f83fe3cfb7c8 100644 (file)
@@ -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");
index fdc49f54a54cfd4703a2cb7cf3591c4cd81eb016..8eb76ccc6941aa08811b268ce0a8096fb4b396e8 100644 (file)
 //                                     if(timer) clearTimeout(timer);
 //                                     timer = setTimeout(NavUpdate,3000);
                                        liking = 1;
+                                       force_update = true;
                                        $.colorbox.close();
                                } else {
                                        $("#id_term").css("border-color","#FF0000");
index 5304d3fd463d4d13874bd12151bdd5b2528b907c..3d4a993e45bc45111dd600e3692fb94126f9be44 100644 (file)
@@ -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']
index 7acb8812e97176cb83cf5a6e67ed3e6098fdb531..08028be8204fbf9f3124fe783a841bc9b59e9382 100644 (file)
@@ -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");