mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
can set position of file with dol_move (#31201)
* can set position of file with dol_move * Update api_documents.class.php * Update api_documents.class.php * fix * fix * fix * fix * fix
This commit is contained in:
parent
7eb375d398
commit
44fdcdd8ed
|
|
@ -58,7 +58,7 @@ return [
|
|||
'htdocs/adherents/stats/index.php' => ['PhanTypeInvalidDimOffset'],
|
||||
'htdocs/admin/fckeditor.php' => ['PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/api/class/api_access.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanUndeclaredProperty'],
|
||||
'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'],
|
||||
'htdocs/api/class/api_documents.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginDuplicateExpressionBinaryOp', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'],
|
||||
'htdocs/api/class/api_login.class.php' => ['PhanPluginUnknownArrayMethodReturnType'],
|
||||
'htdocs/api/class/api_setup.class.php' => ['PhanPluginUnknownArrayMethodReturnType'],
|
||||
'htdocs/api/class/api_status.class.php' => ['PhanPluginUnknownArrayMethodReturnType'],
|
||||
|
|
|
|||
|
|
@ -662,6 +662,9 @@ class Documents extends DolibarrApi
|
|||
* @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64)
|
||||
* @param int $overwriteifexists Overwrite file if exists (1 by default)
|
||||
* @param int $createdirifnotexists Create subdirectories if the doesn't exists (1 by default)
|
||||
* @param int $position Position
|
||||
* @param string $cover Cover info
|
||||
* @param array $array_options array of options
|
||||
* @return string
|
||||
*
|
||||
* @url POST /upload
|
||||
|
|
@ -669,16 +672,12 @@ class Documents extends DolibarrApi
|
|||
* @throws RestException 400 Bad Request
|
||||
* @throws RestException 403 Access denied
|
||||
* @throws RestException 404 Object not found
|
||||
* @throws RestException 500 Error on file operationw
|
||||
* @throws RestException 500 Error on file operation
|
||||
*/
|
||||
public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0, $createdirifnotexists = 1)
|
||||
public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0, $createdirifnotexists = 1, $position = 0, $cover = '', $array_options = [])
|
||||
{
|
||||
global $conf;
|
||||
|
||||
//var_dump($modulepart);
|
||||
//var_dump($filename);
|
||||
//var_dump($filecontent);exit;
|
||||
|
||||
$modulepartorig = $modulepart;
|
||||
|
||||
if (empty($modulepart)) {
|
||||
|
|
@ -939,6 +938,15 @@ class Documents extends DolibarrApi
|
|||
$moreinfo['src_object_type'] = $object->table_element;
|
||||
$moreinfo['src_object_id'] = $object->id;
|
||||
}
|
||||
if (!empty($array_options)) {
|
||||
$moreinfo = array_merge($moreinfo, ["array_options" => $array_options]);
|
||||
}
|
||||
if (!empty($position)) {
|
||||
$moreinfo = array_merge($moreinfo, ["position" => $position]);
|
||||
}
|
||||
if (!empty($cover)) {
|
||||
$moreinfo = array_merge($moreinfo, ["cover" => $cover]);
|
||||
}
|
||||
|
||||
// Move the temporary file at its final emplacement
|
||||
$result = dol_move($destfiletmp, $dest_file, '0', $overwriteifexists, 1, 1, $moreinfo);
|
||||
|
|
|
|||
|
|
@ -1137,6 +1137,12 @@ function dol_move($srcfile, $destfile, $newmask = '0', $overwriteifexists = 1, $
|
|||
if (!empty($moreinfo) && !empty($moreinfo['src_object_id'])) {
|
||||
$ecmfile->src_object_id = $moreinfo['src_object_id'];
|
||||
}
|
||||
if (!empty($moreinfo) && !empty($moreinfo['position'])) {
|
||||
$ecmfile->position = $moreinfo['position'];
|
||||
}
|
||||
if (!empty($moreinfo) && !empty($moreinfo['cover'])) {
|
||||
$ecmfile->cover = $moreinfo['cover'];
|
||||
}
|
||||
|
||||
$resultecm = $ecmfile->create($user);
|
||||
if ($resultecm < 0) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
|
||||
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -131,7 +132,8 @@ class RestAPIDocumentTest extends CommonClassTest
|
|||
'filecontent' => "content text",
|
||||
'fileencoding' => "",
|
||||
'overwriteifexists' => 0,
|
||||
'createdirifnotexists' => 0
|
||||
'createdirifnotexists' => 0,
|
||||
'position' => 0,
|
||||
);
|
||||
|
||||
$param = '';
|
||||
|
|
@ -161,7 +163,8 @@ class RestAPIDocumentTest extends CommonClassTest
|
|||
'filecontent' => "content text",
|
||||
'fileencoding' => "",
|
||||
'overwriteifexists' => 0,
|
||||
'createdirifnotexists' => 0
|
||||
'createdirifnotexists' => 0,
|
||||
'position' => 0,
|
||||
);
|
||||
|
||||
$param = '';
|
||||
|
|
@ -189,7 +192,8 @@ class RestAPIDocumentTest extends CommonClassTest
|
|||
'filecontent' => "content text",
|
||||
'fileencoding' => "",
|
||||
'overwriteifexists' => 0,
|
||||
'createdirifnotexists' => 1
|
||||
'createdirifnotexists' => 1,
|
||||
'position' => 0,
|
||||
);
|
||||
|
||||
$param = '';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user