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)
|
||||
|
||||
@@ -28,7 +28,6 @@ class Dispatcher
|
||||
'suggest' => 'ProvideAutoSuggest',
|
||||
'timeline' => 'ViewTimeline',
|
||||
'uploadmedia' => 'UploadMedia',
|
||||
'confirmdelete' => 'ConfirmDelete',
|
||||
];
|
||||
|
||||
// Work around PHP's FPM not always providing PATH_INFO.
|
||||
|
||||
@@ -289,6 +289,34 @@ class Tag
|
||||
]);
|
||||
}
|
||||
|
||||
public function resetIdAsset()
|
||||
{
|
||||
$db = Registry::get('db');
|
||||
|
||||
$row = $db->query('
|
||||
SELECT MAX(id_asset) as new_id
|
||||
FROM assets_tags
|
||||
WHERE id_tag = {int:id_tag}',
|
||||
[
|
||||
'id_tag' => $this->id_tag,
|
||||
]);
|
||||
|
||||
$new_id = 0;
|
||||
if(!empty($row))
|
||||
{
|
||||
$new_id = $row->fetch_assoc()['new_id'];
|
||||
}
|
||||
|
||||
return $db->query('
|
||||
UPDATE tags
|
||||
SET id_asset_thumb = {int:new_id}
|
||||
WHERE id_tag = {int:id_tag}',
|
||||
[
|
||||
'new_id' => $new_id,
|
||||
'id_tag' => $this->id_tag,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function match($tokens)
|
||||
{
|
||||
if (!is_array($tokens))
|
||||
|
||||
Reference in New Issue
Block a user