Navigation Menu

Skip to content

Commit

Permalink
Corect bug Dolibarr#364
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry committed Apr 15, 2012
1 parent 282614f commit 6391684
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions htdocs/projet/class/task.class.php
Expand Up @@ -319,6 +319,43 @@ function delete($user, $notrigger=0)
$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 ($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;
}
}
}


if (! $error)
{
Expand All @@ -332,7 +369,8 @@ function delete($user, $notrigger=0)
return 0;
}
}



// Delete rang of line
//$this->delRangOfLine($this->id, $this->element);

Expand Down Expand Up @@ -368,7 +406,8 @@ function delete($user, $notrigger=0)
return -1*$error;
}
else
{
{

$this->db->commit();
return 1;
}
Expand All @@ -395,6 +434,7 @@ function hasChildren()
{
$obj=$this->db->fetch_object($resql);
if ($obj) $ret=$obj->nb;
$this->db->free($resql);
}

if (! $error)
Expand Down

0 comments on commit 6391684

Please sign in to comment.