Many item calls are now isolated in a single function
This commit is contained in:
parent
c8cc7f13f1
commit
e609de2957
23 changed files with 161 additions and 387 deletions
|
@ -2218,7 +2218,7 @@ function api_statuses_destroy($type)
|
|||
|
||||
$ret = api_statuses_show($type);
|
||||
|
||||
Item::delete($id);
|
||||
Item::deleteById($id);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -2459,9 +2459,7 @@ function api_favorites_create_destroy($type)
|
|||
throw new BadRequestException("Invalid action ".$action);
|
||||
}
|
||||
|
||||
$r = q("UPDATE item SET starred=%d WHERE id=%d AND uid=%d", $item[0]['starred'], $itemid, api_user());
|
||||
|
||||
q("UPDATE thread SET starred=%d WHERE iid=%d AND uid=%d", $item[0]['starred'], $itemid, api_user());
|
||||
Item::update(['starred' => $item[0]['starred']], ['id' => $itemid]);
|
||||
|
||||
if ($r === false) {
|
||||
throw new InternalServerErrorException("DB error");
|
||||
|
@ -3991,7 +3989,7 @@ function api_fr_photoalbum_delete($type)
|
|||
if (!DBM::is_result($photo_item)) {
|
||||
throw new InternalServerErrorException("problem with deleting items occured");
|
||||
}
|
||||
Item::delete($photo_item[0]['id']);
|
||||
Item::deleteById($photo_item[0]['id']);
|
||||
}
|
||||
|
||||
// now let's delete all photos from the album
|
||||
|
@ -4294,7 +4292,7 @@ function api_fr_photo_delete($type)
|
|||
}
|
||||
// function for setting the items to "deleted = 1" which ensures that comments, likes etc. are not shown anymore
|
||||
// to the user and the contacts of the users (drop_items() do all the necessary magic to avoid orphans in database and federate deletion)
|
||||
Item::delete($photo_item[0]['id']);
|
||||
Item::deleteById($photo_item[0]['id']);
|
||||
|
||||
$answer = ['result' => 'deleted', 'message' => 'photo with id `' . $photo_id . '` has been deleted from server.'];
|
||||
return api_format_data("photo_delete", $type, ['$result' => $answer]);
|
||||
|
|
|
@ -318,13 +318,8 @@ function event_store($arr) {
|
|||
$object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>';
|
||||
$object .= '</object>' . "\n";
|
||||
|
||||
q("UPDATE `item` SET `body` = '%s', `object` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
dbesc(format_event_bbcode($arr)),
|
||||
dbesc($object),
|
||||
dbesc($arr['edited']),
|
||||
intval($r[0]['id']),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
$fields = ['body' => format_event_bbcode($arr), 'object' => $object, 'edited' => $arr['edited']];
|
||||
Item::update($fields, ['id' => $r[0]['id']]);
|
||||
|
||||
$item_id = $r[0]['id'];
|
||||
} else {
|
||||
|
@ -402,11 +397,7 @@ function event_store($arr) {
|
|||
|
||||
$item_id = Item::insert($item_arr);
|
||||
if ($item_id) {
|
||||
q("UPDATE `item` SET `event-id` = %d WHERE `uid` = %d AND `id` = %d",
|
||||
intval($event['id']),
|
||||
intval($arr['uid']),
|
||||
intval($item_id)
|
||||
);
|
||||
Item::update(['event-id' => $event['id']], ['id' => $item_id]);
|
||||
}
|
||||
|
||||
Addon::callHooks("event_created", $event['id']);
|
||||
|
|
|
@ -322,7 +322,7 @@ function drop_items($items) {
|
|||
|
||||
if (count($items)) {
|
||||
foreach ($items as $item) {
|
||||
$owner = Item::delete($item);
|
||||
$owner = Item::deleteById($item);
|
||||
if ($owner && !$uid)
|
||||
$uid = $owner;
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ function drop_item($id) {
|
|||
}
|
||||
|
||||
// delete the item
|
||||
Item::delete($item['id']);
|
||||
Item::deleteById($item['id']);
|
||||
|
||||
goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
|
||||
//NOTREACHED
|
||||
|
|
|
@ -1897,15 +1897,8 @@ function file_tag_save_file($uid, $item, $file)
|
|||
intval($uid)
|
||||
);
|
||||
if (DBM::is_result($r)) {
|
||||
if (! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']')) {
|
||||
q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
dbesc($r[0]['file'] . '[' . file_tag_encode($file) . ']'),
|
||||
intval($item),
|
||||
intval($uid)
|
||||
);
|
||||
}
|
||||
|
||||
Term::insertFromFileFieldByItemId($item);
|
||||
$fields = ['file' => $r[0]['file'] . '[' . file_tag_encode($file) . ']'];
|
||||
Item::update($fields, ['id' => $item]);
|
||||
|
||||
$saved = PConfig::get($uid, 'system', 'filetags');
|
||||
if (!strlen($saved) || !stristr($saved, '[' . file_tag_encode($file) . ']')) {
|
||||
|
@ -1938,13 +1931,8 @@ function file_tag_unsave_file($uid, $item, $file, $cat = false)
|
|||
return false;
|
||||
}
|
||||
|
||||
q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
dbesc(str_replace($pattern,'',$r[0]['file'])),
|
||||
intval($item),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
Term::insertFromFileFieldByItemId($item);
|
||||
$fields = ['file' => str_replace($pattern,'',$r[0]['file'])];
|
||||
Item::update($fields, ['id' => $item]);
|
||||
|
||||
$r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",
|
||||
dbesc($file),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue