function mobile_tools_roles_init in Mobile Tools 6.2
Same name and namespace in other branches
- 5 mobile_tools.module \mobile_tools_roles_init()
- 6.3 mobile_tools_roles.module \mobile_tools_roles_init()
Implementation of hook_init().
File
- modules/
mobile_tools_roles/ mobile_tools_roles.module, line 47 - Primarily Drupal hooks.
Code
function mobile_tools_roles_init() {
// Check the status of mobile roles
if (variable_get('mobile_tools_enable_roles', 0)) {
// Get the current user
global $user;
// Get the current user's roles
$roles = $user->roles;
// Process each of the user's roles and
foreach ($roles as $rid => $role_name) {
$mobile_role = mobile_tools_roles_get_mobile_role($rid);
if (!empty($mobile_role) && mobile_tools_site_type() == 'mobile') {
unset($user->roles[$rid]);
$user->roles[$mobile_role['mrid']] = $mobile_role['name'];
}
}
}
}