forked from Public/pics
Changes the ConfirmDelete page and updates database code.
The ConfirmDelete page now uses parts of the photopage. The Confirmation dialog is its own template which is based on Alert. The database now updates the album thumb to the most recent addition to the album, when the album thumb asset is being deleted. When there are no pictures left in the album 0 will be set.
This commit is contained in:
@@ -485,14 +485,6 @@ class Asset
|
||||
if (!unlink(ASSETSDIR . '/' . $this->subdir . '/' . $this->filename))
|
||||
return false;
|
||||
|
||||
$db->query('
|
||||
UPDATE tags
|
||||
SET id_asset_thumb = 0
|
||||
WHERE id_asset_thumb = {int:id_asset} AND kind = "Album"',
|
||||
[
|
||||
'id_asset' => $this->id_asset,
|
||||
]);
|
||||
|
||||
$db->query('
|
||||
DELETE FROM assets_meta
|
||||
WHERE id_asset = {int:id_asset}',
|
||||
@@ -500,12 +492,53 @@ class Asset
|
||||
'id_asset' => $this->id_asset,
|
||||
]);
|
||||
|
||||
return $db->query('
|
||||
$rows = $db->query('
|
||||
SELECT id_tag
|
||||
FROM assets_tags
|
||||
WHERE id_asset = {int:id_asset}',
|
||||
[
|
||||
'id_asset' => $this->id_asset,
|
||||
]);
|
||||
|
||||
$recount_tags = [];
|
||||
if(!empty($rows))
|
||||
foreach($rows as $row)
|
||||
$recount_tags[] = $row['id_tag'];
|
||||
|
||||
$db->query('
|
||||
DELETE FROM assets_tags
|
||||
WHERE id_asset = {int:id_asset}',
|
||||
[
|
||||
'id_asset' => $this->id_asset,
|
||||
]);
|
||||
|
||||
Tag::recount($recount_tags);
|
||||
|
||||
$return = $db->query('
|
||||
DELETE FROM assets
|
||||
WHERE id_asset = {int:id_asset}',
|
||||
[
|
||||
'id_asset' => $this->id_asset,
|
||||
]);
|
||||
|
||||
$rows = $db->query('
|
||||
SELECT id_tag
|
||||
FROM tags
|
||||
WHERE id_asset_thumb = {int:id_asset} AND kind = "Album"',
|
||||
[
|
||||
'id_asset' => $this->id_asset,
|
||||
]);
|
||||
|
||||
if (!empty($rows))
|
||||
{
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$tag = Tag::fromId($row['id_tag']);
|
||||
$tag->resetIdAsset();
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function linkTags(array $id_tags)
|
||||
|
||||
Reference in New Issue
Block a user