photos: use model delete() to delete photos
This commit is contained in:
parent
234c110d38
commit
3ca0b0bf9d
|
@ -281,19 +281,15 @@ function photos_post(App $a)
|
||||||
|
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($r)) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$res[] = "'" . DBA::escape($rr['rid']) . "'";
|
$res[] = $rr['rid'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$a->internalRedirect($_SESSION['photo_return']);
|
$a->internalRedirect($_SESSION['photo_return']);
|
||||||
return; // NOTREACHED
|
return; // NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
$str_res = implode(',', $res);
|
|
||||||
|
|
||||||
// remove the associated photos
|
// remove the associated photos
|
||||||
q("DELETE FROM `photo` WHERE `resource-id` IN ($str_res) AND `uid` = %d",
|
Photo::delete(['resource-id' => $res, 'uid' => $page_owner_uid]);
|
||||||
intval($page_owner_uid)
|
|
||||||
);
|
|
||||||
|
|
||||||
// find and delete the corresponding item with all the comments and likes/dislikes
|
// find and delete the corresponding item with all the comments and likes/dislikes
|
||||||
Item::deleteForUser(['resource-id' => $res, 'uid' => $page_owner_uid], $page_owner_uid);
|
Item::deleteForUser(['resource-id' => $res, 'uid' => $page_owner_uid], $page_owner_uid);
|
||||||
|
@ -348,10 +344,7 @@ function photos_post(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($r)) {
|
||||||
q("DELETE FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
|
Photo::delete(['resource-id' => $r[0]['resource-id'], 'uid' => $page_owner_uid]);
|
||||||
intval($page_owner_uid),
|
|
||||||
DBA::escape($r[0]['resource-id'])
|
|
||||||
);
|
|
||||||
|
|
||||||
Item::deleteForUser(['resource-id' => $r[0]['resource-id'], 'uid' => $page_owner_uid], $page_owner_uid);
|
Item::deleteForUser(['resource-id' => $r[0]['resource-id'], 'uid' => $page_owner_uid], $page_owner_uid);
|
||||||
|
|
||||||
|
@ -1678,7 +1671,6 @@ function photos_content(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
$twist = !$twist;
|
$twist = !$twist;
|
||||||
|
|
||||||
$ext = $phototypes[$rr['type']];
|
$ext = $phototypes[$rr['type']];
|
||||||
|
|
||||||
$alt_e = $rr['filename'];
|
$alt_e = $rr['filename'];
|
||||||
|
|
Loading…
Reference in a new issue