0
我有一個超過20個角色和權限的相當大的網站。然而,它始終是相同的權限,但取決於誰創建的內容,權限不同...配置具有相同權限的多個角色
所以我現在做的是這樣的:
// Make the new role
$role = new stdClass;
$role->name = 'Redacteur 1';
$role->weight = 3;
user_role_save($role);
// Permissions to assign to the role.
// Note these are defined in hook_permission()
$perms = array(
'access content','access content overview'
);
// Grant the permissions. This function takes care of all necessary cache resets
user_role_grant_permissions($role->rid, $perms);
// Make the new role
$role = new stdClass;
$role->name = 'Redacteur 2';
$role->weight = 3;
user_role_save($role);
// Permissions to assign to the role.
// Note these are defined in hook_permission()
$perms = array(
'access content','access content overview'
);
// Grant the permissions. This function takes care of all necessary cache resets
user_role_grant_permissions($role->rid, $perms);
難道沒有辦法做這與某種陣列,所以我不會結束1000行代碼。當你想改變某些權限時,你必須修改所有角色......這樣做一定比較容易。有什麼建議?