Fix: on supprime l'image d'origine et la vignette
Fix: on vrifie si le chemin du fichier local est renseign
This commit is contained in:
parent
97fdd81283
commit
33827f271f
@ -2338,6 +2338,25 @@ class Product
|
||||
return $tabobj;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Efface la photo du produit et sa vignette
|
||||
* \param file Chemin de l'image
|
||||
*/
|
||||
function delete_photo($file)
|
||||
{
|
||||
// On efface l'image d'origine
|
||||
unlink($file);
|
||||
|
||||
// Si elle existe, on efface la vignette
|
||||
if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$file,$regs))
|
||||
{
|
||||
$photo_vignette=eregi_replace($regs[0],'',$file).'_small'.$regs[0];
|
||||
if (file_exists($photo_vignette))
|
||||
{
|
||||
unlink($photo_vignette);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Charge indicateurs this->nb de tableau de bord
|
||||
|
||||
@ -49,7 +49,7 @@ if (!$user->rights->produit->lire) accessforbidden();
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($_POST["sendit"] && $conf->upload != 0)
|
||||
if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && $conf->upload != 0)
|
||||
{
|
||||
if ($_GET["id"])
|
||||
{
|
||||
@ -66,7 +66,8 @@ if ($_POST["sendit"] && $conf->upload != 0)
|
||||
|
||||
if ($_GET["action"] == 'delete' && $_GET["file"])
|
||||
{
|
||||
unlink($conf->produit->dir_output."/".$_GET["file"]);
|
||||
$product = new Product($db);
|
||||
$product->delete_photo($conf->produit->dir_output."/".$_GET["file"]);
|
||||
}
|
||||
|
||||
|
||||
@ -181,19 +182,22 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
if ($obj['photo_vignette'])
|
||||
{
|
||||
$filename=$obj['photo_vignette'];
|
||||
$viewfilename=$obj['photo'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$filename=$obj['photo'];
|
||||
}
|
||||
|
||||
// Nom affiché
|
||||
$viewfilename=$obj['photo'];
|
||||
|
||||
print '<img border="0" height="120" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$filename).'">';
|
||||
|
||||
print '</a>';
|
||||
print '<br>'.$langs->trans("File").': '.dolibarr_trunc($viewfilename,16);
|
||||
if ($user->rights->produit->creer)
|
||||
{
|
||||
print '<br>'.'<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$filename).'">'.img_delete().'</a>';
|
||||
print '<br>'.'<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$viewfilename).'">'.img_delete().'</a>';
|
||||
}
|
||||
if ($nbbyrow) print '</td>';
|
||||
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user