50@phan-var-force FormSetup $formSetup
53if (($action ==
'update' || !empty($websitetemplateconf)) && !empty($formSetup) && is_object($formSetup) && !empty($user->admin)) {
54 $formSetup->saveConfFromPost();
60if (($action ==
'update' || !empty($websitetemplateconf)) && !empty($arrayofparameters) && is_array($arrayofparameters) && !empty($user->admin)) {
63 foreach ($arrayofparameters as $key => $val) {
65 if (GETPOSTISSET($key)) {
66 if (isset($val[
'type']) && preg_match(
'/category:/', $val[
'type'])) {
72 } elseif (isset($val[
'type']) && $val[
'type'] ==
'html') {
73 $val_const =
GETPOST($key,
'restricthtml');
75 $val_const =
GETPOST($key,
'alpha');
88 if (empty($nomessageinupdate)) {
93 if (empty($nomessageinupdate)) {
99if ($action ==
'deletefile' && $modulepart ==
'doctemplates' && !empty($user->admin)) {
100 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
101 $keyforuploaddir =
GETPOST(
'keyforuploaddir',
'aZ09');
102 $listofdir = explode(
',', preg_replace(
'/[\r\n]+/',
',', trim(
getDolGlobalString($keyforuploaddir))));
104 foreach ($listofdir as $key => $tmpdir) {
105 $tmpdir = preg_replace(
'/DOL_DATA_ROOT\/*/',
'', $tmpdir);
107 unset($listofdir[$key]);
110 $tmpdir = DOL_DATA_ROOT.
'/'.$tmpdir;
111 if (!is_dir($tmpdir)) {
112 if (empty($nomessageinsetmoduleoptions)) {
113 setEventMessages($langs->trans(
"ErrorDirNotFound", $tmpdir),
null,
'warnings');
116 $upload_dir = $tmpdir;
121 $filetodelete = $tmpdir.
'/'.
GETPOST(
'file');
129if ($action ==
'setModuleOptions' && !empty($user->admin)) {
133 if (is_array($_POST)) {
134 foreach ($_POST as $key => $val) {
136 if (preg_match(
'/^param(\d*)$/', $key, $reg)) {
137 $param =
GETPOST(
"param".$reg[1],
'aZ09');
138 $value =
GETPOST(
"value".$reg[1],
'alpha');
146 if (preg_match(
'/_ADDON_PDF_ODT_PATH$/', $param) && preg_match(
'/^DOL_DATA_ROOT/', $value)) {
147 $tmpdir = preg_replace(
'/^DOL_DATA_ROOT/', DOL_DATA_ROOT, $value);
156 if (
GETPOST(
'upload',
'alpha') &&
GETPOST(
'keyforuploaddir',
'aZ09')) {
157 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
158 $keyforuploaddir =
GETPOST(
'keyforuploaddir',
'aZ09');
159 $listofdir = explode(
',', preg_replace(
'/[\r\n]+/',
',', trim(
getDolGlobalString($keyforuploaddir))));
161 foreach ($listofdir as $key => $tmpdir) {
162 $tmpdir = trim($tmpdir);
163 $tmpdir = preg_replace(
'/DOL_DATA_ROOT\/*/',
'', $tmpdir);
165 unset($listofdir[$key]);
168 $tmpdir = DOL_DATA_ROOT.
'/'.$tmpdir;
169 if (!is_dir($tmpdir)) {
170 if (empty($nomessageinsetmoduleoptions)) {
171 setEventMessages($langs->trans(
"ErrorDirNotFound", $tmpdir),
null,
'warnings');
174 $upload_dir = $tmpdir;
180 if (preg_match(
'/_ADDON_PDF_ODT_PATH$/', $keyforuploaddir) && !empty($_FILES[
'uploadfile'])) {
181 $allowedext = array(
'odt',
'ods');
182 $allowedmimes = array(
183 'application/vnd.oasis.opendocument.text',
184 'application/vnd.oasis.opendocument.spreadsheet',
186 'application/x-zip-compressed',
187 'application/octet-stream'
189 $files = $_FILES[
'uploadfile'];
190 if (!is_array($files[
'name'])) {
191 foreach ($files as $key => &$val) {
196 foreach ($files[
'name'] as $idx => $filename) {
197 if (empty($filename)) {
201 $extension = strtolower(pathinfo((
string) $filename, PATHINFO_EXTENSION));
202 if (!in_array($extension, $allowedext,
true)) {
204 setEventMessages($langs->trans(
"ErrorFileNotUploaded").
' (Only .odt/.ods templates are allowed)',
null,
'errors');
205 dol_syslog(__FILE__.
" ODT template upload refused on extension filename=".$filename, LOG_WARNING);
210 if (!empty($files[
'tmp_name'][$idx]) && function_exists(
'finfo_open')) {
211 $finfo = finfo_open(FILEINFO_MIME_TYPE);
213 $detectedmime = (string) finfo_file($finfo, $files[
'tmp_name'][$idx]);
217 if (!empty($detectedmime) && !in_array(strtolower($detectedmime), $allowedmimes,
true)) {
219 setEventMessages($langs->trans(
"ErrorFileNotUploaded").
' (Invalid MIME type for ODT/ODS template)',
null,
'errors');
220 dol_syslog(__FILE__.
" ODT template upload refused on mime filename=".$filename.
" mime=".$detectedmime, LOG_WARNING);
226 if ($upload_dir && !$error) {
236 if (empty($nomessageinsetmoduleoptions)) {
241 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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...