Skip to content
Browse files

Corect bug #364

  • Loading branch information...
1 parent 282614f commit 6391684de86c732d68882e4b8e9e70db20f32eef @FHenry committed Apr 15, 2012
Showing with 42 additions and 2 deletions.
  1. +42 −2 htdocs/projet/class/task.class.php
View
44 htdocs/projet/class/task.class.php
@@ -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)
{
@@ -332,7 +369,8 @@ function delete($user, $notrigger=0)
return 0;
}
}
-
+
+
// Delete rang of line
//$this->delRangOfLine($this->id, $this->element);
@@ -368,7 +406,8 @@ function delete($user, $notrigger=0)
return -1*$error;
}
else
- {
+ {
+
$this->db->commit();
return 1;
}
@@ -395,6 +434,7 @@ function hasChildren()
{
$obj=$this->db->fetch_object($resql);
if ($obj) $ret=$obj->nb;
+ $this->db->free($resql);
}
if (! $error)

0 comments on commit 6391684

Please sign in to comment.
Something went wrong with that request. Please try again.