diff --git a/date_views/includes/date_views_argument_handler_simple.inc b/date_views/includes/date_views_argument_handler_simple.inc index faff05a..cb3d9a4 100644 --- a/date_views/includes/date_views_argument_handler_simple.inc +++ b/date_views/includes/date_views_argument_handler_simple.inc @@ -87,6 +87,7 @@ class date_views_argument_handler_simple extends views_handler_argument_date { $options['granularity'] = array('default' => 'month'); $options['default_argument_type'] = array('default' => 'date'); $options['add_delta'] = array('default' => ''); + $options['operation'] = array('default' => NULL); $options['use_fromto'] = array('default' => ''); $options['title_format'] = array('default' => ''); $options['title_format_custom'] = array('default' => ''); @@ -176,6 +177,29 @@ class date_views_argument_handler_simple extends views_handler_argument_date { '#access' => $access, ); + // Add the operation + $operation_options = array( + '<' => t('Is less than'), + '<=' => t('Is less than or equal to'), + '>=' => t('Is greater than or equal to'), + '>' => t('Is greater than'), + '=' => t('Is equal to'), + '!=' => t('Is not equal to'), + ); + $form['operation'] = array( + '#title' => t('Operation'), + '#type' => 'select', + '#options' => $operation_options, + '#description' => t('The comparison to perform to determine if the date field meets the condition. For multiple value date fields, all values will be checked to see if any meet the condition.'), + '#default_value' => isset($defaults['operation']) ? $defaults['operation'] : $this->options['operation'], + '#required' => TRUE, + '#access' => !empty($this->definition['field_name']), + '#states' => array( + 'visible' => array( + ':input[name="options[use_fromto]"]' => array('value' => 'no') + ), + ), + ); } function options_validate(&$form, &$form_state) { @@ -276,6 +300,12 @@ class date_views_argument_handler_simple extends views_handler_argument_date { $this->ensure_my_table(); $group = !empty($this->options['date_group']) ? $this->options['date_group'] : 0; + // Add in our operations option. + if (!empty($this->options['operation'])) { + $this->query->add_where($group, $this->table_alias .'.'. $this->real_field, $this->argument, $this->options['operation']); + return; + } + // If requested, add the delta field to the view so we can later find the value that matched our query. if (!empty($this->options['add_delta']) && (substr($this->real_field, -6) == '_value' || substr($this->real_field, -7) == '_value2')) { $this->query->add_field($this->table_alias, 'delta');