You are here

function mobile_tools_roles_init in Mobile Tools 6.3

Same name and namespace in other branches
  1. 5 mobile_tools.module \mobile_tools_roles_init()
  2. 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

File

./mobile_tools_roles.module, line 13
Contains the functionality to add mobile user roles

Code

function mobile_tools_roles_init() {
  if (variable_get('mobile_tools_enable_roles', 0)) {
    global $user;
    $roles = $user->roles;
    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'];
      }
    }
  }
}