original_string: protected function in_alternative_role($context) {
          global $USER, $PAGE;
          if (!empty($USER->access['rsw']) && is_array($USER->access['rsw'])) {
              if (!empty($PAGE->context) && !empty($USER->access['rsw'][$PAGE->context->path])) {
                  return $USER->access['rsw'][$PAGE->context->path];
              }
              foreach ($USER->access['rsw'] as $key=>$role) {
                  if (strpos($context->path, $key)===0) {
                      return $role;
                  }
              }
          }
          return false;
      }
code: protected function in_alternative_role($context) {
          global $USER, $PAGE;
          if (!empty($USER->access['rsw']) && is_array($USER->access['rsw'])) {
              if (!empty($PAGE->context) && !empty($USER->access['rsw'][$PAGE->context->path])) {
                  return $USER->access['rsw'][$PAGE->context->path];
              }
              foreach ($USER->access['rsw'] as $key=>$role) {
                  if (strpos($context->path, $key)===0) {
                      return $role;
                  }
              }
          }
          return false;
      }
code_tokens: protected function in_alternative_role ( $ context ) { global $ USER , $ PAGE ; if ( ! empty ( $ USER -> access [ 'rsw' ] ) && is_array ( $ USER -> access [ 'rsw' ] ) ) { if ( ! empty ( $ PAGE -> context ) && ! empty ( $ USER -> access [ 'rsw' ] [ $ PAGE -> context -> path ] ) ) { return $ USER -> access [ 'rsw' ] [ $ PAGE -> context -> path ] ; } foreach ( $ USER -> access [ 'rsw' ] as $ key => $ role ) { if ( strpos ( $ context -> path , $ key ) === 0 ) { return $ role ; } } } return false ; }
docstring: Determine whether the user is assuming another role
  
  This function checks to see if the user is assuming another role by means of
  role switching. In doing this we compare each RSW key (context path) against
  the current context path. This ensures that we can provide the switching
  options against both the course and any page shown under the course.
  
  @param context $context
  @return bool|int The role(int) if the user is in another role, false otherwise
docstring_tokens: Determine whether the user is assuming another role