function birthdays_field_views_handler_filter::birthdays_add_where in Birthdays 7
Adds a where clause on a birtdhay value.
2 calls to birthdays_field_views_handler_filter::birthdays_add_where()
File
- views/
birthdays_field_views_handler_filter.inc, line 103 - The birthdays_field_views_handler_filter class.
Class
- birthdays_field_views_handler_filter
- Handler that allows to filter by birthday fields.
Code
function birthdays_add_where($field, $operator, $type, $value) {
// Get the absolute value.
if ($type == 'offset') {
$birthday = BirthdaysBirthday::fromOffset($value);
}
else {
$birthday = BirthdaysBirthday::fromString($value, TRUE);
if ($birthday
->isEmpty()) {
return;
}
}
// Add the WHERE expression.
$value = $birthday
->getYear() * 500 + $birthday
->getMonth() * 32 + $birthday
->getDay();
if ($birthday
->getYear()) {
$this->query
->add_where_expression($this->options['group'], "{$field}_year * 500 + {$field}_month * 32 + {$field}_day {$operator} {$value}");
}
else {
$this->query
->add_where_expression($this->options['group'], "{$field}_month * 32 + {$field}_day {$operator} {$value}");
}
}