Debug modulebuilder

This commit is contained in:
Laurent Destailleur 2023-03-07 15:51:27 +01:00
parent 009288ad4d
commit bd066b3211
4 changed files with 157 additions and 156 deletions

View File

@ -432,7 +432,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
while (($file = readdir($handle)) !== false) {
$reg = array();
if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $file, $reg)) {
if (preg_match('/\.back$/', $file)) {
if (preg_match('/\.back$/', $file) || preg_match('/^(.+)\.disabled\.php/', $file)) {
continue;
}

View File

@ -1788,7 +1788,9 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di
if (empty($conf->use_javascript_ajax)) {
$out .= ' href="'.DOL_URL_ROOT.$url.'" target="_blank"';
} elseif ($jsonopen) {
$out .= ' onclick="javascript:'.$jsonopen.'"';
$out .= ' href="#" onclick="javascript:'.$jsonopen.'"';
} else {
$out .= ' href="#"';
}
$out .= '>'.$buttonstring.'</a>';

View File

@ -174,3 +174,6 @@ MenuDeletedSuccessfuly=Menu has been successfully deleted
MenuAddedSuccessfuly=Menu has been successfully added
MenuUpdatedSuccessfuly=Menu has been successfully updated
ApiObjectDeleted=API for object %s has been successfully deleted
CRUDRead=Read
CRUDCreateWrite=Create or Update
FailedToAddCodeIntoDescriptor=Failed to add code into descriptor. Check that the string comment "%s" is still present into the file.

View File

@ -924,19 +924,17 @@ if ($dirins && $action == 'addlanguage' && !empty($module)) {
}
// remove/delete File
// Remove/delete File
if ($dirins && $action == 'confirm_removefile' && !empty($module)) {
$objectname = $tabobj;
$relativefilename = dol_sanitizePathName(GETPOST('file', 'restricthtml'));
$file_api = $dirins."/".$relativefilename;
//check if have more than one object
// Scan dir class to detect all classes of module $module and save them into $objects[]
$dirins = $listofmodules[strtolower($module)]['moduledescriptorrootpath'];
$destdir = $dirins.'/'.strtolower($module);
$listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$');
$objects = array();
foreach ($listofobject as $fileobj) {
if (preg_match('/^api_/', $fileobj['name'])) {
continue;
@ -952,115 +950,57 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) {
}
}
$existObj = 0;
$file = file_get_contents($file_api);
$objs = array();
if (str_contains($file, $objectname)) {
$existObj++;
}
if ($existObj && count($objects) > 1) {
$begin = '/*CRUD FOR '.strtoupper($objectname).'*/';
$end = '/*END CRUD FOR '.strtoupper($objectname).'*/';
$varcomentedDel = "\t * @var ".$objectname." \$".strtolower($objectname)." {@type ".$objectname."}";
$propsDel .= "\tpublic \$".strtolower($objectname).";";
$constructObjDel .= "\t\t\$this->".strtolower($objectname)."= new ".$objectname."(\$this->db);";
$content = file($file_api);
// for delete property and the initialization from the construct
foreach ($content as $lineNumber => &$lineContent) {
if (strpos($lineContent, $varcomentedDel) !== false) {
$lineContent = '';
// Now we delete the file
if ($relativefilename) {
$dirnametodelete = dirname($relativefilename);
$filetodelete = $dirins.'/'.$relativefilename;
$dirtodelete = $dirins.'/'.$dirnametodelete;
$result = dol_delete_file($filetodelete);
if (!$result) {
setEventMessages($langs->trans("ErrorFailToDeleteFile", basename($filetodelete)), null, 'errors');
} else {
// If we delete a .sql file, we delete also the other .sql file
if (preg_match('/\.sql$/', $relativefilename)) {
if (preg_match('/\.key\.sql$/', $relativefilename)) {
$relativefilename = preg_replace('/\.key\.sql$/', '.sql', $relativefilename);
$filetodelete = $dirins.'/'.$relativefilename;
$result = dol_delete_file($filetodelete);
} elseif (preg_match('/\.sql$/', $relativefilename)) {
$relativefilename = preg_replace('/\.sql$/', '.key.sql', $relativefilename);
$filetodelete = $dirins.'/'.$relativefilename;
$result = dol_delete_file($filetodelete);
}
}
if (strpos($lineContent, $propsDel) !== false) {
$lineContent = '';
if (dol_is_dir_empty($dirtodelete)) {
dol_delete_dir($dirtodelete);
}
if (strpos($lineContent, $constructObjDel) !== false) {
$lineContent = '';
// Update descriptor file to comment file
if (in_array($tab, array('css', 'js'))) {
$srcfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php';
$arrayreplacement = array('/^\s*\''.preg_quote('/'.$relativefilename, '/').'\',*/m'=>' // \'/'.$relativefilename.'\',');
dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
}
}
$allContent = implode("", $content);
file_put_contents($file_api, $allContent);
// for delete methods of object
$handle = fopen($file_api, "r");
$i = 1;
$lines = array();
while (($line = fgets($handle)) !== false) {
//search line begin
if (strpos($line, $begin) !== false) {
$start_line = $i;
// Copy lines until the end on array
while (($line = fgets($handle)) !== false) {
if (strpos($line, $end) !== false) {
$end_line = $i;
break;
}
$lines[] = $line;
$i++;
}
break;
if (preg_match('/_extrafields/', $relativefilename)) {
// Now we update the object file to set $isextrafieldmanaged to 0
$srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php';
$arrayreplacement = array('/\$isextrafieldmanaged = 1;/' => '$isextrafieldmanaged = 0;');
dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
}
$i++;
}
$allContent = implode("", $lines);
//var_dump($allContent);exit;
$check = dolReplaceInFile($file_api, array($allContent => ''));
if ($check) {
dolReplaceInFile($file_api, array($begin => '', $end => ''));
setEventMessages($langs->trans("ApiObjectDeleted", $langs->transnoentities($objectname)), null);
}
fclose($handle);
}
if (count($objects) == 1 && $existObj) {
if ($relativefilename) {
$dirnametodelete = dirname($relativefilename);
$filetodelete = $dirins.'/'.$relativefilename;
$dirtodelete = $dirins.'/'.$dirnametodelete;
$result = dol_delete_file($filetodelete);
if (!$result) {
setEventMessages($langs->trans("ErrorFailToDeleteFile", basename($filetodelete)), null, 'errors');
} else {
// If we delete a .sql file, we delete also the other .sql file
if (preg_match('/\.sql$/', $relativefilename)) {
if (preg_match('/\.key\.sql$/', $relativefilename)) {
$relativefilename = preg_replace('/\.key\.sql$/', '.sql', $relativefilename);
$filetodelete = $dirins.'/'.$relativefilename;
$result = dol_delete_file($filetodelete);
} elseif (preg_match('/\.sql$/', $relativefilename)) {
$relativefilename = preg_replace('/\.sql$/', '.key.sql', $relativefilename);
$filetodelete = $dirins.'/'.$relativefilename;
$result = dol_delete_file($filetodelete);
}
}
if (dol_is_dir_empty($dirtodelete)) {
dol_delete_dir($dirtodelete);
}
// Update descriptor file to comment file
if (in_array($tab, array('css', 'js'))) {
$srcfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php';
$arrayreplacement = array('/^\s*\''.preg_quote('/'.$relativefilename, '/').'\',*/m'=>' // \'/'.$relativefilename.'\',');
dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
}
if (preg_match('/_extrafields/', $relativefilename)) {
// Now we update the object file to set $isextrafieldmanaged to 0
$srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php';
$arrayreplacement = array('/\$isextrafieldmanaged = 1;/' => '$isextrafieldmanaged = 0;');
dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
}
// Now we update the lib file to set $showtabofpagexxx to 0
$varnametoupdate = '';
$reg = array();
if (preg_match('/_([a-z]+)\.php$/', $relativefilename, $reg)) {
$varnametoupdate = 'showtabofpage'.$reg[1];
}
if ($varnametoupdate) {
$srcfile = $dirins.'/'.strtolower($module).'/lib/'.strtolower($module).'_'.strtolower($objectname).'.lib.php';
$arrayreplacement = array('/\$'.$varnametoupdate.' = 1;/' => '$'.$varnametoupdate.' = 0;');
dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
}
// Now we update the lib file to set $showtabofpagexxx to 0
$varnametoupdate = '';
$reg = array();
if (preg_match('/_([a-z]+)\.php$/', $relativefilename, $reg)) {
$varnametoupdate = 'showtabofpage'.$reg[1];
}
if ($varnametoupdate) {
$srcfile = $dirins.'/'.strtolower($module).'/lib/'.strtolower($module).'_'.strtolower($objectname).'.lib.php';
$arrayreplacement = array('/\$'.$varnametoupdate.' = 1;/' => '$'.$varnametoupdate.' = 0;');
dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
}
}
}
@ -1074,9 +1014,12 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
if ($result) {
setEventMessages($result, null, 'errors');
} else {
/* FIX ALI header must be after action. Always add an exit after a header.
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
*/
setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings');
}
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings');
}
$objectname = ucfirst($objectname);
@ -1539,31 +1482,43 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
// Regenerate left menu entry in descriptor for $objectname
$stringtoadd = "
\$this->menu[\$r++]=array(
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'fk_menu'=>'fk_mainmenu=mymodule',
// This is a Left menu entry
'type'=>'left',
'titre'=>'List MyObject',
'mainmenu'=>'mymodule',
'leftmenu'=>'myobject',
'leftmenu'=>'mymodule_myobject',
'url'=>'/mymodule/myobject_list.php',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'mymodule@mymodule',
'position'=>1100+\$r,
// Define condition to show or hide menu entry. Use '\$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'\$conf->mymodule->enabled',
// Use 'perms'=>'\$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'perms'=>'1',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2,
);
\$this->menu[\$r++]=array(
'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject',
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule_myobject',
// This is a Left menu entry
'type'=>'left',
'titre'=>'New MyObject',
'mainmenu'=>'mymodule',
'leftmenu'=>'myobject',
'leftmenu'=>'mymodule_myobject',
'url'=>'/mymodule/myobject_card.php?action=create',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'mymodule@mymodule',
'position'=>1100+\$r,
// Define condition to show or hide menu entry. Use '\$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'\$conf->mymodule->enabled',
// Use 'perms'=>'\$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'perms'=>'1',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2
);\n";
$stringtoadd = preg_replace('/MyObject/', $objectname, $stringtoadd);
@ -1572,13 +1527,14 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
$moduledescriptorfile = $destdir.'/core/modules/mod'.$module.'.class.php';
}
// TODO Allow a replace with regex using dolReplaceInFile with param arryreplacementisregex to 1
// TODO Avoid duplicate addition
// load class and check if menu exist with same object name
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
dol_include_once($pathtofile);
$class = 'mod'.$module;
// TODO Allow a replace with regex using dolReplaceInFile with param arryreplacementisregex to 1
// TODO Avoid duplicate addition
// load class and check if menu exist with same object name
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
dol_include_once($pathtofile);
$class = 'mod'.$module;
if (class_exists($class)) {
try {
$moduleobj = new $class($db);
@ -1587,8 +1543,8 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
dol_print_error($db, $e->getMessage());
}
}
$menus = $moduleobj->menu;
$counter = 0 ;
$menus = $moduleobj->menu;
$counter = 0 ;
foreach ($menus as $menu) {
if ($menu['leftmenu'] == strtolower($objectname)) {
$counter++;
@ -1597,8 +1553,9 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
if (!$counter) {
dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER LEFTMENU MYOBJECT */' => '/*LEFTMENU '.strtoupper($objectname).'*/'.$stringtoadd."\n\t\t".'/*END LEFTMENU '.strtoupper($objectname).'*/'."\n\t\t".'/* END MODULEBUILDER LEFTMENU MYOBJECT */'));
}
// Add module descriptor to list of files to replace "MyObject' string with real name of object.
$filetogenerate[] = 'core/modules/mod'.$module.'.class.php';
// Add module descriptor to list of files to replace "MyObject' string with real name of object.
$filetogenerate[] = 'core/modules/mod'.$module.'.class.php';
}
if (!$error) {
@ -1940,9 +1897,13 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) {
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
if ($result) {
setEventMessages($result, null, 'errors');
$error++;
} else {
/* TODO ALI Header reidrect must be at end after actions. Also tab=pemrissions looks strange
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
*/
setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings');
}
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings');
}
if (preg_match('/[^a-z0-9_]/i', $objectname)) {
$error++;
@ -2244,15 +2205,32 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) {
\$r++;
";
$moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php';
//var_dump($existRight.' '.$firstRight);exit;
if (!$existRight) {
dolReplaceInFile($moduledescriptorfile, array('/*END '.strtoupper($objectForPerms).'*/' => $rightToAdd.'/*END '.strtoupper($objectForPerms).'*/'));
setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null);
}
if ($firstRight>0) {
dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectForPerms).'*/'.$rightToAdd."/*END ".strtoupper($objectForPerms).'*/'."\n\t\t".'/* END MODULEBUILDER PERMISSIONS */'));
setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null);
if ($firstRight > 0) {
$filecontentbefore = file_get_contents($moduledescriptorfile);
$result = dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectForPerms).'*/'.$rightToAdd."/*END ".strtoupper($objectForPerms).'*/'."\n\t\t".'/* END MODULEBUILDER PERMISSIONS */'));
$filecontentafter = file_get_contents($moduledescriptorfile);
if ($filecontentbefore != $filecontentafter) {
setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null);
} else {
setEventMessages($langs->trans('FailedToAddCodeIntoDescriptor', 'END MODULEBUILDER PERMISSIONS'), null, 'warnings');
}
}
}
clearstatcache(true);
if (function_exists('opcache_invalidate')) {
opcache_reset(); // remove the include cache hell !
}
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
exit;
}
@ -2336,6 +2314,7 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e
}
}
// TODO ALI Update of permission must be done by rewriting completely the permission section
//prepare right want to delete
$right = "
\$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1);
@ -2352,6 +2331,7 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e
\$this->rights[\$r][5] = '$crud';
\$r++;
";
if (!$error) {
if (isModEnabled(strtolower($module))) {
$result = unActivateModule(strtolower($module));
@ -2366,8 +2346,14 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e
$moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php';
$check = dolReplaceInFile($moduledescriptorfile, array($right => $rightUpdated));
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
setEventMessages($langs->trans('PermissionUpdatedSuccesfuly'), null);
clearstatcache(true);
if (function_exists('opcache_invalidate')) {
opcache_reset(); // remove the include cache hell !
}
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
exit;
}
}
@ -2377,7 +2363,7 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p
// load class and check if right exist
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
dol_include_once($pathtofile);
$class = 'mod'.$module;
$class = 'mod'.$module;
if (class_exists($class)) {
try {
$moduleobj = new $class($db);
@ -2387,14 +2373,14 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p
}
}
$permissions = $moduleobj->rights;
$key = (int) GETPOST('permskey', 'int')-1;
//get permission want to delete from permissions array
$x1 = $permissions[$key][1];
$x2 = $permissions[$key][4];
$x3 = $permissions[$key][5];
//prepare right want to delete
$rightTodelete = "
$permissions = $moduleobj->rights;
$key = (int) GETPOST('permskey', 'int')-1;
//get permission want to delete from permissions array
$x1 = $permissions[$key][1];
$x2 = $permissions[$key][4];
$x3 = $permissions[$key][5];
//prepare right want to delete
$rightTodelete = "
\$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1);
\$this->rights[\$r][1] = '$x1';
\$this->rights[\$r][4] = '$x2';
@ -2402,9 +2388,11 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p
\$r++;
";
$moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php';
// TODO ALI The delete must be done by rewriting all content between /* BEGIN MODULEBUILDER PERMISSIONS */ and /* END MODULEBUILDER PERMISSIONS */
$check = dolReplaceInFile($moduledescriptorfile, array($rightTodelete => "\n\t\t"));
$moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php';
$check = dolReplaceInFile($moduledescriptorfile, array($rightTodelete => "\n\t\t"));
if ($check > 0) {
//check if all permissions of object was deleted
$permsForObj = array();
@ -2424,13 +2412,20 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p
if ($result) {
setEventMessages($result, null, 'errors');
}
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
setEventMessages($langs->trans('PermissionDeletedSuccesfuly'), null);
setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings');
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
exit;
} else {
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
setEventMessages($langs->trans('PermissionDeletedSuccesfuly'), null);
clearstatcache(true);
if (function_exists('opcache_invalidate')) {
opcache_reset(); // remove the include cache hell !
}
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
exit;
}
}
@ -3401,7 +3396,8 @@ if ($module == 'initmodule') {
print '</td><td>';
print $moduleobj->numero;
print '<span class="opacitymedium">';
print ' &nbsp; (<a href="'.DOL_URL_ROOT.'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info" target="_blank" rel="noopener noreferrer">'.$langs->trans("SeeIDsInUse").'</a>';
print ' &nbsp; (';
print dolButtonToOpenUrlInDialogPopup('popup_modules_id', $langs->transnoentitiesnoconv("SeeIDsInUse"), $langs->transnoentitiesnoconv("SeeIDsInUse"), '/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info', '', '');
print ' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans("SeeReservedIDsRangeHere").'</a>)';
print '</span>';
print '</td></tr>';
@ -4873,8 +4869,8 @@ if ($module == 'initmodule') {
}
}
// declared select list for actions and labels permissions
$crud = array('Read','Write','Delete');
$labels = array("Read objects of $module","Create/Update objects of $module","Delete objects of $module");
$crud = array('read'=>'CRUDRead', 'write'=>'CRUDCreateWrite', 'delete'=>'Delete');
$labels = array("Read objects of ".$module, "Create/Update objects of ".$module, "Delete objects of ".$module);
$action = GETPOST('action', 'alpha');
@ -4919,18 +4915,18 @@ if ($module == 'initmodule') {
print '<tr class="liste_titre">';
print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, "center");
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, "center");
print_liste_field_titre("Permission", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, "center");
print_liste_field_titre("Object", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, "center");
print_liste_field_titre("CRUD", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, "center");
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, "center");
print "</tr>\n";
//form for add new right
print '<tr>';
print '<td><input type="text" readonly name="id" value="'.dol_escape_htmltag($moduleobj->numero.sprintf('%02d', $i + count($perms))).'"></td>';
print '<tr class="small">';
print '<td><input type="text" readonly name="id" class="width75" value="'.dol_escape_htmltag($moduleobj->numero.sprintf('%02d', $i + count($perms))).'"></td>';
print '<td>';
print '<select name="label" >';
print '<option value=""></option>';
for ($i = 0; $i<3; $i++) {
for ($i = 0; $i < 3; $i++) {
print '<option value="'.dol_escape_htmltag($labels[$i]).'">'.$labels[$i].'</option>';
}
print '</select></td>';
@ -4946,8 +4942,8 @@ if ($module == 'initmodule') {
print '<td><select class="maxwidth" name="crud">';
print '<option value=""></option>';
for ($i = 0;$i<3;$i++) {
print '<option value="'.$crud[$i].'">'.$langs->trans($crud[$i]).'</option>';
foreach ($crud as $key => $val) {
print '<option value="'.$key.'">'.$langs->trans($val).'</option>';
}
print '</td>';
@ -5016,7 +5012,7 @@ if ($module == 'initmodule') {
print '<tr class="oddeven">';
print '<td>';
print $perm[0];
print dol_escape_htmltag($perm[0]);
print '</td>';
print '<td>';
@ -5024,7 +5020,7 @@ if ($module == 'initmodule') {
print '</td>';
print '<td>';
print $perm[4];
print dol_escape_htmltag($perm[4]);
print '</td>';
print '<td>';
@ -5042,7 +5038,7 @@ if ($module == 'initmodule') {
}
}
} else {
print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
print '<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
}
print '</table>';