mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 19:29:58 +03:00
Fixes #863 Allow delete representative for empty albums
This commit is contained in:
parent
64819ae2a0
commit
743d31c9e0
3 changed files with 20 additions and 6 deletions
|
@ -411,7 +411,7 @@ if ($category['has_images'] or !empty($category['representative_picture_id']))
|
||||||
}
|
}
|
||||||
|
|
||||||
// can the admin choose to set a new random representant ?
|
// can the admin choose to set a new random representant ?
|
||||||
$tpl_representant['ALLOW_SET_RANDOM'] = ($category['has_images']) ? true : false;
|
$tpl_representant['ALLOW_SET_RANDOM'] = ($category['has_images'] ? true : false);
|
||||||
|
|
||||||
// can the admin delete the current representant ?
|
// can the admin delete the current representant ?
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -78,7 +78,11 @@ jQuery(document).ready(function() {
|
||||||
var data = jQuery.parseJSON(data);
|
var data = jQuery.parseJSON(data);
|
||||||
if (data.stat == 'ok') {
|
if (data.stat == 'ok') {
|
||||||
jQuery(".albumThumbnailImage").hide();
|
jQuery(".albumThumbnailImage").hide();
|
||||||
jQuery(".albumThumbnailRandom").show();
|
if (jQuery(".albumThumbnailActions").data('random_allowed') == '') {
|
||||||
|
jQuery(".deleteRepresentative").hide();
|
||||||
|
} else {
|
||||||
|
jQuery(".albumThumbnailRandom").show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alert("error on "+method);
|
alert("error on "+method);
|
||||||
|
@ -176,13 +180,16 @@ jQuery(document).ready(function() {
|
||||||
<a class="albumThumbnailImage" style="{if !isset($representant.picture)}display:none{/if}" href="{$representant.picture.url}"><img src="{$representant.picture.src}"></a>
|
<a class="albumThumbnailImage" style="{if !isset($representant.picture)}display:none{/if}" href="{$representant.picture.url}"><img src="{$representant.picture.src}"></a>
|
||||||
<img class="albumThumbnailRandom" style="{if isset($representant.picture)}display:none{/if}" src="{$ROOT_URL}{$themeconf.admin_icon_dir}/category_representant_random.png" alt="{'Random photo'|@translate}">
|
<img class="albumThumbnailRandom" style="{if isset($representant.picture)}display:none{/if}" src="{$ROOT_URL}{$themeconf.admin_icon_dir}/category_representant_random.png" alt="{'Random photo'|@translate}">
|
||||||
|
|
||||||
<p class="albumThumbnailActions">
|
<p class="albumThumbnailActions" data-random_allowed="{$representant.ALLOW_SET_RANDOM}">
|
||||||
|
{assign var="action_separator" value=""}
|
||||||
{if $representant.ALLOW_SET_RANDOM }
|
{if $representant.ALLOW_SET_RANDOM }
|
||||||
<a href="#refresh" data-category_id="{$CAT_ID}" class="refreshRepresentative" title="{'Find a new representant by random'|@translate}">{'Refresh'|@translate}</a>
|
<a href="#refresh" data-category_id="{$CAT_ID}" class="refreshRepresentative" title="{'Find a new representant by random'|@translate}">{'Refresh'|@translate}</a>
|
||||||
|
{assign var="action_separator" value="|"}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{if isset($representant.ALLOW_DELETE) }
|
{if isset($representant.ALLOW_DELETE) }
|
||||||
| <a href="#delete" data-category_id="{$CAT_ID}" class="deleteRepresentative" title="{'Delete Representant'|@translate}">{'Delete'|translate}</a>
|
{$action_separator}
|
||||||
|
<a href="#delete" data-category_id="{$CAT_ID}" class="deleteRepresentative" title="{'Delete Representant'|@translate}">{'Delete'|translate}</a>
|
||||||
{/if}
|
{/if}
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -703,7 +703,7 @@ UPDATE '. USER_CACHE_CATEGORIES_TABLE .'
|
||||||
* API method
|
* API method
|
||||||
*
|
*
|
||||||
* Deletes the album thumbnail. Only possible if
|
* Deletes the album thumbnail. Only possible if
|
||||||
* $conf['allow_random_representative']
|
* $conf['allow_random_representative'] or if the album has no direct photos.
|
||||||
*
|
*
|
||||||
* @param mixed[] $params
|
* @param mixed[] $params
|
||||||
* @option int category_id
|
* @option int category_id
|
||||||
|
@ -724,7 +724,14 @@ SELECT id
|
||||||
return new PwgError(404, 'category_id not found');
|
return new PwgError(404, 'category_id not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$conf['allow_random_representative'])
|
$query = '
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||||
|
WHERE category_id = '.$params['category_id'].'
|
||||||
|
;';
|
||||||
|
list($nb_images) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
|
||||||
|
if (!$conf['allow_random_representative'] and $nb_images != 0)
|
||||||
{
|
{
|
||||||
return new PwgError(401, 'not permitted');
|
return new PwgError(401, 'not permitted');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue