You are here

function event_get_events_event in Event 5.2

Same name in this branch
  1. 5.2 event_database.mysql.inc \event_get_events_event()
  2. 5.2 event_database.mysqli.inc \event_get_events_event()
  3. 5.2 event_database.pgsql.inc \event_get_events_event()

Parameters

$first start date:

$last end date:

Whether to order the result set on the starting date.: Valid values: FALSE, 'DESC', 'ASC'

$rewrite_parameter optional array that is merged into the : fourth argument of db_rewrite_sql.

Return value

database resource

1 call to event_get_events_event()
event_get_events in ./event.module
Get events between two specified dates

File

./event_database.mysqli.inc, line 86

Code

function event_get_events_event($first, $last, $order, $rewrite_parameter = array()) {
  global $user;
  $shift = variable_get('date_default_timezone', 0);
  $before_first = event_implode_date(event_date_later(event_explode_date($first), -1));
  $after_last = event_implode_date(event_date_later(event_explode_date($last), 1));
  $query = "SELECT n.nid, n.uid, n.title, n.type, e.event_start, e.event_start AS event_start_orig, e.event_end, e.event_end AS event_end_orig, e.timezone, e.has_time, e.has_end_date, tz.offset AS offset, tz.offset_dst AS offset_dst, tz.dst_region, tz.is_dst, e.event_start - INTERVAL IF(tz.is_dst, tz.offset_dst, tz.offset) HOUR_SECOND AS event_start_utc, e.event_end - INTERVAL IF(tz.is_dst, tz.offset_dst, tz.offset) HOUR_SECOND AS event_end_utc, e.event_start - INTERVAL IF(tz.is_dst, tz.offset_dst, tz.offset) HOUR_SECOND + INTERVAL %d SECOND AS event_start_user, e.event_end - INTERVAL IF(tz.is_dst, tz.offset_dst, tz.offset) HOUR_SECOND + INTERVAL %d SECOND AS event_end_user, e.event_start - INTERVAL IF(tz.is_dst, tz.offset_dst, tz.offset) HOUR_SECOND + INTERVAL %d SECOND AS event_start_site, e.event_end - INTERVAL IF(tz.is_dst, tz.offset_dst, tz.offset) HOUR_SECOND + INTERVAL %d SECOND AS event_end_site, tz.name as timezone_name FROM {node} n INNER JOIN {event} e ON n.nid = e.nid INNER JOIN {event_timezones} tz ON tz.timezone = e.timezone WHERE n.status = 1 AND ((e.event_start >= '%s' AND e.event_start <= '%s') OR (e.event_end >= '%s' AND e.event_end <= '%s') OR (e.event_start <= '%s' AND e.event_end >= '%s')) GROUP BY n.nid HAVING (event_start >= '%s' AND event_start <= '%s') OR (event_end >= '%s' AND event_end <= '%s') OR (event_start <= '%s' AND event_end >= '%s')";
  switch ($order) {
    case 'DESC':
      $query .= " ORDER BY event_start DESC";
      break;
    case 'ASC':
      $query .= " ORDER BY event_start ASC";
      break;
  }
  $timezone = isset($user->timezone) ? $user->timezone : 0;
  return db_query(db_rewrite_sql($query, 'n', 'nid', array_merge(array(
    'event' => TRUE,
    'event_get_events' => TRUE,
    'event_get_events_event' => TRUE,
  ), $rewrite_parameter)), $timezone, $timezone, $shift, $shift, $before_first, $after_last, $before_first, $after_last, $before_first, $after_last, $first, $last, $first, $last, $first, $last);
}