You are here

public function SchedulerHandlerFieldSchedulerCountdown::query in Scheduler 7

Add the timestamp_field into the SQL query.

It is calculated as publish_on - REQUEST_TIME so the result is the number of seconds from now until publishing. If publish_on is in the past then NULL is returned.

Overrides views_handler_field::query

File

./scheduler_handler_field_scheduler_countdown.inc, line 34
Display scheduled dates in 'countdown' format for use in Views.

Class

SchedulerHandlerFieldSchedulerCountdown
Field handler to display a countdown until a scheduled action.

Code

public function query() {
  $this
    ->ensure_my_table();
  $this->node_table = $this->query
    ->ensure_table('node', $this->relationship);
  $time_field = $this->definition['timestamp_field'];
  $this->field_alias = $this->query
    ->add_field(NULL, 'CASE WHEN (' . $time_field . ' > ' . REQUEST_TIME . ') THEN (' . $time_field . ' - ' . REQUEST_TIME . ') ELSE NULL END', $this->table_alias . '_' . $this->field);
}