original_string: public function get_user_roles($userid) {
          $roles = array();
          $ras = get_user_roles($this->context, $userid, true, 'c.contextlevel DESC, r.sortorder ASC');
          $plugins = $this->get_enrolment_plugins(false);
          foreach ($ras as $ra) {
              if ($ra->contextid != $this->context->id) {
                  if (!array_key_exists($ra->roleid, $roles)) {
                      $roles[$ra->roleid] = null;
                  }
                  // higher ras, course always takes precedence
                  continue;
              }
              if (array_key_exists($ra->roleid, $roles) && $roles[$ra->roleid] === false) {
                  continue;
              }
              $changeable = true;
              if ($ra->component) {
                  $changeable = false;
                  if (strpos($ra->component, 'enrol_') === 0) {
                      $plugin = substr($ra->component, 6);
                      if (isset($plugins[$plugin])) {
                          $changeable = !$plugins[$plugin]->roles_protected();
                      }
                  }
              }
  
              $roles[$ra->roleid] = $changeable;
          }
          return $roles;
      }
code: public function get_user_roles($userid) {
          $roles = array();
          $ras = get_user_roles($this->context, $userid, true, 'c.contextlevel DESC, r.sortorder ASC');
          $plugins = $this->get_enrolment_plugins(false);
          foreach ($ras as $ra) {
              if ($ra->contextid != $this->context->id) {
                  if (!array_key_exists($ra->roleid, $roles)) {
                      $roles[$ra->roleid] = null;
                  }
                  // higher ras, course always takes precedence
                  continue;
              }
              if (array_key_exists($ra->roleid, $roles) && $roles[$ra->roleid] === false) {
                  continue;
              }
              $changeable = true;
              if ($ra->component) {
                  $changeable = false;
                  if (strpos($ra->component, 'enrol_') === 0) {
                      $plugin = substr($ra->component, 6);
                      if (isset($plugins[$plugin])) {
                          $changeable = !$plugins[$plugin]->roles_protected();
                      }
                  }
              }
  
              $roles[$ra->roleid] = $changeable;
          }
          return $roles;
      }
code_tokens: public function get_user_roles ( $ userid ) { $ roles = array ( ) ; $ ras = get_user_roles ( $ this -> context , $ userid , true , 'c.contextlevel DESC, r.sortorder ASC' ) ; $ plugins = $ this -> get_enrolment_plugins ( false ) ; foreach ( $ ras as $ ra ) { if ( $ ra -> contextid != $ this -> context -> id ) { if ( ! array_key_exists ( $ ra -> roleid , $ roles ) ) { $ roles [ $ ra -> roleid ] = null ; } // higher ras, course always takes precedence continue ; } if ( array_key_exists ( $ ra -> roleid , $ roles ) && $ roles [ $ ra -> roleid ] === false ) { continue ; } $ changeable = true ; if ( $ ra -> component ) { $ changeable = false ; if ( strpos ( $ ra -> component , 'enrol_' ) === 0 ) { $ plugin = substr ( $ ra -> component , 6 ) ; if ( isset ( $ plugins [ $ plugin ] ) ) { $ changeable = ! $ plugins [ $ plugin ] -> roles_protected ( ) ; } } } $ roles [ $ ra -> roleid ] = $ changeable ; } return $ roles ; }
docstring: Gets the roles assigned to this user that are applicable for this course.
  
  @param int $userid
  @return array
docstring_tokens: Gets the roles assigned to this user that are applicable for this course .