Fix default value of dol_move
This commit is contained in:
parent
d62ecff59b
commit
0f4bf91fcd
5 changed files with 18 additions and 10 deletions
|
|
@ -962,6 +962,7 @@ class Documents extends DolibarrApi
|
|||
if (!empty($cover)) {
|
||||
$moreinfo = array_merge($moreinfo, ["cover" => $cover]);
|
||||
}
|
||||
$moreinfo['gen_or_uploaded'] = 'api';
|
||||
|
||||
// Move the temporary file at its final emplacement
|
||||
$result = dol_move($destfiletmp, $dest_file, '0', $overwriteifexists, 1, 1, $moreinfo);
|
||||
|
|
|
|||
|
|
@ -3487,6 +3487,7 @@ class Facture extends CommonInvoice
|
|||
/**
|
||||
* Tag invoice as validated + call trigger BILL_VALIDATE
|
||||
* Object must have lines loaded with fetch_lines
|
||||
* This may rename files on disk because ref is modified but it does not generate any document.
|
||||
*
|
||||
* @param User $user Object user that validate
|
||||
* @param string $force_number Reference to force on invoice
|
||||
|
|
@ -3861,7 +3862,7 @@ class Facture extends CommonInvoice
|
|||
}
|
||||
|
||||
if (!$error) {
|
||||
// Rename directory if dir was a temporary ref
|
||||
// Rename directory in index entry if dir was a temporary ref
|
||||
if (preg_match('/^[\(]?PROV/i', $this->ref)) {
|
||||
// Now we rename also files into index
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'facture/".$this->db->escape($this->newref)."'";
|
||||
|
|
@ -3923,7 +3924,8 @@ class Facture extends CommonInvoice
|
|||
}
|
||||
}
|
||||
|
||||
// Rename directory if dir was a temporary ref
|
||||
// All database actions are now complete
|
||||
// We rename the directory and files on disk if old dir was a temporary ref.
|
||||
if (!$error && preg_match('/^[\(]?PROV/i', $this->oldref)) {
|
||||
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
|
||||
$oldref = dol_sanitizeFileName($this->oldref);
|
||||
|
|
@ -3935,7 +3937,7 @@ class Facture extends CommonInvoice
|
|||
|
||||
if (@rename($dirsource, $dirdest)) {
|
||||
dol_syslog("Rename ok");
|
||||
// Rename docs starting with $oldref with $newref
|
||||
// Rename also docs starting with $oldref with $newref
|
||||
$listoffiles = dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
|
||||
foreach ($listoffiles as $fileentry) {
|
||||
$dirsource = $fileentry['name'];
|
||||
|
|
@ -5729,8 +5731,6 @@ class Facture extends CommonInvoice
|
|||
*/
|
||||
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$outputlangs->loadLangs(array("bills", "products"));
|
||||
|
||||
if (!dol_strlen($modele)) {
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes' && !empty($permissionto
|
|||
$langs->load("errors"); // lang must be loaded because we can't rely on loading during output, we need var substitution to be done now.
|
||||
setEventMessages($langs->trans("ErrorFilenameCantStartWithDot", $filenameto), null, 'errors');
|
||||
} elseif (!file_exists($destpath)) {
|
||||
$result = dol_move($srcpath, $destpath);
|
||||
$result = dol_move($srcpath, $destpath, '0', 1, 0, 1);
|
||||
if ($result) {
|
||||
// Define if we have to generate thumbs or not
|
||||
$generatethumbs = 1;
|
||||
|
|
|
|||
|
|
@ -765,7 +765,8 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask
|
|||
dolChmod($newpathoftmpdestfile, $newmask);
|
||||
|
||||
// Rename
|
||||
$result = dol_move($newpathoftmpdestfile, $newpathofdestfile, $newmask, (($destfile == $srcfile) ? 1 : 0), 0, $indexdatabase);
|
||||
$moreinfo = array('gen_or_uploaded' => 'dolReplaceInFile');
|
||||
$result = dol_move($newpathoftmpdestfile, $newpathofdestfile, $newmask, (($destfile == $srcfile) ? 1 : 0), 0, $indexdatabase, $moreinfo);
|
||||
if (!$result) {
|
||||
dol_syslog("files.lib.php::dolReplaceInFile failed to move tmp file to final dest", LOG_WARNING);
|
||||
return -3;
|
||||
|
|
@ -1145,7 +1146,7 @@ function dol_move($srcfile, $destfile, $newmask = '0', $overwriteifexists = 1, $
|
|||
if (!empty($moreinfo) && !empty($moreinfo['gen_or_uploaded'])) {
|
||||
$ecmfile->gen_or_uploaded = $moreinfo['gen_or_uploaded'];
|
||||
} else {
|
||||
$ecmfile->gen_or_uploaded = 'uploaded';
|
||||
$ecmfile->gen_or_uploaded = 'undefined'; // or 'generated', 'uploaded'
|
||||
}
|
||||
if (!empty($moreinfo) && !empty($moreinfo['description'])) {
|
||||
$ecmfile->description = $moreinfo['description']; // indexed content
|
||||
|
|
@ -1272,7 +1273,8 @@ function dol_move_dir($srcdir, $destdir, $overwriteifexists = 1, $indexdatabase
|
|||
if ($file["type"] == "dir") {
|
||||
$res = dol_move_dir($filepath.'/'.$oldname, $filepath.'/'.$newname, $overwriteifexists, $indexdatabase, $renamedircontent);
|
||||
} else {
|
||||
$res = dol_move($filepath.'/'.$oldname, $filepath.'/'.$newname, '0', $overwriteifexists, 0, $indexdatabase);
|
||||
$moreinfo = array('gen_or_uploaded' => 'dol_move_dir');
|
||||
$res = dol_move($filepath.'/'.$oldname, $filepath.'/'.$newname, '0', $overwriteifexists, 0, $indexdatabase, $moreinfo);
|
||||
}
|
||||
if (!$res) {
|
||||
return $result;
|
||||
|
|
|
|||
|
|
@ -2576,7 +2576,12 @@ class Ticket extends CommonObject
|
|||
$destfile = $destdir.'/'.$pathinfo['filename'].' - '.dol_print_date($now, 'dayhourlog').'.'.$pathinfo['extension'];
|
||||
}
|
||||
|
||||
$moreinfo = array('description' => 'File saved by copyFilesForTicket', 'src_object_type' => $this->element, 'src_object_id' => $this->id);
|
||||
$moreinfo = array(
|
||||
'description' => 'File saved by copyFilesForTicket',
|
||||
'src_object_type' => $this->element,
|
||||
'src_object_id' => $this->id,
|
||||
'gen_or_uploaded' => 'uploaded'
|
||||
);
|
||||
|
||||
$res = dol_move($filepath[$i], $destfile, '0', 1, 0, 1, $moreinfo);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue