From f84f94f0bef21caa117786ed3e1ef42045f4ee68 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 3 Feb 2023 11:09:59 +0100 Subject: [PATCH] delete rights if exists when delete object --- htdocs/modulebuilder/index.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 236e3f2c3f8..782a1623678 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1814,6 +1814,27 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) { dolReplaceInFile($moduledescriptorfile, array('/*'.strtoupper($objectname).'*/' => '')); } + // regenerate permissions and delete them + $rightToadd = " + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); // Permission id (must not be already used) + \$this->rights[\$r][1] = 'Read objects of ".$module."'; // Permission label + \$this->rights[\$r][4] = '".strtolower($objectname)."'; + \$this->rights[\$r][5] = 'read'; // In php code, permission will be checked by test if (\$user->rights->toto->myobject->read) + \$r++; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); // Permission id (must not be already used) + \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; // Permission label + \$this->rights[\$r][4] = '".strtolower($objectname)."'; + \$this->rights[\$r][5] = 'write'; // In php code, permission will be checked by test if (\$user->rights->toto->myobject->write) + \$r++; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); // Permission id (must not be already used) + \$this->rights[\$r][1] = 'Delete objects of ".$module."'; // Permission label + \$this->rights[\$r][4] = '".strtolower($objectname)."'; + \$this->rights[\$r][5] = 'delete'; // In php code, permission will be checked by test if (\$user->rights->toto->myobject->delete) + \$r++; + "; + + $deleteright = dolReplaceInFile($moduledescriptorfile, array($rightToadd => '', '/*'.strtoupper($objectname).'*/' => '', "/*END ".strtoupper($objectname).'*/'."\n\t\t" => ''."\n\t\t")); + $resultko = 0; foreach ($filetodelete as $tmpfiletodelete) { $resulttmp = dol_delete_file($dir.'/'.$tmpfiletodelete, 0, 0, 1);