Browse Source

We need "global"

pull/5166/head
Michael 3 years ago
parent
commit
b654af28fa
4 changed files with 14 additions and 2 deletions
  1. +1
    -0
      database.sql
  2. +2
    -2
      include/api.php
  3. +1
    -0
      src/Database/DBStructure.php
  4. +10
    -0
      src/Model/Item.php

+ 1
- 0
database.sql 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)),


+ 2
- 2
include/api.php 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`


+ 1
- 0
src/Database/DBStructure.php 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"],


+ 10
- 0
src/Model/Item.php 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;


Loading…
Cancel
Save