function og_role_save in Organic groups 7
Same name and namespace in other branches
- 7.2 og.module \og_role_save()
Save a user role to the database.
Parameters
$role: A role object to modify or add. If $role->rid is not specified, a new role will be created.
Return value
Status constant indicating if role was created or updated. Failure to write the user role record will return FALSE. Otherwise. SAVED_NEW or SAVED_UPDATED is returned depending on the operation performed.
3 calls to og_role_save()
- og_create_global_role in ./
og.module - Add a new global role - a role associated to group ID 0.
- og_roles_override in ./
og.module - Create new roles, based on the default roles and permissions.
- og_ui_user_admin_roles_submit in og_ui/
og_ui.admin.inc
File
- ./
og.module, line 2611 - Enable users to create and manage groups with roles and permissions.
Code
function og_role_save($role) {
if ($role->name) {
// Prevent leading and trailing spaces in role names.
$role->name = trim($role->name);
}
if (!empty($role->rid) && $role->name) {
$status = drupal_write_record('og_role', $role, 'rid');
module_invoke_all('og_role_update', $role);
}
else {
$status = drupal_write_record('og_role', $role);
module_invoke_all('og_role_insert', $role);
}
og_invalidate_cache();
return $status;
}