51@phan-var-force FormSetup $formSetup
52@phan-var-force string $action
53@phan-var-force int $error
54@phan-var-force ?string $modulepart
55@phan-var-force ?string $websitetemplateconf
56@phan-var-force ?string $upload_dir
59if (($action ==
'update' || !empty($websitetemplateconf)) && !empty($formSetup) && is_object($formSetup) && !empty($user->admin)) {
60 $formSetup->saveConfFromPost();
64if (($action ==
'update' || !empty($websitetemplateconf)) && !empty($arrayofparameters) && is_array($arrayofparameters) && !empty($user->admin)) {
67 foreach ($arrayofparameters as $key => $val) {
69 if (GETPOSTISSET($key)) {
70 if (isset($val[
'type']) && preg_match(
'/category:/', $val[
'type'])) {
76 } elseif (isset($val[
'type']) && $val[
'type'] ==
'html') {
77 $val_const =
GETPOST($key,
'restricthtml');
79 $val_const =
GETPOST($key,
'alpha');
92 if (empty($nomessageinupdate)) {
97 if (empty($nomessageinupdate)) {
103if ($action ==
'deletefile' && $modulepart ==
'doctemplates' && !empty($user->admin)) {
104 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
105 $keyforuploaddir =
GETPOST(
'keyforuploaddir',
'aZ09');
106 $listofdir = explode(
',', preg_replace(
'/[\r\n]+/',
',', trim(
getDolGlobalString($keyforuploaddir))));
108 foreach ($listofdir as $key => $tmpdir) {
109 $tmpdir = preg_replace(
'/DOL_DATA_ROOT\/*/',
'', $tmpdir);
111 unset($listofdir[$key]);
114 $tmpdir = DOL_DATA_ROOT.
'/'.$tmpdir;
115 if (!is_dir($tmpdir)) {
116 if (empty($nomessageinsetmoduleoptions)) {
117 setEventMessages($langs->trans(
"ErrorDirNotFound", $tmpdir),
null,
'warnings');
120 $upload_dir = $tmpdir;
126 $filetodelete = $upload_dir.
'/'.
GETPOST(
'file');
135if ($action ==
'setModuleOptions' && !empty($user->admin)) {
139 if (is_array($_POST)) {
140 foreach ($_POST as $key => $val) {
142 if (preg_match(
'/^param(\d*)$/', $key, $reg)) {
143 $param =
GETPOST(
"param".$reg[1],
'aZ09');
144 $value =
GETPOST(
"value".$reg[1],
'alpha');
152 if (preg_match(
'/_ADDON_PDF_ODT_PATH$/', $param) && preg_match(
'/^DOL_DATA_ROOT/', $value)) {
153 $tmpdir = preg_replace(
'/^DOL_DATA_ROOT/', DOL_DATA_ROOT, $value);
162 if (
GETPOST(
'upload',
'alpha') &&
GETPOST(
'keyforuploaddir',
'aZ09')) {
163 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
164 $keyforuploaddir =
GETPOST(
'keyforuploaddir',
'aZ09');
165 $listofdir = explode(
',', preg_replace(
'/[\r\n]+/',
',', trim(
getDolGlobalString($keyforuploaddir))));
167 foreach ($listofdir as $key => $tmpdir) {
168 $tmpdir = trim($tmpdir);
169 $tmpdir = preg_replace(
'/DOL_DATA_ROOT\/*/',
'', $tmpdir);
171 unset($listofdir[$key]);
174 $tmpdir = DOL_DATA_ROOT.
'/'.$tmpdir;
175 if (!is_dir($tmpdir)) {
176 if (empty($nomessageinsetmoduleoptions)) {
177 setEventMessages($langs->trans(
"ErrorDirNotFound", $tmpdir),
null,
'warnings');
180 $upload_dir = $tmpdir;
186 if (preg_match(
'/_ADDON_PDF_ODT_PATH$/', $keyforuploaddir) && !empty($_FILES[
'uploadfile'])) {
187 $allowedext = array(
'odt',
'ods');
188 $allowedmimes = array(
189 'application/vnd.oasis.opendocument.text',
190 'application/vnd.oasis.opendocument.spreadsheet',
192 'application/x-zip-compressed',
193 'application/octet-stream'
195 $files = $_FILES[
'uploadfile'];
196 if (!is_array($files[
'name'])) {
197 foreach ($files as $key => &$val) {
202 foreach ($files[
'name'] as $idx => $filename) {
203 if (empty($filename)) {
207 $extension = strtolower(pathinfo((
string) $filename, PATHINFO_EXTENSION));
208 if (!in_array($extension, $allowedext,
true)) {
210 setEventMessages($langs->trans(
"ErrorFileNotUploaded").
' (Only .odt/.ods templates are allowed)',
null,
'errors');
211 dol_syslog(__FILE__.
" ODT template upload refused on extension filename=".$filename, LOG_WARNING);
216 if (!empty($files[
'tmp_name'][$idx]) && function_exists(
'finfo_open')) {
217 $finfo = finfo_open(FILEINFO_MIME_TYPE);
219 $detectedmime = (
string) finfo_file($finfo, $files[
'tmp_name'][$idx]);
223 if (!empty($detectedmime) && !in_array(strtolower($detectedmime), $allowedmimes,
true)) {
225 setEventMessages($langs->trans(
"ErrorFileNotUploaded").
' (Invalid MIME type for ODT/ODS template)',
null,
'errors');
226 dol_syslog(__FILE__.
" ODT template upload refused on mime filename=".$filename.
" mime=".$detectedmime, LOG_WARNING);
232 if ($upload_dir && !$error) {
242 if (empty($nomessageinsetmoduleoptions)) {
247 if (empty($nomessageinsetmoduleoptions)) {
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $keyforsourcefile='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null, $forceFullTextIndexation='', $mode=0)
Get and save an upload file (for example after submitting a new file in a mail form).
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string