X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fthreads.php;h=df0f8ee1de5a24e5577be553a4871226573c312d;hb=352b168e2d2672a5e0c905c93ec771c960142b38;hp=a487d6e01f859bfb66da61b0f60bb3935314612c;hpb=3463a442badb575f024a090f371d4f75c89d9b78;p=friendica.git diff --git a/include/threads.php b/include/threads.php index a487d6e01f..df0f8ee1de 100644 --- a/include/threads.php +++ b/include/threads.php @@ -22,6 +22,15 @@ function add_thread($itemid, $onlyshadow = false) { } } +/** + * @brief Add a shadow entry for a given item id that is a thread starter + * + * We store every public item entry additionally with the user id "0". + * This is used for the community page and for the search. + * It is planned that in the future we will store public item entries only once. + * + * @param integer $itemid Item ID that should be added + */ function add_shadow_thread($itemid) { $items = q("SELECT `uid`, `wall`, `private`, `moderated`, `visible`, `contact-id`, `deleted`, `network` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid)); @@ -88,7 +97,15 @@ function add_shadow_thread($itemid) { unset($item[0]['id']); $item[0]['uid'] = 0; $item[0]['origin'] = 0; + $item[0]['wall'] = 0; $item[0]['contact-id'] = get_contact($item[0]['author-link'], 0); + + if (in_array($item[0]['type'], array("net-comment", "wall-comment"))) { + $item[0]['type'] = 'remote-comment'; + } elseif ($item[0]['type'] == 'wall') { + $item[0]['type'] = 'remote'; + } + $public_shadow = item_store($item[0], false, false, true); logger("Stored public shadow for thread ".$itemid." under id ".$public_shadow, LOGGER_DEBUG); @@ -96,7 +113,28 @@ function add_shadow_thread($itemid) { } } -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) @@ -118,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);