original_string: public static function get_calendar_action_events_by_timesort($timesortfrom = 0, $timesortto = null,
                                                         $aftereventid = 0, $limitnum = 20, $limittononsuspendedevents = false,
                                                         $userid = null) {
          global $PAGE, $USER;
  
          $params = self::validate_parameters(
              self::get_calendar_action_events_by_timesort_parameters(),
              [
                  'timesortfrom' => $timesortfrom,
                  'timesortto' => $timesortto,
                  'aftereventid' => $aftereventid,
                  'limitnum' => $limitnum,
                  'limittononsuspendedevents' => $limittononsuspendedevents,
                  'userid' => $userid,
              ]
          );
          if ($params['userid']) {
              $user = \core_user::get_user($params['userid']);
          } else {
              $user = $USER;
          }
  
          $context = \context_user::instance($user->id);
          self::validate_context($context);
  
          if (empty($params['aftereventid'])) {
              $params['aftereventid'] = null;
          }
  
          $renderer = $PAGE->get_renderer('core_calendar');
          $events = local_api::get_action_events_by_timesort(
              $params['timesortfrom'],
              $params['timesortto'],
              $params['aftereventid'],
              $params['limitnum'],
              $params['limittononsuspendedevents'],
              $user
          );
  
          $exportercache = new events_related_objects_cache($events);
          $exporter = new events_exporter($events, ['cache' => $exportercache]);
  
          return $exporter->export($renderer);
      }
code: public static function get_calendar_action_events_by_timesort($timesortfrom = 0, $timesortto = null,
                                                         $aftereventid = 0, $limitnum = 20, $limittononsuspendedevents = false,
                                                         $userid = null) {
          global $PAGE, $USER;
  
          $params = self::validate_parameters(
              self::get_calendar_action_events_by_timesort_parameters(),
              [
                  'timesortfrom' => $timesortfrom,
                  'timesortto' => $timesortto,
                  'aftereventid' => $aftereventid,
                  'limitnum' => $limitnum,
                  'limittononsuspendedevents' => $limittononsuspendedevents,
                  'userid' => $userid,
              ]
          );
          if ($params['userid']) {
              $user = \core_user::get_user($params['userid']);
          } else {
              $user = $USER;
          }
  
          $context = \context_user::instance($user->id);
          self::validate_context($context);
  
          if (empty($params['aftereventid'])) {
              $params['aftereventid'] = null;
          }
  
          $renderer = $PAGE->get_renderer('core_calendar');
          $events = local_api::get_action_events_by_timesort(
              $params['timesortfrom'],
              $params['timesortto'],
              $params['aftereventid'],
              $params['limitnum'],
              $params['limittononsuspendedevents'],
              $user
          );
  
          $exportercache = new events_related_objects_cache($events);
          $exporter = new events_exporter($events, ['cache' => $exportercache]);
  
          return $exporter->export($renderer);
      }
code_tokens: public static function get_calendar_action_events_by_timesort ( $ timesortfrom = 0 , $ timesortto = null , $ aftereventid = 0 , $ limitnum = 20 , $ limittononsuspendedevents = false , $ userid = null ) { global $ PAGE , $ USER ; $ params = self :: validate_parameters ( self :: get_calendar_action_events_by_timesort_parameters ( ) , [ 'timesortfrom' => $ timesortfrom , 'timesortto' => $ timesortto , 'aftereventid' => $ aftereventid , 'limitnum' => $ limitnum , 'limittononsuspendedevents' => $ limittononsuspendedevents , 'userid' => $ userid , ] ) ; if ( $ params [ 'userid' ] ) { $ user = \ core_user :: get_user ( $ params [ 'userid' ] ) ; } else { $ user = $ USER ; } $ context = \ context_user :: instance ( $ user -> id ) ; self :: validate_context ( $ context ) ; if ( empty ( $ params [ 'aftereventid' ] ) ) { $ params [ 'aftereventid' ] = null ; } $ renderer = $ PAGE -> get_renderer ( 'core_calendar' ) ; $ events = local_api :: get_action_events_by_timesort ( $ params [ 'timesortfrom' ] , $ params [ 'timesortto' ] , $ params [ 'aftereventid' ] , $ params [ 'limitnum' ] , $ params [ 'limittononsuspendedevents' ] , $ user ) ; $ exportercache = new events_related_objects_cache ( $ events ) ; $ exporter = new events_exporter ( $ events , [ 'cache' => $ exportercache ] ) ; return $ exporter -> export ( $ renderer ) ; }
docstring: Get calendar action events based on the timesort value.
  
  @since Moodle 3.3
  @param null|int $timesortfrom Events after this time (inclusive)
  @param null|int $timesortto Events before this time (inclusive)
  @param null|int $aftereventid Get events with ids greater than this one
  @param int $limitnum Limit the number of results to this value
  @param null|int $userid The user id
  @return array
docstring_tokens: Get calendar action events based on the timesort value .