diff --git a/admin/setup_mvp.php b/admin/setup_mvp.php index b3450b9..9342dbd 100644 --- a/admin/setup_mvp.php +++ b/admin/setup_mvp.php @@ -21,7 +21,7 @@ if (!$res) { require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_config.class.php'; // Access control -if (!$user->rights->declarationtva->admin) { +if (!$user->hasRight("declarationtva", "declarationtva", "admin")) { accessforbidden(); } diff --git a/core/modules/modDeclarationTVA.class.php b/core/modules/modDeclarationTVA.class.php index 61857b6..32aa436 100644 --- a/core/modules/modDeclarationTVA.class.php +++ b/core/modules/modDeclarationTVA.class.php @@ -294,24 +294,27 @@ class modDeclarationTVA extends DolibarrModules $r = 0; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ - /* $o = 1; $this->rights[$r][0] = $this->numero . sprintf("%02d", ($o * 10) + 1); // Permission id (must not be already used) - $this->rights[$r][1] = 'Read objects of DeclarationTVA'; // Permission label - $this->rights[$r][4] = 'myobject'; - $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'myobject', 'read')) + $this->rights[$r][1] = 'Read DeclarationTVA'; // Permission label + $this->rights[$r][4] = 'declarationtva'; + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'declarationtva', 'read')) $r++; $this->rights[$r][0] = $this->numero . sprintf("%02d", ($o * 10) + 2); // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/Update objects of DeclarationTVA'; // Permission label - $this->rights[$r][4] = 'myobject'; - $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'myobject', 'write')) + $this->rights[$r][1] = 'Create/Update DeclarationTVA'; // Permission label + $this->rights[$r][4] = 'declarationtva'; + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'declarationtva', 'write')) $r++; $this->rights[$r][0] = $this->numero . sprintf("%02d", ($o * 10) + 3); // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete objects of DeclarationTVA'; // Permission label - $this->rights[$r][4] = 'myobject'; - $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'myobject', 'delete')) + $this->rights[$r][1] = 'Delete DeclarationTVA'; // Permission label + $this->rights[$r][4] = 'declarationtva'; + $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'declarationtva', 'delete')) + $r++; + $this->rights[$r][0] = $this->numero . sprintf("%02d", ($o * 10) + 4); // Permission id (must not be already used) + $this->rights[$r][1] = 'Admin DeclarationTVA'; // Permission label + $this->rights[$r][4] = 'declarationtva'; + $this->rights[$r][5] = 'admin'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'declarationtva', 'admin')) $r++; - */ /* END MODULEBUILDER PERMISSIONS */ @@ -331,7 +334,7 @@ class modDeclarationTVA extends DolibarrModules 'langs' => 'declarationtva@declarationtva', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position' => 1000 + $r, 'enabled' => 'isModEnabled("declarationtva")', // Define condition to show or hide menu entry. Use 'isModEnabled("declarationtva")' if entry must be visible if module is enabled. - 'perms' => '1', // Use 'perms'=>'$user->hasRight("declarationtva", "myobject", "read")' if you want your menu with a permission rules + 'perms' => '$user->hasRight("declarationtva", "declarationtva", "read")', // Use 'perms'=>'$user->hasRight("declarationtva", "declarationtva", "read")' if you want your menu with a permission rules 'target' => '', 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both ); @@ -349,7 +352,7 @@ class modDeclarationTVA extends DolibarrModules 'langs' => 'declarationtva@declarationtva', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position' => 1000 + $r, 'enabled' => 'isModEnabled("declarationtva")', // Define condition to show or hide menu entry. Use 'isModEnabled("declarationtva")' if entry must be visible if module is enabled. - 'perms' => '1', // Use 'perms'=>'$user->hasRight("declarationtva", "myobject", "read")' if you want your menu with a permission rules + 'perms' => '$user->hasRight("declarationtva", "declarationtva", "read")', // Use 'perms'=>'$user->hasRight("declarationtva", "declarationtva", "read")' if you want your menu with a permission rules 'target' => '', 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both ); diff --git a/declarationtvaindex.php b/declarationtvaindex.php index a43538c..e4d074d 100644 --- a/declarationtvaindex.php +++ b/declarationtvaindex.php @@ -24,7 +24,7 @@ require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationt require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_period.class.php'; // Access control -if (!$user->rights->declarationtva->read) { +if (!$user->hasRight("declarationtva", "declarationtva", "read")) { accessforbidden(); }