$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;
}
$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']));
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)."'";
}
// 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"]),
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 = "") {
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);
}
}