Created
March 2, 2015 12:07
-
-
Save rodrigoaguilera/8d10a5de82d9e40280d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Helper function to set permissions for node types. | |
*/ | |
function pineda_set_permissions($role, $permissions, $module = 'node') { | |
$rid = array_search($role, user_roles()); | |
foreach ($permissions as $name) { | |
db_merge('role_permission') | |
->key(array( | |
'rid' => $rid, | |
'permission' => $name, | |
)) | |
->fields(array( | |
'module' => $module, | |
)) | |
->execute(); | |
} | |
// Clear the user access cache. | |
drupal_static_reset('user_access'); | |
drupal_static_reset('user_role_permissions'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment