Fix: Can not delete directory in ecm module
This commit is contained in:
parent
d26083e8fe
commit
db9e81f571
@ -143,9 +143,15 @@ if ($_POST['action'] == 'confirm_deletedir' && $_POST['confirm'] == 'yes')
|
|||||||
{
|
{
|
||||||
// Fetch was already done
|
// Fetch was already done
|
||||||
$result=$ecmdir->delete($user);
|
$result=$ecmdir->delete($user);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
header("Location: ".DOL_URL_ROOT."/ecm/index.php");
|
header("Location: ".DOL_URL_ROOT."/ecm/index.php");
|
||||||
exit;
|
exit;
|
||||||
// $mesg = '<div class="ok">'.$langs->trans("ECMSectionWasRemoved", $ecmdir->label).'</div>';
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg = '<div class="error">'.$langs->trans($ecmdir->error).'</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update description
|
// Update description
|
||||||
|
|||||||
@ -24,13 +24,13 @@
|
|||||||
\version $Id$
|
\version $Id$
|
||||||
\author Laurent Destailleur
|
\author Laurent Destailleur
|
||||||
\remarks Initialy built by build_class_from_table on 2008-02-24 19:24
|
\remarks Initialy built by build_class_from_table on 2008-02-24 19:24
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class EcmDirectory
|
\class EcmDirectory
|
||||||
\brief Class to manage ECM directories
|
\brief Class to manage ECM directories
|
||||||
\remarks Initialy built by build_class_from_table on 2008-02-24 19:24
|
\remarks Initialy built by build_class_from_table on 2008-02-24 19:24
|
||||||
*/
|
*/
|
||||||
class EcmDirectory // extends CommonObject
|
class EcmDirectory // extends CommonObject
|
||||||
{
|
{
|
||||||
var $db; //!< To store db handler
|
var $db; //!< To store db handler
|
||||||
@ -149,7 +149,7 @@ class EcmDirectory // extends CommonObject
|
|||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
|
$result=$interface->run_triggers('MYECMDIR_CREATE',$this,$user,$langs,$conf);
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ class EcmDirectory // extends CommonObject
|
|||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
|
$result=$interface->run_triggers('MYECMDIR_MODIFY',$this,$user,$langs,$conf);
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ class EcmDirectory // extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Delete object in database
|
* \brief Delete object on database and on disk
|
||||||
* \param user User that delete
|
* \param user User that delete
|
||||||
* \return int <0 if KO, >0 if OK
|
* \return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
@ -324,6 +324,12 @@ class EcmDirectory // extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
|
$relativepath=$this->getRelativePath(1); // Ex: dir1/dir2/dir3
|
||||||
|
|
||||||
|
dol_syslog("EcmDirectories::delete remove directory ".$relativepath);
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
|
||||||
$sql.= " WHERE rowid=".$this->id;
|
$sql.= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
@ -331,22 +337,39 @@ class EcmDirectory // extends CommonObject
|
|||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql)
|
if (! $resql)
|
||||||
{
|
{
|
||||||
|
$this->db->rollback();
|
||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error="Error ".$this->db->lasterror();
|
||||||
dol_syslog("EcmDirectories::delete ".$this->error, LOG_ERR);
|
dol_syslog("EcmDirectories::delete ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $conf->ecm->dir_output . "/" . $this->label;
|
$file = $conf->ecm->dir_output . "/" . $relativepath;
|
||||||
$result=@dol_delete_dir($file);
|
$result=@dol_delete_dir($file);
|
||||||
|
|
||||||
|
if ($result || ! @is_dir(dol_osencode($file)))
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error='ErrorFailedToDeleteDir';
|
||||||
|
dol_syslog("EcmDirectories::delete ".$this->error, LOG_ERR);
|
||||||
|
$this->db->rollback();
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
|
$result=$interface->run_triggers('MYECMDIR_DELETE',$this,$user,$langs,$conf);
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
if (! $error) return 1;
|
||||||
|
else return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user