diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 0d2137928ac..2807a8bea6d 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1218,6 +1218,53 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php'=>'core/modules/'.strtolower($module).'/doc/pdf_standard_'.strtolower($objectname).'.modules.php' ); } + if (GETPOST('generatepermissions', 'aZ09')) { + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + dol_include_once($pathtofile); + $class = 'mod'.$module; + if (class_exists($class)) { + try { + $moduleobj = new $class($db); + } catch (Exception $e) { + $error++; + dol_print_error($db, $e->getMessage()); + } + } + if (empty($firstobjectname)) { + $rightToadd = preg_replace('/myobject/', $objectname, $rightToadd); + } + if ($objectname != $firstobjectname) { + $rightToadd = " + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Read objects of ".$module."'; + \$this->rights[\$r][4] = '".strtolower($objectname)."'; + \$this->rights[\$r][5] = 'read'; + \$r++; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; + \$this->rights[\$r][4] = '".strtolower($objectname)."'; + \$this->rights[\$r][5] = 'write'; + \$r++; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Delete objects of ".$module."'; + \$this->rights[\$r][4] = '".strtolower($objectname)."'; + \$this->rights[\$r][5] = 'delete'; + \$r++; + "; + $rights = $moduleobj->rights; + $rightAdd = explode("\$r++", $rightToadd); + + for ($i=0; $itrans('PermissionAlreadyExist'), null, 'errors'); + } + } + } + dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectname).'*/'.$rightToadd."/*END ".strtoupper($objectname).'*/'."\n\t\t".'/* END MODULEBUILDER PERMISSIONS */')); + } + } if (!$error) { @@ -2760,6 +2807,7 @@ if ($module == 'initmodule') { print '
'; print '
'; print '
'; + print '
'; print '
'; print ''; print '
';