X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fthreads.php;h=df0f8ee1de5a24e5577be553a4871226573c312d;hb=d49325d177cf03b97df250ca3cb081421c541049;hp=21fdb0df34000f4e0a60c49fd8ed74f7c1637371;hpb=beb1e040696ae53b58aebdd2f639b0eb90c639fd;p=friendica.git diff --git a/include/threads.php b/include/threads.php index 21fdb0df34..df0f8ee1de 100644 --- a/include/threads.php +++ b/include/threads.php @@ -1,7 +1,9 @@ 0) - q("UPDATE `item` SET `shadow` = %d WHERE `id` = %d", intval($public_shadow), intval($itemid)); + $public_shadow = item_store($item[0], false, false, true); + logger("Stored public shadow for thread ".$itemid." under id ".$public_shadow, LOGGER_DEBUG); + } } } -function add_shadow_entry($item) { +/** + * @brief Add a shadow entry for a given item id that is a comment + * + * This function does the same like the function above - but for comments + * + * @param integer $itemid Item ID that should be added + */ +function add_shadow_entry($itemid) { + + $items = q("SELECT * FROM `item` WHERE `id` = %d", intval($itemid)); + + if (!dbm::is_result($items)) { + return; + } + + $item = $items[0]; + + // Is it a toplevel post? + if ($item['id'] == $item['parent']) { + add_shadow_thread($itemid); + return; + } // Is this a shadow entry? if ($item['uid'] == 0) @@ -103,7 +156,16 @@ function add_shadow_entry($item) { unset($item['id']); $item['uid'] = 0; + $item['origin'] = 0; + $item['wall'] = 0; $item['contact-id'] = get_contact($item['author-link'], 0); + + if (in_array($item['type'], array("net-comment", "wall-comment"))) { + $item['type'] = 'remote-comment'; + } elseif ($item['type'] == 'wall') { + $item['type'] = 'remote'; + } + $public_shadow = item_store($item, false, false, true); logger("Stored public shadow for comment ".$item['uri']." under id ".$public_shadow, LOGGER_DEBUG); @@ -180,7 +242,7 @@ function delete_thread($itemid, $itemuri = "") { intval($item["uid"]) ); if (!count($r)) { - $r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0)", + $r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0", dbesc($itemuri) ); logger("delete_thread: Deleted shadow for item ".$itemuri." - ".print_r($result, true), LOGGER_DEBUG); @@ -197,8 +259,10 @@ function update_threads() { logger("update_threads: fetched messages: ".count($messages)); - while ($message = $db->qfetch()) + while ($message = $db->qfetch()) { add_thread($message["id"]); + add_shadow_thread($message["id"]); + } $db->qclose(); } @@ -231,7 +295,7 @@ function update_shadow_copy() { logger("fetched messages: ".count($messages)); while ($message = $db->qfetch()) - add_thread($message["iid"], true); + add_shadow_thread($message["iid"]); $db->qclose(); }