Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
0f8156ebcf
@ -439,21 +439,9 @@ class Project extends CommonObject
|
||||
if ($conf->projet->dir_output)
|
||||
{
|
||||
$dir = $conf->projet->dir_output . "/" . $projectref;
|
||||
$file = $conf->projet->dir_output . "/" . $projectref . "/" . $projectref . ".pdf";
|
||||
if (file_exists($file))
|
||||
{
|
||||
dol_delete_preview($this);
|
||||
|
||||
if (!dol_delete_file($file))
|
||||
{
|
||||
$this->error = 'ErrorFailToDeleteFile';
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (file_exists($dir))
|
||||
{
|
||||
$res = @dol_delete_dir($dir);
|
||||
$res = @dol_delete_dir_recursive($dir);
|
||||
if (!$res)
|
||||
{
|
||||
$this->error = 'ErrorFailToDeleteDir';
|
||||
|
||||
@ -319,6 +319,24 @@ class Task extends CommonObject
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Delete associated link file
|
||||
//retreive project ref to know project folder
|
||||
$sql = "SELECT p.ref";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid=t.fk_projet";
|
||||
$sql.= " WHERE t.rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::delete(retreive proj ref) sql=".$sql, LOG_DEBUG);
|
||||
$resql_projref=$this->db->query($sql);
|
||||
if ($resql_projref)
|
||||
{
|
||||
if ($this->db->num_rows($resql_projref))
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql_projref);
|
||||
$projectref = $obj->ref;
|
||||
}
|
||||
}
|
||||
$this->db->free($resql_projref);
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
@ -370,6 +388,27 @@ class Task extends CommonObject
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
//Delete associated link file
|
||||
if ($conf->projet->dir_output)
|
||||
{
|
||||
$dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($projectref) . '/' . dol_sanitizeFileName($this->id);
|
||||
dol_syslog(get_class($this)."::delete(retreive proj ref) dir=".$dir, LOG_DEBUG);
|
||||
if (file_exists($dir))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php");
|
||||
$res = @dol_delete_dir_recursive($dir);
|
||||
if (!$res)
|
||||
{
|
||||
$this->error = 'ErrorFailToDeleteDir';
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -395,6 +434,7 @@ class Task extends CommonObject
|
||||
{
|
||||
$obj=$this->db->fetch_object($resql);
|
||||
if ($obj) $ret=$obj->nb;
|
||||
$this->db->free($resql);
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user