From 480091832358bf66949031e83e7e82383d8621e8 Mon Sep 17 00:00:00 2001 From: Sergio Sanchis Climent Date: Tue, 18 Oct 2016 23:17:45 +0200 Subject: [PATCH] FIX: Documents no change directory if change reference of the task. --- htdocs/projet/class/task.class.php | 26 ++++++++++++++++++++++++++ htdocs/projet/tasks/task.php | 1 + 2 files changed, 27 insertions(+) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 12799a6664f..b4c26b7d7e6 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -58,6 +58,8 @@ class Task extends CommonObject var $timespent_fk_user; var $timespent_note; + public $oldcopy; + /** * Constructor @@ -316,6 +318,30 @@ class Task extends CommonObject } } + if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) + { + // We remove directory + if ($conf->projet->dir_output) + { + $project = new Project($this->db); + $project->fetch($this->fk_project); + + $olddir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($this->oldcopy->ref); + $newdir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($this->ref); + if (file_exists($olddir)) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + $res=dol_move($olddir, $newdir); + if (! $res) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToRenameDir',$olddir,$newdir); + $error++; + } + } + } + } + // Commit or rollback if ($error) { diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 0dd08bbd342..6e0648b61e6 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -82,6 +82,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) if (! $error) { $object->fetch($id,$ref); + $object->oldcopy = clone $object; $tmparray=explode('_',$_POST['task_parent']); $task_parent=$tmparray[1];