- $result = dbq("INSERT INTO `thread` (`"
- .implode("`, `", array_keys($item))
- ."`) VALUES ('"
- .implode("', '", array_values($item))
- ."')");
-
- logger("add_thread: Add thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
-
- // Adding a shadow item entry
- if (($itemid == 0) OR ($item['uid'] == 0))
- return;
-
- // Check, if hide-friends is activated - then don't do a shadow entry
- $r = q("SELECT `hide-friends` FROM `profile` WHERE `is-default` AND `uid` = %d AND NOT `hide-friends`",
- $item['uid']);
- if (!count($r))
- return;
-
- // Only add a shadow, if the profile isn't hidden
- $r = q("SELECT `uid` FROM `user` where `uid` = %d AND NOT `hidewall`", $item['uid']);
- if (!count($r))
- return;
-
- $item = q("SELECT * FROM `item` WHERE `id` = %d",
- intval($itemid));
-
- if (count($item) AND ($item[0]["visible"] == 1) AND ($item[0]["deleted"] == 0) AND
- (($item[0]["id"] == $item[0]["parent"]) OR ($item[0]["parent"] == 0)) AND
- ($item[0]["moderated"] == 0) AND ($item[0]["allow_cid"] == '') AND ($item[0]["allow_gid"] == '') AND
- ($item[0]["deny_cid"] == '') AND ($item[0]["deny_gid"] == '') AND ($item[0]["private"] == 0)) {
-
- $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1",
- dbesc($item['uri']));
-
- if (!$r) {
- // Preparing public shadow (removing user specific data)
- require_once("include/items.php");
- unset($item[0]['id']);
- $item[0]['uid'] = 0;
- $item[0]['contact-id'] = 0;