Fix module permissions for MVP access
Permission System Fixes: - Uncommented and updated module permissions - Added proper permission levels: read, write, delete, admin - Updated permission names from 'myobject' to 'declarationtva' - Fixed menu permission checks Permission Levels: - Read: Access to view declarations and periods - Write: Create and update declarations - Delete: Remove declarations and periods - Admin: Access to configuration and setup Access Control Updates: - Updated setup_mvp.php to use correct permission check - Updated declarationtvaindex.php to use correct permission check - Menu entries now use proper permission validation Testing Instructions: 1. Disable and re-enable the module to refresh permissions 2. Go to Home -> Users -> admin user 3. Check DeclarationTVA permissions are enabled 4. Try accessing the configuration page again The module should now be accessible with proper permissions!
This commit is contained in:
parent
a419fcfc15
commit
e91f0dc3b0
@ -21,7 +21,7 @@ if (!$res) {
|
|||||||
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_config.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_config.class.php';
|
||||||
|
|
||||||
// Access control
|
// Access control
|
||||||
if (!$user->rights->declarationtva->admin) {
|
if (!$user->hasRight("declarationtva", "declarationtva", "admin")) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -294,24 +294,27 @@ class modDeclarationTVA extends DolibarrModules
|
|||||||
$r = 0;
|
$r = 0;
|
||||||
// Add here entries to declare new permissions
|
// Add here entries to declare new permissions
|
||||||
/* BEGIN MODULEBUILDER PERMISSIONS */
|
/* BEGIN MODULEBUILDER PERMISSIONS */
|
||||||
/*
|
|
||||||
$o = 1;
|
$o = 1;
|
||||||
$this->rights[$r][0] = $this->numero . sprintf("%02d", ($o * 10) + 1); // Permission id (must not be already used)
|
$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][1] = 'Read DeclarationTVA'; // Permission label
|
||||||
$this->rights[$r][4] = 'myobject';
|
$this->rights[$r][4] = 'declarationtva';
|
||||||
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'myobject', 'read'))
|
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'declarationtva', 'read'))
|
||||||
$r++;
|
$r++;
|
||||||
$this->rights[$r][0] = $this->numero . sprintf("%02d", ($o * 10) + 2); // Permission id (must not be already used)
|
$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][1] = 'Create/Update DeclarationTVA'; // Permission label
|
||||||
$this->rights[$r][4] = 'myobject';
|
$this->rights[$r][4] = 'declarationtva';
|
||||||
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'myobject', 'write'))
|
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'declarationtva', 'write'))
|
||||||
$r++;
|
$r++;
|
||||||
$this->rights[$r][0] = $this->numero . sprintf("%02d", ($o * 10) + 3); // Permission id (must not be already used)
|
$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][1] = 'Delete DeclarationTVA'; // Permission label
|
||||||
$this->rights[$r][4] = 'myobject';
|
$this->rights[$r][4] = 'declarationtva';
|
||||||
$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->hasRight('declarationtva', 'myobject', 'delete'))
|
$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++;
|
$r++;
|
||||||
*/
|
|
||||||
/* END MODULEBUILDER PERMISSIONS */
|
/* 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.
|
'langs' => 'declarationtva@declarationtva', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
'position' => 1000 + $r,
|
'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.
|
'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' => '',
|
'target' => '',
|
||||||
'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
|
'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.
|
'langs' => 'declarationtva@declarationtva', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
'position' => 1000 + $r,
|
'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.
|
'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' => '',
|
'target' => '',
|
||||||
'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
|
'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
|
||||||
);
|
);
|
||||||
|
|||||||
@ -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';
|
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_period.class.php';
|
||||||
|
|
||||||
// Access control
|
// Access control
|
||||||
if (!$user->rights->declarationtva->read) {
|
if (!$user->hasRight("declarationtva", "declarationtva", "read")) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user