original_string: public static function get_user_contacts(int $userid, int $limitfrom = 0, int $limitnum = 0) {
          global $CFG, $USER;
  
          // Check if messaging is enabled.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
  
          $systemcontext = context_system::instance();
  
          $params = array(
              'userid' => $userid,
              'limitfrom' => $limitfrom,
              'limitnum' => $limitnum
          );
          $params = self::validate_parameters(self::get_user_contacts_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.');
          }
  
          return \core_message\api::get_user_contacts($params['userid'], $params['limitfrom'], $params['limitnum']);
      }
code: public static function get_user_contacts(int $userid, int $limitfrom = 0, int $limitnum = 0) {
          global $CFG, $USER;
  
          // Check if messaging is enabled.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
  
          $systemcontext = context_system::instance();
  
          $params = array(
              'userid' => $userid,
              'limitfrom' => $limitfrom,
              'limitnum' => $limitnum
          );
          $params = self::validate_parameters(self::get_user_contacts_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.');
          }
  
          return \core_message\api::get_user_contacts($params['userid'], $params['limitfrom'], $params['limitnum']);
      }
code_tokens: public static function get_user_contacts ( int $ userid , int $ limitfrom = 0 , int $ limitnum = 0 ) { global $ CFG , $ USER ; // Check if messaging is enabled. if ( empty ( $ CFG -> messaging ) ) { throw new moodle_exception ( 'disabled' , 'message' ) ; } $ systemcontext = context_system :: instance ( ) ; $ params = array ( 'userid' => $ userid , 'limitfrom' => $ limitfrom , 'limitnum' => $ limitnum ) ; $ params = self :: validate_parameters ( self :: get_user_contacts_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.' ) ; } return \ core_message \ api :: get_user_contacts ( $ params [ 'userid' ] , $ params [ 'limitfrom' ] , $ params [ 'limitnum' ] ) ; }
docstring: Get user contacts.
  
  @param int $userid The id of the user who we are viewing conversations for
  @param int $limitfrom
  @param int $limitnum
  @return array
  @throws moodle_exception
docstring_tokens: Get user contacts .