You are here

function mobile_tools_user in Mobile Tools 5

Same name and namespace in other branches
  1. 6 mobile_tools_roles.inc \mobile_tools_user()

Implementation of the user_load function to assure that the right role is being assigned to the user. This is the same actions as in the hook_init() method

File

./mobile_tools.module, line 666
Mobile Tools provides a range of functionality assisting in creating a mobile drupal site . this functionality contains:

Code

function mobile_tools_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'load':
      $user = $account;
      $roles = $user->roles;
      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') {
          unset($user->roles[$key]);
          $user->roles[$role->sibling['id']] = $role->sibling['name'];
        }
      }
      break;
  }
}