function og_role_save in Organic groups 7.2
Same name and namespace in other branches
- 7 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.
7 calls to og_role_save()
- OgMigrateOgurRoles::import in includes/
migrate/ 7000/ og_ogur_roles.migrate.inc - Create group, group-audience and group description fields.
- OgMigrateRoles::preImport in includes/
migrate/ 7200/ og_roles.migrate.inc - Copy all existing global roles to bundle-specific versions. Although similar processing is available through the og_roles_override() function, special handling is necessary to ensure that custom global roles are copied as well as default global roles.
- OgRoleRevoke::testOgRoleRevoke in ./
og.test - og_features_permission_features_rebuild in includes/
og_features_permission.features.inc - Implements hook_features_rebuild().
- og_features_role_features_rebuild in includes/
og_features_role.features.inc - Implements hook_features_rebuild().
File
- ./
og.module, line 2899 - 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;
}