Remove no more used option MODULEBUILDER_FOREVERYONE

Add menu entry in main menu Tools for Modulebuilder and API explorer
This commit is contained in:
Laurent Destailleur 2022-11-01 11:46:21 +01:00
parent 28a6a879cb
commit 9aeb1b0f86
4 changed files with 26 additions and 41 deletions

View File

@ -152,37 +152,20 @@ class modApi extends DolibarrModules
$this->menu = array(); // List of menus to add $this->menu = array(); // List of menus to add
$r = 0; $r = 0;
// Add here entries to declare new menus $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools',
// 'type'=>'left',
// Example to declare a new Top Menu entry and its Left menu entry: 'titre'=>'ApiExplorer',
// $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
// 'type'=>'top', // This is a Top menu entry 'mainmenu'=>'tools',
// 'titre'=>'Api top menu', 'leftmenu'=>'devtools_api',
// 'mainmenu'=>'api', 'url'=>'/api/index.php/explorer',
// 'leftmenu'=>'api', 'langs'=>'modulebuilder',
// 'url'=>'/api/pagetop.php', 'position'=>100,
// 'langs'=>'mylangfile@api', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'perms'=>'1',
// 'position'=>100, //'enabled'=>'isModEnabled("api") && preg_match(\'/^(devtools)/\',$leftmenu)',
// 'enabled'=>'$conf->api->enabled', // Define condition to show or hide menu entry. Use '$conf->api->enabled' if entry must be visible if module is enabled. 'enabled'=>'isModEnabled("api")',
// 'perms'=>'1', // Use 'perms'=>'$user->rights->api->level1->level2' if you want your menu with a permission rules 'target'=>'_apiexplorer',
// 'target'=>'', 'user'=>0);
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++;
//
// Example to declare a Left Menu entry into an existing Top menu entry:
// $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
// 'type'=>'left', // This is a Left menu entry
// 'titre'=>'Api left menu',
// 'mainmenu'=>'xxx',
// 'leftmenu'=>'api',
// 'url'=>'/api/pagelevel2.php',
// 'langs'=>'mylangfile@api', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
// 'position'=>100,
// 'enabled'=>'$conf->api->enabled', // Define condition to show or hide menu entry. Use '$conf->api->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
// 'perms'=>'1', // Use 'perms'=>'$user->rights->api->level1->level2' if you want your menu with a permission rules
// 'target'=>'',
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++;
// Exports // Exports

View File

@ -102,16 +102,18 @@ class modModuleBuilder extends DolibarrModules
//------------------ //------------------
$this->menu = array(); $this->menu = array();
$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools',
'type'=>'left', 'type'=>'left',
'titre'=>'ModuleBuilder', 'titre'=>'ModuleBuilder',
'mainmenu'=>'home', 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
'leftmenu'=>'admintools_modulebuilder', 'mainmenu'=>'tools',
'url'=>'/modulebuilder/index.php?mainmenu=home&leftmenu=admintools', 'leftmenu'=>'devtools_modulebuilder',
'url'=>'/modulebuilder/index.php?mainmenu=tools&leftmenu=devtools',
'langs'=>'modulebuilder', 'langs'=>'modulebuilder',
'position'=>100, 'position'=>100,
'perms'=>'1', 'perms'=>'$user->hasRight("modulebuilder", "run")',
'enabled'=>'$conf->modulebuilder->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu) && ($user->admin || $conf->global->MODULEBUILDER_FOREVERYONE)', //'enabled'=>'isModEnabled("modulebuilder") && preg_match(\'/^(devtools|all)/\',$leftmenu)',
'enabled'=>'isModEnabled("modulebuilder")',
'target'=>'_modulebuilder', 'target'=>'_modulebuilder',
'user'=>0); 'user'=>0);
} }

View File

@ -86,7 +86,7 @@ IsAMeasure=Is a measure
DirScanned=Directory scanned DirScanned=Directory scanned
NoTrigger=No trigger NoTrigger=No trigger
NoWidget=No widget NoWidget=No widget
GoToApiExplorer=API explorer ApiExplorer=API explorer
ListOfMenusEntries=List of menu entries ListOfMenusEntries=List of menu entries
ListOfDictionariesEntries=List of dictionaries entries ListOfDictionariesEntries=List of dictionaries entries
ListOfPermissionsDefined=List of defined permissions ListOfPermissionsDefined=List of defined permissions

View File

@ -84,7 +84,7 @@ $idmodule= GETPOST('idmodule', 'alpha');
if (!isModEnabled('modulebuilder')) { if (!isModEnabled('modulebuilder')) {
accessforbidden('Module ModuleBuilder not enabled'); accessforbidden('Module ModuleBuilder not enabled');
} }
if (!$user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) { if (!$user->hasRight("modulebuilder", "run")) {
accessforbidden('ModuleBuilderNotAllowed'); accessforbidden('ModuleBuilderNotAllowed');
} }
@ -2836,9 +2836,9 @@ if ($module == 'initmodule') {
print '<a class="reposition editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=confirm_removefile&token='.newToken().'&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Delete"), 'delete').'</a>'; print '<a class="reposition editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=confirm_removefile&token='.newToken().'&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Delete"), 'delete').'</a>';
print ' &nbsp; '; print ' &nbsp; ';
if (empty($conf->global->$const_name)) { // If module is not activated if (empty($conf->global->$const_name)) { // If module is not activated
print '<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans("ModuleMustBeEnabled", $module).'"><strike>'.$langs->trans("GoToApiExplorer").'</strike></a>'; print '<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans("ModuleMustBeEnabled", $module).'"><strike>'.$langs->trans("ApiExplorer").'</strike></a>';
} else { } else {
print '<a href="'.DOL_URL_ROOT.'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans("GoToApiExplorer").'</a>'; print '<a href="'.DOL_URL_ROOT.'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans("ApiExplorer").'</a>';
} }
} else { } else {
print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=initapi&token='.newToken().'&format=php&file='.urlencode($pathtoapi).'">'.img_picto('Generate', 'generate', 'class="paddingleft"').'</a>'; print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=initapi&token='.newToken().'&format=php&file='.urlencode($pathtoapi).'">'.img_picto('Generate', 'generate', 'class="paddingleft"').'</a>';