diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php
index 6ee36b64e9d..8d8aacf1386 100644
--- a/htdocs/ecm/docmine.php
+++ b/htdocs/ecm/docmine.php
@@ -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 = '
'.$langs->trans("ECMSectionWasRemoved", $ecmdir->label).'
';
}
-// 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=''.$ecmdir->error.'
';
+ }
}
@@ -176,7 +183,8 @@ if ($_GET["action"] == 'edit')
print '';
print '| '.$langs->trans("Ref").' | ';
$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').' '.$langs->trans("ECMRoot").' -> ';
print $s;
print ' |
';
diff --git a/htdocs/ecm/ecmdirectory.class.php b/htdocs/ecm/ecmdirectory.class.php
index 452cfc68602..544d433064f 100644
--- a/htdocs/ecm/ecmdirectory.class.php
+++ b/htdocs/ecm/ecmdirectory.class.php
@@ -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;
+ }
}