]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Post/Category.php
Merge pull request #9806 from Extarys/actionfade
[friendica.git] / src / Model / Post / Category.php
index 680e32e3ad269ac694ebf3ce1c741db491005cb5..f2c66c66297d4e247007262eb89f1b2a0d167dcb 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Model\Post;
 
 use Friendica\Database\DBA;
 use Friendica\Model\Item;
+use Friendica\Model\Post;
 use Friendica\Model\Tag;
 
 /**
@@ -49,12 +50,12 @@ class Category
        {
                $file_text = '';
 
-               $tags = DBA::selectToArray('post-category', ['type', 'name'], ['uri-id' => $uri_id, 'uid' => $uid]);
+               $tags = DBA::selectToArray('category-view', ['type', 'name'], ['uri-id' => $uri_id, 'uid' => $uid]);
                foreach ($tags as $tag) {
                        if ($tag['type'] == self::CATEGORY) {
-                               $file_text .= '<' . $tag['term'] . '>';
+                               $file_text .= '<' . $tag['name'] . '>';
                        } else {
-                               $file_text .= '[' . $tag['term'] . ']';
+                               $file_text .= '[' . $tag['name'] . ']';
                        }
                }
 
@@ -72,16 +73,14 @@ class Category
         */
        public static function storeTextByURIId(int $uri_id, int $uid, string $files)
        {
-               $message = Item::selectFirst(['deleted'], ['uri-id' => $uri_id, 'uid' => $uid]);
-               if (!DBA::isResult($message)) {
-                       return;
-               }
-
-               // Clean up all tags
-               DBA::delete('post-category', ['uri-id' => $uri_id, 'uid' => $uid]);
+               $message = Post::selectFirst(['deleted'], ['uri-id' => $uri_id, 'uid' => $uid]);
+               if (DBA::isResult($message)) {
+                       // Clean up all tags
+                       DBA::delete('post-category', ['uri-id' => $uri_id, 'uid' => $uid]);
 
-               if ($message['deleted']) {
-                       return;
+                       if ($message['deleted']) {
+                               return;
+                       }
                }
 
                if (preg_match_all("/\[(.*?)\]/ism", $files, $result)) {
@@ -91,7 +90,7 @@ class Category
                                        continue;
                                }
 
-                               DBA::insert('post-category', [
+                               DBA::replace('post-category', [
                                        'uri-id' => $uri_id,
                                        'uid' => $uid,
                                        'type' => self::FILE,
@@ -107,7 +106,7 @@ class Category
                                        continue;
                                }
 
-                               DBA::insert('post-category', [
+                               DBA::replace('post-category', [
                                        'uri-id' => $uri_id,
                                        'uid' => $uid,
                                        'type' => self::CATEGORY,