You are here

function _datex_date_views_argument_handler_simple::date_forbid in Datex 7.3

Add a callback.

To determine if we have moved outside the valid date range for this argument.

1 call to _datex_date_views_argument_handler_simple::date_forbid()
_datex_date_views_argument_handler_simple::_query in ./datex.views.inc
Inject a test for valid date range before the regular query.

File

./datex.views.inc, line 896
Datex views integration.

Class

_datex_date_views_argument_handler_simple
Copied from date_views module. So we have no hard dependency on it.

Code

function date_forbid() {
  if (empty($this->argument)) {
    return TRUE;
  }
  $this->date_range = $this->date_handler
    ->arg_range($this->argument);
  $this->min_date = $this->date_range[0];
  $this->max_date = $this->date_range[1];
  $this->limit = date_range_years($this->options['year_range']);
  $group = !empty($this->options['date_group']) ? $this->options['date_group'] : 0;

  // See if we're outside the allowed date range for our argument.
  if (date_format($this->min_date, 'Y') < $this->limit[0] || date_format($this->max_date, 'Y') > $this->limit[1]) {
    $this->forbid = TRUE;
    $this->view->build_info['fail'] = TRUE;
    return TRUE;
  }
  return FALSE;
}