original_string: public static function get_relevant_users($query, $courseid) {
          global $CFG, $PAGE;
  
          // Validate parameter.
          self::validate_parameters(self::get_relevant_users_parameters(),
                  ['query' => $query, 'courseid' => $courseid]);
  
          // Validate the context (search page is always system context).
          $systemcontext = \context_system::instance();
          self::validate_context($systemcontext);
  
          // Get course object too.
          if ($courseid) {
              $coursecontext = \context_course::instance($courseid);
          } else {
              $coursecontext = null;
          }
  
          // If not logged in, can't see anyone when forceloginforprofiles is on.
          if (!empty($CFG->forceloginforprofiles)) {
              if (!isloggedin() || isguestuser()) {
                  return [];
              }
          }
  
          $users = \core_user::search($query, $coursecontext);
  
          $result = [];
          foreach ($users as $user) {
              // Get a standard exported user object.
              $fulldetails = (new user_summary_exporter($user))->export($PAGE->get_renderer('core'));
  
              // To avoid leaking private data to students, only include the specific information we
              // are going to display (and not the email, idnumber, etc).
              $result[] = (object)['id' => $fulldetails->id, 'fullname' => $fulldetails->fullname,
                      'profileimageurlsmall' => $fulldetails->profileimageurlsmall];
          }
          return $result;
      }
code: public static function get_relevant_users($query, $courseid) {
          global $CFG, $PAGE;
  
          // Validate parameter.
          self::validate_parameters(self::get_relevant_users_parameters(),
                  ['query' => $query, 'courseid' => $courseid]);
  
          // Validate the context (search page is always system context).
          $systemcontext = \context_system::instance();
          self::validate_context($systemcontext);
  
          // Get course object too.
          if ($courseid) {
              $coursecontext = \context_course::instance($courseid);
          } else {
              $coursecontext = null;
          }
  
          // If not logged in, can't see anyone when forceloginforprofiles is on.
          if (!empty($CFG->forceloginforprofiles)) {
              if (!isloggedin() || isguestuser()) {
                  return [];
              }
          }
  
          $users = \core_user::search($query, $coursecontext);
  
          $result = [];
          foreach ($users as $user) {
              // Get a standard exported user object.
              $fulldetails = (new user_summary_exporter($user))->export($PAGE->get_renderer('core'));
  
              // To avoid leaking private data to students, only include the specific information we
              // are going to display (and not the email, idnumber, etc).
              $result[] = (object)['id' => $fulldetails->id, 'fullname' => $fulldetails->fullname,
                      'profileimageurlsmall' => $fulldetails->profileimageurlsmall];
          }
          return $result;
      }
code_tokens: public static function get_relevant_users ( $ query , $ courseid ) { global $ CFG , $ PAGE ; // Validate parameter. self :: validate_parameters ( self :: get_relevant_users_parameters ( ) , [ 'query' => $ query , 'courseid' => $ courseid ] ) ; // Validate the context (search page is always system context). $ systemcontext = \ context_system :: instance ( ) ; self :: validate_context ( $ systemcontext ) ; // Get course object too. if ( $ courseid ) { $ coursecontext = \ context_course :: instance ( $ courseid ) ; } else { $ coursecontext = null ; } // If not logged in, can't see anyone when forceloginforprofiles is on. if ( ! empty ( $ CFG -> forceloginforprofiles ) ) { if ( ! isloggedin ( ) || isguestuser ( ) ) { return [ ] ; } } $ users = \ core_user :: search ( $ query , $ coursecontext ) ; $ result = [ ] ; foreach ( $ users as $ user ) { // Get a standard exported user object. $ fulldetails = ( new user_summary_exporter ( $ user ) ) -> export ( $ PAGE -> get_renderer ( 'core' ) ) ; // To avoid leaking private data to students, only include the specific information we // are going to display (and not the email, idnumber, etc). $ result [ ] = ( object ) [ 'id' => $ fulldetails -> id , 'fullname' => $ fulldetails -> fullname , 'profileimageurlsmall' => $ fulldetails -> profileimageurlsmall ] ; } return $ result ; }
docstring: Searches for users given a query, taking into account the current user's permissions and
  possibly a course to check within.
  
  @param string $query Query text
  @param int $courseid Course id or 0 if no restriction
  @return array Defined return structure
docstring_tokens: Searches for users given a query taking into account the current user s permissions and possibly a course to check within .