Merge branch 'ticket-11211-MultiDeleteImg'
This commit is contained in:
commit
2ee444b269
@ -684,7 +684,38 @@ class AdminProducts extends AdminTab
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
|
||||
/* Product images management */
|
||||
/* @Override - Antadis, delete some images in same time */
|
||||
elseif (Tools::isSubmit('deleteImages') && Tools::getValue('ids_image'))
|
||||
{
|
||||
$ids_image = Tools::getValue('ids_image');
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
foreach ($ids_image as $key => $id_image) {
|
||||
if(Validate::isUnsignedId((int)$id_image) AND Validate::isLoadedObject($image = new Image((int)$id_image))) {
|
||||
$image->delete();
|
||||
|
||||
if (!Image::getCover($image->id_product))
|
||||
{
|
||||
$first_img = Db::getInstance()->getRow('
|
||||
SELECT `id_image` FROM `'._DB_PREFIX_.'image`
|
||||
WHERE `id_product` = '.(int)($image->id_product));
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'image`
|
||||
SET `cover` = 1
|
||||
WHERE `id_image` = '.(int)($first_img['id_image']));
|
||||
}
|
||||
@unlink(_PS_TMP_IMG_DIR_.'/product_'.$image->id_product.'.jpg');
|
||||
@unlink(_PS_TMP_IMG_DIR_.'/product_mini_'.$image->id_product.'.jpg');
|
||||
}
|
||||
}
|
||||
if(isset($image) && Validate::isLoadedObject($image)) {
|
||||
Tools::redirectAdmin($currentIndex.'&id_product='.$image->id_product.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&add'.$this->table.'&tabs=1'.'&token='.($token ? $token : $this->token));
|
||||
} else {
|
||||
$this->_errors[] = Tools::displayError('An error occured.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elseif (($id_image = (int)(Tools::getValue('id_image'))) AND Validate::isUnsignedId($id_image) AND Validate::isLoadedObject($image = new Image($id_image)))
|
||||
{
|
||||
/* PrestaShop demo mode */
|
||||
@ -3802,6 +3833,7 @@ class AdminProducts extends AdminTab
|
||||
<td colspan="2">
|
||||
<table cellspacing="0" cellpadding="0" class="table sortable" id="listItem">
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th style="width: 100px;">'.$this->l('Image').'</th>
|
||||
<th> </th>
|
||||
<th>'.$this->l('Position').'</th>
|
||||
@ -3817,6 +3849,7 @@ class AdminProducts extends AdminTab
|
||||
// echo $this->_positionJS()
|
||||
echo '
|
||||
<tr id="image_'.$image_obj->id.'">
|
||||
<td style="padding: 4px;"><input type="checkbox" name="ids_image[]" value="'.(int)($image['id_image']).'"/></td>
|
||||
<td style="padding: 4px;"><a href="'._THEME_PROD_DIR_.$img_path.'.jpg" target="_blank">
|
||||
<img src="'._THEME_PROD_DIR_.$img_path.'-small.jpg'.((int)(Tools::getValue('image_updated')) === (int)($image['id_image']) ? '?date='.time() : '').'"
|
||||
alt="'.htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8').'" title="'.htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8').'" /></a></td>
|
||||
@ -3855,6 +3888,7 @@ class AdminProducts extends AdminTab
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p><button name="deleteImages" id="deleteImages" class="button" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');">'.$this->l('Supprimer la selection').'</button></p>
|
||||
</div>';
|
||||
echo '
|
||||
<script type="text/javascript" src="../js/attributesBack.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user