1
1
Fork 0

We need "global"

This commit is contained in:
Michael 2018-06-03 09:40:32 +00:00
parent ea498ff283
commit b654af28fa
4 changed files with 14 additions and 2 deletions

View 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)),

View 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`

View 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"],

View 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;