Commit 14d1e788 authored by Liam Morland's avatar Liam Morland
Browse files

Merge branch 'ISTWCMS-2798-404-events' into 7.x-2.x

parents 8ca99412 6624bda9
......@@ -253,6 +253,57 @@ function uw_ct_event_form_alter(&$form, &$form_state, $form_id) {
}
}
/**
* Implements hook_views_post_render().
*
* Return 404 if the date argument is +/- current date and there are
* no future/past ahead/behind it.
*/
function uw_ct_event_views_post_render(&$view, &$output, &$cache) {
if ($view->name == 'events_responsive' && $view->current_display == 'events_archive_page' && count($view->result) == 0) {
$first_arg = check_plain($view->args[0]);
if (isset($first_arg)) {
$one_year_future_time = strtotime('+1 years');
$one_year_past_time = strtotime('-1 years');
$first_arg_time = strtotime($first_arg);
if ($first_arg_time > strtotime('+1 day', $one_year_future_time)) {
// Get the furthest in the future event date.
// If it is greater than that, then throw 404.
// Add a day so we do not have to worry about timezones.
$future_date = format_date(strtotime('+1 days', $first_arg_time), 'custom', 'c');
$futureQuery = new EntityFieldQuery();
$future_results = $futureQuery->entityCondition('entity_type', 'node')
->propertyCondition('status', 1)
->fieldCondition('field_event_date', 'value2', $future_date, '>')
->execute();
if (empty($future_results)) {
drupal_not_found();
drupal_exit();
}
}
elseif ($first_arg_time < strtotime('-1 day', $one_year_past_time)) {
// Get the earliest previous event data.
// If it is less than that, then throw 404.
// Subtract a day so we do not have to worry about timezones.
$past_date = format_date(strtotime('-1 days', $first_arg_time), 'custom', 'c');
$pastQuery = new EntityFieldQuery();
$past_results = $pastQuery->entityCondition('entity_type', 'node')
->propertyCondition('status', 1)
->fieldCondition('field_event_date', 'value', $past_date, '<')
->execute();
if (empty($past_results)) {
drupal_not_found();
drupal_exit();
}
}
}
}
}
/**
* Implements hook_views_pre_render().
*
......
......@@ -1929,6 +1929,16 @@ echo uw_ct_web_page_filter_summary($data->field_body);
$handler->display->display_options['sorts']['nid']['table'] = 'node';
$handler->display->display_options['sorts']['nid']['field'] = 'nid';
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: Global: Null */
$handler->display->display_options['arguments']['null']['id'] = 'null';
$handler->display->display_options['arguments']['null']['table'] = 'views';
$handler->display->display_options['arguments']['null']['field'] = 'null';
$handler->display->display_options['arguments']['null']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['null']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['null']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['null']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['null']['specify_validation'] = TRUE;
$handler->display->display_options['arguments']['null']['must_not_be'] = TRUE;
$handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['filter_groups']['operator'] = 'OR';
$handler->display->display_options['filter_groups']['groups'] = array(
......@@ -2275,6 +2285,7 @@ echo uw_ct_web_page_filter_summary($data->field_body);
$handler->display->display_options['pager']['options']['items_per_page'] = '25';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['defaults']['empty'] = FALSE;
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
......@@ -2403,11 +2414,23 @@ echo uw_ct_web_page_filter_summary($data->field_body);
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = TRUE;
$handler->display->display_options['arguments']['date_argument']['specify_validation'] = TRUE;
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-1000:+1000';
$handler->display->display_options['arguments']['date_argument']['granularity_reset'] = 0;
$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
'field_data_field_event_date.field_event_date_value' => 'field_data_field_event_date.field_event_date_value',
);
/* Contextual filter: Global: Null */
$handler->display->display_options['arguments']['null']['id'] = 'null';
$handler->display->display_options['arguments']['null']['table'] = 'views';
$handler->display->display_options['arguments']['null']['field'] = 'null';
$handler->display->display_options['arguments']['null']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['null']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['null']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['null']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['null']['specify_validation'] = TRUE;
$handler->display->display_options['arguments']['null']['must_not_be'] = TRUE;
$handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['filter_groups']['operator'] = 'OR';
$handler->display->display_options['defaults']['filters'] = FALSE;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment