original_string: public static function message_search_users($userid, $search, $limitfrom = 0, $limitnum = 0) {
          global $USER;
  
          $systemcontext = context_system::instance();
  
          $params = array(
              'userid' => $userid,
              'search' => $search,
              'limitfrom' => $limitfrom,
              'limitnum' => $limitnum
          );
          $params = self::validate_parameters(self::message_search_users_parameters(), $params);
          self::validate_context($systemcontext);
  
          if (($USER->id != $params['userid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
              throw new moodle_exception('You do not have permission to perform this action.');
          }
  
          list($contacts, $noncontacts) = \core_message\api::message_search_users(
              $params['userid'],
              $params['search'],
              $params['limitfrom'],
              $params['limitnum']);
  
          return array('contacts' => $contacts, 'noncontacts' => $noncontacts);
      }
code: public static function message_search_users($userid, $search, $limitfrom = 0, $limitnum = 0) {
          global $USER;
  
          $systemcontext = context_system::instance();
  
          $params = array(
              'userid' => $userid,
              'search' => $search,
              'limitfrom' => $limitfrom,
              'limitnum' => $limitnum
          );
          $params = self::validate_parameters(self::message_search_users_parameters(), $params);
          self::validate_context($systemcontext);
  
          if (($USER->id != $params['userid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
              throw new moodle_exception('You do not have permission to perform this action.');
          }
  
          list($contacts, $noncontacts) = \core_message\api::message_search_users(
              $params['userid'],
              $params['search'],
              $params['limitfrom'],
              $params['limitnum']);
  
          return array('contacts' => $contacts, 'noncontacts' => $noncontacts);
      }
code_tokens: public static function message_search_users ( $ userid , $ search , $ limitfrom = 0 , $ limitnum = 0 ) { global $ USER ; $ systemcontext = context_system :: instance ( ) ; $ params = array ( 'userid' => $ userid , 'search' => $ search , 'limitfrom' => $ limitfrom , 'limitnum' => $ limitnum ) ; $ params = self :: validate_parameters ( self :: message_search_users_parameters ( ) , $ params ) ; self :: validate_context ( $ systemcontext ) ; if ( ( $ USER -> id != $ params [ 'userid' ] ) && ! has_capability ( 'moodle/site:readallmessages' , $ systemcontext ) ) { throw new moodle_exception ( 'You do not have permission to perform this action.' ) ; } list ( $ contacts , $ noncontacts ) = \ core_message \ api :: message_search_users ( $ params [ 'userid' ] , $ params [ 'search' ] , $ params [ 'limitfrom' ] , $ params [ 'limitnum' ] ) ; return array ( 'contacts' => $ contacts , 'noncontacts' => $ noncontacts ) ; }
docstring: Get search users results.
  
  @param int $userid The id of the user who is performing the search
  @param string $search The string being searched
  @param int $limitfrom
  @param int $limitnum
  @return array
  @throws moodle_exception
  @since 3.6
docstring_tokens: Get search users results .