You are here

function event_get_events_upcoming in Event 5.2

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

Parameters

$time current date:

$limit number of returned events:

$types The node types to get. If none given, all: event-enabled types will be retrieved that are configured to show up in all calendars.

$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_upcoming()
_event_block_upcoming in ./event.module
Helper function for upcoming events block. Can be called by other modules.

File

./event_database.pgsql.inc, line 118

Code

function event_get_events_upcoming($time, $types, $limit, $rewrite_parameter = array()) {
  $placeholders = implode(',', array_fill(0, count($types), "'%s'"));
  $query = "SELECT n.nid, n.title, n.type, n.status, n.changed, e.event_start, e.event_end, e.timezone, e.has_time, e.has_end_date, extract('day' from event_start - '%s')*24 + cast(substring(cast(event_start - '%s' as varchar) from ' (..):') as integer) || substring(cast(event_start - '%s' as varchar) from ' ..(:..:..)') as time_left, 0 AS days_left FROM {node} n INNER JOIN {event} e ON n.nid = e.nid WHERE n.status = 1 AND (((e.event_start <> e.event_end) AND ('%s' >= e.event_start AND '%s' < e.event_end)) OR ((e.event_start = e.event_end) AND ('%s' <= e.event_start + '%d seconds')) OR e.event_start >= '%s') AND n.type IN ({$placeholders}) ORDER BY event_start";
  return db_query_range(db_rewrite_sql($query, 'n', 'nid', array_merge(array(
    'event' => TRUE,
    'event_get_events' => TRUE,
    'event_get_events_upcoming' => TRUE,
    'event_types' => $types,
  ), $rewrite_parameter)), array_merge(array(
    $time,
    $time,
    $time,
    $time,
    $time,
    $time,
    $time,
    $time,
    60 * 60 * 2,
    $time,
  ), $types), 0, $limit);
}