Fix: Description was lost

This commit is contained in:
Laurent Destailleur 2008-05-04 14:39:14 +00:00
parent e2475e9530
commit 37bae6699e
2 changed files with 29 additions and 7 deletions

View File

@ -80,6 +80,7 @@ $relativepath=$ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
/*******************************************************************
* ACTIONS
*
@ -128,17 +129,23 @@ if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
// Remove dir
if ($_POST['action'] == 'confirm_deletedir' && $_POST['confirm'] == 'yes')
{
// Fetch was already done
$result=$ecmdir->delete($user);
header("Location: ".DOL_URL_ROOT."/ecm/index.php");
exit;
// $mesg = '<div class="ok">'.$langs->trans("ECMSectionWasRemoved", $ecmdir->label).'</div>';
}
// Remove dir
// Update description
if ($_POST['action'] == 'update' && ! $_POST['cancel'])
{
// Fetch was already done
$ecmdir->description = $_POST["description"];
$result=$ecmdir->update($user);
if ($result <= 0)
{
$mesg='<div class="error">'.$ecmdir->error.'</div>';
}
}
@ -176,7 +183,8 @@ if ($_GET["action"] == 'edit')
print '<table class="border" width="100%">';
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
$s='';
$tmpecmdir=$ecmdir;
$tmpecmdir=new ECMDirectory($db); // Need to create a new one
$tmpecmdir->fetch($ecmdir->id);
$result = 1;
while ($tmpecmdir && $result > 0)
{
@ -192,6 +200,7 @@ while ($tmpecmdir && $result > 0)
$tmpecmdir=0;
}
}
print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> ';
print $s;
print '</td></tr>';

View File

@ -75,7 +75,7 @@ class EcmDirectory // extends CommonObject
$now=time();
// Clean parameters
$this->label=sanitize_string($this->label);
$this->label=sanitize_string($this->label);
$this->fk_parent=trim($this->fk_parent);
$this->description=trim($this->description);
if (! $this->cachenbofdoc) $this->cachenbofdoc=0;
@ -139,6 +139,8 @@ class EcmDirectory // extends CommonObject
{
global $conf, $langs;
$error=0;
// Clean parameters
$this->label=trim($this->label);
$this->fk_parent=trim($this->fk_parent);
@ -147,6 +149,8 @@ class EcmDirectory // extends CommonObject
// Check parameters
// Put here code to add control on parameters values
$this->db->begin();
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
@ -159,12 +163,12 @@ class EcmDirectory // extends CommonObject
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
$error++;
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("EcmDirectories::update ".$this->error, LOG_ERR);
return -1;
}
if (! $notrigger)
if (! $error && ! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
@ -174,7 +178,16 @@ class EcmDirectory // extends CommonObject
// Fin appel triggers
}
return 1;
if (! $error)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -1;
}
}