diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index d2310e25ac0..5f0c574869d 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -510,6 +510,12 @@ function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1) return -3; } if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; + if (empty($newmask)) // This should no happen + { + dol_syslog("Warning: dol_copy called with empty value for newmask and no default value defined", LOG_WARNING); + $newmask='0664'; + } + @chmod($newpathofdestfile, octdec($newmask)); return 1; diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index d6f38b90523..8ec9d651c79 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin @@ -228,6 +228,47 @@ class modProjet extends DolibarrModules // Permissions $this->remove($options); + //ODT template for project + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/projects'; + $dest=$dirodt.'/template_project.odt'; + + if (file_exists($src) && ! file_exists($dest)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } + } + + //ODT template for tasks + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/tasks'; + $dest=$dirodt.'/template_task_summary.odt'; + + if (file_exists($src) && ! file_exists($dest)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } + } + + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','invoice',".$conf->entity.")" + ); + $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','project',".$conf->entity.")", diff --git a/htdocs/install/doctemplates/projects/template_task_summary.odt b/htdocs/install/doctemplates/projects/template_task_summary.odt deleted file mode 100755 index 84fbe00ccc9..00000000000 Binary files a/htdocs/install/doctemplates/projects/template_task_summary.odt and /dev/null differ