Merge pull request #5893 from olsesacl/task_reference

FIX: Documents no change directory if change reference of the task.
This commit is contained in:
Laurent Destailleur 2016-10-24 01:12:26 +02:00 committed by GitHub
commit 7dd3beaa5f
2 changed files with 27 additions and 0 deletions

View File

@ -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)
{

View File

@ -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];