Fix: Blank page when renaming a product ref

This commit is contained in:
Laurent Destailleur 2012-09-19 14:11:01 +02:00
parent 9306360d3c
commit 0e76bd7ac6
3 changed files with 6 additions and 3 deletions

View File

@ -515,13 +515,13 @@ function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
/**
* Move a file into another name.
* This function differs from dol_move_uploaded_file, because it can be called in any context.
*
* @param string $srcfile Source file (can't be a directory)
* @param string $destfile Destination file (can't be a directory)
* @param string $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK)
* @param int $overwriteifexists Overwrite file if exists (1 by default)
* @return boolean True if OK, false if KO
* @see dol_move_uploaded_file
*/
function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
{

View File

@ -524,7 +524,8 @@ class Product extends CommonObject
$newdir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->ref);
if (file_exists($olddir))
{
$res=@dol_move($olddir, $newdir);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$res=dol_move($olddir, $newdir);
if (! $res)
{
$this->error='ErrorFailToMoveDir';
@ -550,11 +551,13 @@ class Product extends CommonObject
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref);
$this->db->rollback();
return -1;
}
else
{
$this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
$this->db->rollback();
return -2;
}
}

View File

@ -239,7 +239,7 @@ if (empty($reshook))
// Update a product or service
if ($action == 'update' && ($user->rights->produit->creer || $user->rights->service->creer))
{
if (GETPOST('cancel'))
if (GETPOST('cancel'))
{
$action = '';
}