]> git.mxchange.org Git - friendica.git/commitdiff
We need "global"
authorMichael <heluecht@pirati.ca>
Sun, 3 Jun 2018 09:40:32 +0000 (09:40 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 3 Jun 2018 09:40:32 +0000 (09:40 +0000)
database.sql
include/api.php
src/Database/DBStructure.php
src/Model/Item.php

index 6f4d9ca7916c3b231916be04135c00a594483fc5..ffe02585e2be257fd6e09c6e4cb5d5c2a78c65f5 100644 (file)
@@ -514,6 +514,7 @@ CREATE TABLE IF NOT EXISTS `item` (
        `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
        `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
        `rendered-html` mediumtext COMMENT 'item.body converted to html',
+       `global` boolean NOT NULL DEFAULT '0' COMMENT '',
         PRIMARY KEY(`id`),
         INDEX `guid` (`guid`(191)),
         INDEX `uri` (`uri`(191)),
index 4dce85ed50e345bd6a0a93634205ee2700229297..94adecf0c0afe5a225daee72a8e5b5e93ccc12df 100644 (file)
@@ -1632,7 +1632,7 @@ function api_search($type)
        $r = dba::p(
                "SELECT ".item_fieldlists()."
                FROM `item` ".item_joins(api_user())."
-               WHERE ".item_condition()." AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`public`))
+               WHERE ".item_condition()." AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))
                AND `item`.`body` LIKE CONCAT('%',?,'%')
                $sql_extra
                AND `item`.`id`>?
@@ -2066,7 +2066,7 @@ function api_conversation_show($type)
                $sql_extra = ' AND `item`.`id` <= ' . intval($max_id);
        }
 
-       $r = q("SELECT `item`.`*` FROM `item`
+       $r = q("SELECT `item`.* FROM `item`
                STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                        AND (NOT `contact`.`blocked` OR `contact`.`pending`)
                WHERE `item`.`parent` = %d AND `item`.`visible`
index 03146dd5de30bc9979c993686589bc96305817f0..f5c778b21932304c26304fa5fe65804708c3dc47 100644 (file)
@@ -1195,6 +1195,7 @@ class DBStructure
                                                "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"],
                                                "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
                                                "rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"],
+                                               "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
                                                ],
                                "indexes" => [
                                                "PRIMARY" => ["id"],
index 1b64aafd0159bf48c613c71bc4395e9290a891d6..c15d10f1971a907ca3849ae785e8b8f513dcbccc 100644 (file)
@@ -724,6 +724,16 @@ class Item extends BaseObject
                        }
                }
 
+               // Is this item available in the global items (with uid=0)?
+               if ($item["uid"] == 0) {
+                       $item["global"] = true;
+
+                       // Set the global flag on all items if this was a global item entry
+                       dba::update('item', ['global' => true], ['uri' => $item["uri"]]);
+               } else {
+                       $item["global"] = dba::exists('item', ['uid' => 0, 'uri' => $item["uri"]]);
+               }
+
                // ACL settings
                if (strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) {
                        $private = 1;