function event_get_events_user in Event 5.2
Same name in this branch
- 5.2 event_database.mysql.inc \event_get_events_user()
- 5.2 event_database.mysqli.inc \event_get_events_user()
- 5.2 event_database.pgsql.inc \event_get_events_user()
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_user()
- event_get_events in ./
event.module - Get events between two specified dates
File
- ./
event_database.pgsql.inc, line 25
Code
function event_get_events_user($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.title, n.type, e.event_start AS event_start_orig, e.event_end AS event_end_orig, e.timezone, e.has_time, e.has_end_date, tz.offset, tz.offset_dst ELSEtz.dst_region, tz.is_dst, e.event_start - CASE WHEN tz.is_dst = 1 THEN tz.offset_dst ELSE tz.offset END AS event_start_utc, e.event_end - CASE WHEN tz.is_dst = 1 THEN tz.offset_dst ELSE tz.offset END AS event_end_utc, e.event_start - CASE WHEN tz.is_dst = 1 THEN tz.offset_dst ELSE tz.offset END + INTERVAL '%d seconds' AS event_start, e.event_end - CASE WHEN tz.is_dst = 1 THEN tz.offset_dst ELSE tz.offset END + INTERVAL '%d seconds' AS event_end, e.event_start - CASE WHEN tz.is_dst = 1 THEN tz.offset_dst ELSE tz.offset END + INTERVAL '%d seconds' AS event_start_user, e.event_end - CASE WHEN tz.is_dst = 1 THEN tz.offset_dst ELSE tz.offset END + INTERVAL '%d seconds' AS event_end_user, e.event_start - CASE WHEN tz.is_dst = 1 THEN tz.offset_dst ELSE tz.offset END + INTERVAL '%d seconds' AS event_start_site, e.event_end - CASE WHEN tz.is_dst = 1 THEN tz.offset_dst ELSE tz.offset END + INTERVAL '%d seconds' 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_user' => TRUE,
), $rewrite_parameter)), $timezone, $timezone, $timezone, $timezone, $shift, $shift, $before_first, $after_last, $before_first, $after_last, $before_first, $after_last, $first, $last, $first, $last, $first, $last);
}