fix some problems

This commit is contained in:
Lamrani Abdel 2023-06-05 16:15:52 +02:00
parent 1436ff7a88
commit 0f4feec3ff
7 changed files with 42 additions and 57 deletions

View File

@ -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();

View File

@ -316,6 +316,7 @@ ErrorFixThisHere=<a href="%s">Fix this here</a>
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.

View File

@ -312,6 +312,7 @@ ErrorEqualModule=Module invalide dans <b>%s</b>.
ErrorFieldValue=La valeur pour <b>%s</b> est incorrecte
ErrorCoherenceMenu=Le champ <b>%s</b> est requis lorsque <b>%s</b> 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

View File

@ -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);

View File

@ -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

View File

@ -37,7 +37,7 @@ This document was generated using Dolibarr ERP CRM process
:toc: manual
:toc-placement: preamble
<<<
== INTRODUCTION

View File

@ -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();