original_string: public static function get_conversation_messages(int $currentuserid, int $convid, int $limitfrom = 0, int $limitnum = 0,
                                                           bool $newest = false, int $timefrom = 0) {
          global $CFG, $PAGE, $USER;
  
          // Check if messaging is enabled.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
  
          $systemcontext = context_system::instance();
  
          $params = array(
              'currentuserid' => $currentuserid,
              'convid' => $convid,
              'limitfrom' => $limitfrom,
              'limitnum' => $limitnum,
              'newest' => $newest,
              'timefrom' => $timefrom,
          );
          $params = self::validate_parameters(self::get_conversation_messages_parameters(), $params);
          self::validate_context($systemcontext);
  
          if (($USER->id != $params['currentuserid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
              throw new moodle_exception('You do not have permission to perform this action.');
          }
  
          $sort = $newest ? 'timecreated DESC' : 'timecreated ASC';
  
          // We need to enforce a one second delay on messages to avoid race conditions of current
          // messages still being sent.
          //
          // There is a chance that we could request messages before the current time's
          // second has elapsed and while other messages are being sent in that same second. In which
          // case those messages will be lost.
          //
          // Instead we ignore the current time in the result set to ensure that second is allowed to finish.
          $timeto = empty($params['timefrom']) ? 0 : time() - 1;
  
          // No requesting messages from the current time, as stated above.
          if ($params['timefrom'] == time()) {
              $messages = [];
          } else {
              $messages = \core_message\api::get_conversation_messages(
                  $params['currentuserid'],
                  $params['convid'],
                  $params['limitfrom'],
                  $params['limitnum'],
                  $sort,
                  $params['timefrom'],
                  $timeto);
          }
  
          return $messages;
      }
code: public static function get_conversation_messages(int $currentuserid, int $convid, int $limitfrom = 0, int $limitnum = 0,
                                                           bool $newest = false, int $timefrom = 0) {
          global $CFG, $PAGE, $USER;
  
          // Check if messaging is enabled.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
  
          $systemcontext = context_system::instance();
  
          $params = array(
              'currentuserid' => $currentuserid,
              'convid' => $convid,
              'limitfrom' => $limitfrom,
              'limitnum' => $limitnum,
              'newest' => $newest,
              'timefrom' => $timefrom,
          );
          $params = self::validate_parameters(self::get_conversation_messages_parameters(), $params);
          self::validate_context($systemcontext);
  
          if (($USER->id != $params['currentuserid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
              throw new moodle_exception('You do not have permission to perform this action.');
          }
  
          $sort = $newest ? 'timecreated DESC' : 'timecreated ASC';
  
          // We need to enforce a one second delay on messages to avoid race conditions of current
          // messages still being sent.
          //
          // There is a chance that we could request messages before the current time's
          // second has elapsed and while other messages are being sent in that same second. In which
          // case those messages will be lost.
          //
          // Instead we ignore the current time in the result set to ensure that second is allowed to finish.
          $timeto = empty($params['timefrom']) ? 0 : time() - 1;
  
          // No requesting messages from the current time, as stated above.
          if ($params['timefrom'] == time()) {
              $messages = [];
          } else {
              $messages = \core_message\api::get_conversation_messages(
                  $params['currentuserid'],
                  $params['convid'],
                  $params['limitfrom'],
                  $params['limitnum'],
                  $sort,
                  $params['timefrom'],
                  $timeto);
          }
  
          return $messages;
      }
code_tokens: public static function get_conversation_messages ( int $ currentuserid , int $ convid , int $ limitfrom = 0 , int $ limitnum = 0 , bool $ newest = false , int $ timefrom = 0 ) { global $ CFG , $ PAGE , $ USER ; // Check if messaging is enabled. if ( empty ( $ CFG -> messaging ) ) { throw new moodle_exception ( 'disabled' , 'message' ) ; } $ systemcontext = context_system :: instance ( ) ; $ params = array ( 'currentuserid' => $ currentuserid , 'convid' => $ convid , 'limitfrom' => $ limitfrom , 'limitnum' => $ limitnum , 'newest' => $ newest , 'timefrom' => $ timefrom , ) ; $ params = self :: validate_parameters ( self :: get_conversation_messages_parameters ( ) , $ params ) ; self :: validate_context ( $ systemcontext ) ; if ( ( $ USER -> id != $ params [ 'currentuserid' ] ) && ! has_capability ( 'moodle/site:readallmessages' , $ systemcontext ) ) { throw new moodle_exception ( 'You do not have permission to perform this action.' ) ; } $ sort = $ newest ? 'timecreated DESC' : 'timecreated ASC' ; // We need to enforce a one second delay on messages to avoid race conditions of current // messages still being sent. // // There is a chance that we could request messages before the current time's // second has elapsed and while other messages are being sent in that same second. In which // case those messages will be lost. // // Instead we ignore the current time in the result set to ensure that second is allowed to finish. $ timeto = empty ( $ params [ 'timefrom' ] ) ? 0 : time ( ) - 1 ; // No requesting messages from the current time, as stated above. if ( $ params [ 'timefrom' ] == time ( ) ) { $ messages = [ ] ; } else { $ messages = \ core_message \ api :: get_conversation_messages ( $ params [ 'currentuserid' ] , $ params [ 'convid' ] , $ params [ 'limitfrom' ] , $ params [ 'limitnum' ] , $ sort , $ params [ 'timefrom' ] , $ timeto ) ; } return $ messages ; }
docstring: Get conversation messages.
  
  @param  int $currentuserid The current user's id.
  @param  int $convid The conversation id.
  @param  int $limitfrom Return a subset of records, starting at this point (optional).
  @param  int $limitnum Return a subset comprising this many records in total (optional, required if $limitfrom is set).
  @param  bool $newest True for getting first newest messages, false otherwise.
  @param  int  $timefrom The time from the conversation messages to get.
  @return stdClass The messages and members who have sent some of these messages.
  @throws moodle_exception
  @since 3.6
docstring_tokens: Get conversation messages .