function mobile_tools_roles_boot in Mobile Tools 7.2
Same name in this branch
- 7.2 mobile_tools_roles/mobile_tools_roles.module \mobile_tools_roles_boot()
- 7.2 mobile_tools_roles/mobile_tools_roles.inc \mobile_tools_roles_boot()
Same name and namespace in other branches
- 6 mobile_tools_roles.inc \mobile_tools_roles_boot()
Being called in the hook_init() implementation This function is in charge of changing the user role
File
- mobile_tools_roles/
mobile_tools_roles.module, line 24 - Contains the functionality to add mobile user roles
Code
function mobile_tools_roles_boot() {
global $user;
$roles = $user->roles;
//count the number of mobile roles... must be bigger then 1
$result = db_query("SELECT COUNT(*) as count FROM {mobile_tools_roles_relations}");
$item = $result
->fetchObject();
if ($item->count > 0) {
foreach ($roles as $key => $value) {
$role = mobile_tools_roles_info(array(
'id' => $key,
));
if ($role->type == 'desktop' && $role->has_sibling == 1 && ($_SESSION['mobile-tools-site-type'] == 'mobile' || $_SESSION['mobile-tools-mobile-device']['type'] == 'mobile' && variable_get('mobile_tools_theme_switch', FALSE) == 'mobile-tools-mobile-device')) {
unset($user->roles[$key]);
$user->roles[$role->sibling['id']] = $role->sibling['name'];
}
}
}
}