X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fthreads.php;h=bb978bc77428f05a962e9d3c355daa149043b20d;hb=0cd9db9cb7f4c96f597e37590a536eaae123238d;hp=66622e8746c6c40cefee9fe732d1857a22f480f2;hpb=7a9456d5ac2e73229b2237074c700731c63661a6;p=friendica.git diff --git a/include/threads.php b/include/threads.php index 66622e8746..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 = "") { @@ -245,9 +253,7 @@ function delete_thread($itemid, $itemuri = "") { intval($item["uid"]) ); if (!dbm::is_result($r)) { - $r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0", - dbesc($itemuri) - ); + dba::delete('item', array('uri' => $itemuri, 'uid' => 0)); logger("delete_thread: Deleted shadow for item ".$itemuri." - ".print_r($result, true), LOGGER_DEBUG); } }