// Is there a shadow parent?
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['parent-uri']));
- if (!count($r))
+ if (!dbm::is_result($r))
return;
// Is there already a shadow entry?
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['uri']));
- if (count($r))
+ if (dbm::is_result($r))
return;
// Preparing public shadow (removing user specific data)
function update_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) {
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 (!$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 = "") {
dbesc($itemuri),
intval($item["uid"])
);
- if (!count($r)) {
+ if (!dbm::is_result($r)) {
$r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0",
dbesc($itemuri)
);
}
function update_threads_mention() {
- $a = get_app();
-
$users = q("SELECT `uid`, `nickname` FROM `user` ORDER BY `uid`");
foreach ($users AS $user) {
- $self = normalise_link($a->get_baseurl() . '/profile/' . $user['nickname']);
+ $self = normalise_link(App::get_baseurl() . '/profile/' . $user['nickname']);
$selfhttps = str_replace("http://", "https://", $self);
$parents = q("SELECT DISTINCT(`parent`) FROM `item` WHERE `uid` = %d AND
((`owner-link` IN ('%s', '%s')) OR (`author-link` IN ('%s', '%s')))",