function mobile_tools_roles_init in Mobile Tools 5
Same name and namespace in other branches
- 6.3 mobile_tools_roles.module \mobile_tools_roles_init()
- 6.2 modules/mobile_tools_roles/mobile_tools_roles.module \mobile_tools_roles_init()
Being called in the hook_init() implementation This function is in charge of changing the user role
1 call to mobile_tools_roles_init()
- mobile_tools_init in ./
mobile_tools.module - Implementation of hook_boot().
File
- ./
mobile_tools.module, line 195 - Mobile Tools provides a range of functionality assisting in creating a mobile drupal site . this functionality contains:
Code
function mobile_tools_roles_init() {
global $user;
$roles = $user->roles;
//count the number of mobile roles... must be bigger then 1
$count = db_result(db_query("SELECT COUNT(*) as count FROM {mobile_tools_roles_relations}"));
if ($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_handling', FALSE) == 'theme-switch') {
unset($user->roles[$key]);
$user->roles[$role->sibling['id']] = $role->sibling['name'];
}
}
}
}