diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index f2c5160db38..d912c2e40df 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -77,6 +77,8 @@ if ($action == 'setproductionmode') } } +dol_mkdir(DOL_DATA_ROOT.'/api/temp'); // May have been deleted by a purge + /* * View diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index 39f63683575..50b35392644 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -32,7 +32,7 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel { if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Set public note @@ -40,6 +40,6 @@ else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST(' { if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 704653ade84..c995c1269ad 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -599,11 +599,12 @@ function dol_include_once($relpath, $classname='') /** * Return path of url or filesystem. Return alternate root if exists. * - * @param string $path Relative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile - * @param int $type 0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file) - * @return string Full filesystem path (if mode=0), Full url path (if mode=1) + * @param string $path Relative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile + * @param int $type 0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file) + * @param int $returnemptyifnotfound If file was not found, do not return default path but an empty string + * @return string Full filesystem path (if mode=0), Full url path (if mode=1) */ -function dol_buildpath($path, $type=0) +function dol_buildpath($path, $type=0, $returnemptyifnotfound=0) { global $conf; @@ -611,16 +612,20 @@ function dol_buildpath($path, $type=0) if (empty($type)) // For a filesystem path { - $res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard value + $res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard default path foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...) { if ($key == 'main') continue; if (file_exists($dirroot.'/'.$path)) { $res=$dirroot.'/'.$path; - break; + return $res; } } + if ($returnemptyifnotfound) // Not found, we return empty string + { + return ''; + } } else // For an url path { diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 726cf56c0d5..732514de9c1 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -66,3 +66,6 @@ NoTrigger=No trigger NoWidget=No widget EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION) VisibleDesc=Is field is visible in list (-1 means not shown by default but can be added into list to be viewed) +MenusDefDesc=Define here the menus provided by your module (once defined, they are visible into the menu editor %s) +PermissionsDefDesc=Define here the new permissions provided by your module (once defined, they are visible into the default permissions setup %s) +ListOfPermissionsDefined=List of defined permissions diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1c7d8156aa6..43f679541ab 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -682,16 +682,26 @@ if ($action == 'savefile' && empty($cancel)) // Save old version if (dol_is_file($pathoffile)) { - dol_move($pathoffile, $pathoffilebackup, 0, 1, 0, 0); + dol_copy($pathoffile, $pathoffilebackup, 0, 1); } - $content = GETPOST('editfilecontent'); + $content = GETPOST('editfilecontent','none'); // Save file on disk - file_put_contents($pathoffile, $content); - @chmod($pathoffile, octdec($newmask)); + if ($content) + { + dol_delete_file($pathoffile); + file_put_contents($pathoffile, $content); + @chmod($pathoffile, octdec($newmask)); - setEventMessages($langs->trans("FileSaved"), null); + setEventMessages($langs->trans("FileSaved"), null); + } + else + { + setEventMessages($langs->trans("ContentCantBeEmpty"), null, 'errors'); + //$action='editfile'; + $error++; + } } } @@ -1141,9 +1151,12 @@ elseif (! empty($module)) } else { - $fullpathoffile=dol_buildpath($file, 0); // Description - level 2 + $fullpathoffile=dol_buildpath($file, 0, 1); // Description - level 2 - $content = file_get_contents($fullpathoffile); + if ($fullpathoffile) + { + $content = file_get_contents($fullpathoffile); + } // New module print '
'; } else { @@ -1861,7 +2124,7 @@ elseif (! empty($module)) print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); print '