diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php
index 453b34529b4..2f416e2e296 100644
--- a/htdocs/core/lib/modulebuilder.lib.php
+++ b/htdocs/core/lib/modulebuilder.lib.php
@@ -657,44 +657,28 @@ function writePropsInAsciiDoc($file, $objectname, $destfile)
$table .= "|".$attUnique;
}
$table .="\n";
- $countKeys = count($keys);
- for ($j=0;$j<$countKeys;$j++) {
- $string = $keys[$j];
+ foreach ($keys as $string) {
$string = trim($string, "'");
$string = rtrim($string, ",");
-
- $array = [];
- eval("\$array = [$string];");
+ $array = eval("return [$string];");
// check if is array after cleaning string
if (!is_array($array)) {
return -1;
}
- // name of field
- $field = array_keys($array);
- // all values of each property
- $values = array_values($array);
+ $field = array_keys($array);
+ $values = array_values($array)[0];
// check each field has all properties and add it if missed
- if (count($values[0]) <=22) {
- foreach ($attributesUnique as $cle) {
- if (!in_array($cle, array_keys($values[0]))) {
- $values[0][$cle] = '';
- }
+ foreach ($attributesUnique as $attUnique) {
+ if (!array_key_exists($attUnique, $values)) {
+ $values[$attUnique] = '';
}
}
- //reorganize $values with order attributeUnique
- $valuesRestructured = array();
- foreach ($attributesUnique as $key) {
- if (array_key_exists($key, $values[0])) {
- $valuesRestructured[$key] = $values[0][$key];
- }
- }
- // write all values of properties for each field
- $table .= "|*".$field[0]."*|";
- $table .= implode("|", array_values($valuesRestructured))."\n";
+ $table .= "|*" . $field[0] . "*|";
+ $table .= implode("|", $values) . "\n";
}
// end table
$table .= "|===";
@@ -780,8 +764,7 @@ function writePermsInAsciiDoc($file, $destfile)
$string .= "\n";
//content table
$array = explode(";", $content);
- $indexIgnored = 15;
- $permissions = array_slice($array, $indexIgnored, null, true);
+ $permissions = array_filter($array);
// delete occurrences "$r++" and ID
$permissions = str_replace('$r++', 1, $permissions);
@@ -806,21 +789,12 @@ function writePermsInAsciiDoc($file, $destfile)
array_pop($permsN);
// Group permissions by Object and add it to string
- $temp_array = [];
$final_array = [];
- $countRights = count($permsN);
- for ($i = 0; $i < $countRights ; $i++) {
- // Add current element to temporary array
- $temp_array[] = $permsN[$i];
- // add them to the final array and empty the temporary array
- if (count($temp_array) == 2) {
- $final_array[] = $temp_array;
- $temp_array = [];
- }
- }
- // add it to the final array
- if (count($temp_array) > 0) {
+ $index = 0;
+ while ($index < count($permsN)) {
+ $temp_array = [$permsN[$index], $permsN[$index + 1]];
$final_array[] = $temp_array;
+ $index += 2;
}
$result = array();
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index 1ca41cadfb7..1fe46109c61 100644
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -316,6 +316,7 @@ ErrorFixThisHere=Fix this here
ErrorTheUrlOfYourDolInstanceDoesNotMatchURLIntoOAuthSetup=Error: The URL of you current instance (%s) does not match the URL defined into your OAuth2 login setup (%s). Doing OAuth2 login in such a configuration is not allowed.
ErrorMenuExistValue=A Menu already exist with this Title or URL
ErrorSVGFilesNotAllowedAsLinksWithout=SVG files are not allowed as external links without option %s
+ErrorTypeMenu=Impossible to add another menu for the same module on the navbar, not handle yet
# Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang
index 14bf3e959f5..cee77697d33 100644
--- a/htdocs/langs/fr_FR/errors.lang
+++ b/htdocs/langs/fr_FR/errors.lang
@@ -312,6 +312,7 @@ ErrorEqualModule=Module invalide dans %s.
ErrorFieldValue=La valeur pour %s est incorrecte
ErrorCoherenceMenu=Le champ %s est requis lorsque %s vaut 'left'
ErrorMenuExistValue=Un menu existe déjà avec ce titre ou cette URL
+ErrorTypeMenu=Impossible de rajouter un autre menu sur la navbar pour le même module ,pas encore traité
# Warnings
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 99d2bf28bbd..d6527adc0a8 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -1473,7 +1473,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
'mon module'=>$module,
'Mon module'=>$module,
'htdocs/modulebuilder/template/'=>strtolower($modulename),
- //'myobject'=>strtolower($objectname),
+ 'myobject'=>strtolower($objectname),
'MyObject'=>$objectname,
//'MYOBJECT'=>strtoupper($objectname),
'---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '')
@@ -2499,6 +2499,10 @@ if ($dirins && $action == 'addmenu' && empty($cancel)) {
setEventMessages($langs->trans("ErrorCoherenceMenu", $langs->transnoentities("leftmenu"), $langs->transnoentities("type")), null, 'errors');
}
}
+ if (GETPOST('type', 'alpha') == 'top') {
+ $error++;
+ setEventMessages($langs->trans("ErrorTypeMenu", $langs->transnoentities("type")), null, 'errors');
+ }
$moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php';
if (!$error) {
@@ -2599,6 +2603,11 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int')) {
} else {
$menuModify['enabled'] = "0";
}
+
+ if (GETPOST('type', 'alpha') == 'top') {
+ $error++;
+ setEventMessages($langs->trans("ErrorTypeMenu", $langs->transnoentities("type")), null, 'errors');
+ }
if (!$error) {
//update menu
$result = reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
index bcf72d401ae..71983dbcdb2 100644
--- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
+++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
@@ -268,7 +268,7 @@ class modMyModule extends DolibarrModules
$r = 0;
// Add here entries to declare new permissions
/* BEGIN MODULEBUILDER PERMISSIONS */
- $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
+ /*$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = 'Read objects of MyModule'; // Permission label
$this->rights[$r][4] = 'myobject';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->read)
@@ -282,7 +282,7 @@ class modMyModule extends DolibarrModules
$this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label
$this->rights[$r][4] = 'myobject';
$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->delete)
- $r++;
+ $r++;*/
/* END MODULEBUILDER PERMISSIONS */
// Main menu entries to add
diff --git a/htdocs/modulebuilder/template/doc/Documentation.asciidoc b/htdocs/modulebuilder/template/doc/Documentation.asciidoc
index a6dc59eea14..e649ad16fe2 100644
--- a/htdocs/modulebuilder/template/doc/Documentation.asciidoc
+++ b/htdocs/modulebuilder/template/doc/Documentation.asciidoc
@@ -37,7 +37,7 @@ This document was generated using Dolibarr ERP CRM process
:toc: manual
:toc-placement: preamble
-<<<
+
== INTRODUCTION
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index 56872c26289..a443753a8a7 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -149,19 +149,19 @@ foreach ($object->fields as $key => $val) {
}
// List of fields to search into when doing a "search in all"
-$fieldstosearchall = array();
-foreach ($object->fields as $key => $val) {
- if (!empty($val['searchall'])) {
- $fieldstosearchall['t.'.$key] = $val['label'];
- }
-}
-$parameters = array('fieldstosearchall'=>$fieldstosearchall);
-$reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook > 0) {
- $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
-} elseif ($reshook == 0) {
- $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
-}
+// $fieldstosearchall = array();
+// foreach ($object->fields as $key => $val) {
+// if (!empty($val['searchall'])) {
+// $fieldstosearchall['t.'.$key] = $val['label'];
+// }
+// }
+// $parameters = array('fieldstosearchall'=>$fieldstosearchall);
+// $reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+// if ($reshook > 0) {
+// $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
+// } elseif ($reshook == 0) {
+// $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
+// }
// Definition of array of fields for columns
$arrayfields = array();