X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fthreads.php;h=bb978bc77428f05a962e9d3c355daa149043b20d;hb=2bad626be6a17423565a7aa69f001b8997da3efd;hp=b0ba54684062022b0a28c7b05e88003cc0455cfc;hpb=4a473611163a12b48d3bbad71dc54765be8789f9;p=friendica.git diff --git a/include/threads.php b/include/threads.php index b0ba546840..bb978bc774 100644 --- a/include/threads.php +++ b/include/threads.php @@ -45,12 +45,12 @@ function add_shadow_thread($itemid) { $item = $items[0]; // is it already a copy? - if (($itemid == 0) OR ($item['uid'] == 0)) { + if (($itemid == 0) || ($item['uid'] == 0)) { return; } // Is it a visible public post? - if (!$item["visible"] OR $item["deleted"] OR $item["moderated"] OR $item["private"]) { + if (!$item["visible"] || $item["deleted"] || $item["moderated"] || $item["private"]) { return; } @@ -86,8 +86,8 @@ function add_shadow_thread($itemid) { $item = q("SELECT * FROM `item` WHERE `id` = %d", intval($itemid)); - if (count($item) AND ($item[0]["allow_cid"] == '') AND ($item[0]["allow_gid"] == '') AND - ($item[0]["deny_cid"] == '') AND ($item[0]["deny_gid"] == '')) { + if (count($item) && ($item[0]["allow_cid"] == '') && ($item[0]["allow_gid"] == '') && + ($item[0]["deny_cid"] == '') && ($item[0]["deny_gid"] == '')) { $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['uri'])); @@ -177,29 +177,34 @@ function add_shadow_entry($itemid) { function update_thread_uri($itemuri, $uid) { $messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid)); - if (dbm::is_result($messages)) - foreach ($messages as $message) + if (dbm::is_result($messages)) { + foreach ($messages as $message) { update_thread($message["id"]); + } + } } function update_thread($itemid, $setmention = false) { $items = q("SELECT `uid`, `guid`, `title`, `body`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`, `deleted`, `origin`, `forum_mode`, `network`, `rendered-html`, `rendered-hash` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid)); - if (!dbm::is_result($items)) + if (!dbm::is_result($items)) { return; + } $item = $items[0]; - if ($setmention) + if ($setmention) { $item["mention"] = 1; + } $sql = ""; foreach ($item AS $field => $data) if (!in_array($field, array("guid", "title", "body", "rendered-html", "rendered-hash"))) { - if ($sql != "") + if ($sql != "") { $sql .= ", "; + } $sql .= "`".$field."` = '".dbesc($data)."'"; } @@ -211,8 +216,9 @@ function update_thread($itemid, $setmention = false) { // Updating a shadow item entry $items = q("SELECT `id` FROM `item` WHERE `guid` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item["guid"])); - if (!$items) + if (!dbm::is_result($items)) { return; + } $result = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s' WHERE `id` = %d", dbesc($item["title"]), @@ -227,9 +233,11 @@ function update_thread($itemid, $setmention = false) { function delete_thread_uri($itemuri, $uid) { $messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid)); - if(count($messages)) - foreach ($messages as $message) + if (dbm::is_result($messages)) { + foreach ($messages as $message) { delete_thread($message["id"], $itemuri); + } + } } function delete_thread($itemid, $itemuri = "") {