5 * Definition of views_handler_filter_history_user_timestamp.
9 * Filter for new content.
11 * The handler is named history_user, because of compability reasons, the table
14 * @ingroup views_filter_handlers
16 class views_handler_filter_history_user_timestamp extends views_handler_filter {
17 // Don't display empty space where the operator would be.
18 var $no_operator = TRUE;
20 function expose_form(&$form, &$form_state) {
21 parent::expose_form($form, $form_state);
22 // @todo There are better ways of excluding required and multiple (object flags)
23 unset($form['expose']['required']);
24 unset($form['expose']['multiple']);
25 unset($form['expose']['remember']);
28 function value_form(&$form, &$form_state) {
29 // Only present a checkbox for the exposed filter itself. There's no way
30 // to tell the difference between not checked and the default value, so
31 // specifying the default value via the views UI is meaningless.
32 if (!empty($form_state['exposed'])) {
33 if (isset($this->options['expose']['label'])) {
34 $label = $this->options['expose']['label'];
37 $label = t('Has new content');
39 $form['value'] = array(
40 '#type' => 'checkbox',
42 '#default_value' => $this->value,
49 // This can only work if we're logged in.
50 if (!$user || !$user->uid) {
54 // Don't filter if we're exposed and the checkbox isn't selected.
55 if ((!empty($this->options['exposed'])) && empty($this->value)) {
59 // Hey, Drupal kills old history, so nodes that haven't been updated
60 // since NODE_NEW_LIMIT are bzzzzzzzt outta here!
62 $limit = REQUEST_TIME - NODE_NEW_LIMIT;
64 $this->ensure_my_table();
65 $field = "$this->table_alias.$this->real_field";
66 $node = $this->query->ensure_table('node', $this->relationship);
70 if (module_exists('comment')) {
71 $ncs = $this->query->ensure_table('node_comment_statistics', $this->relationship);
72 $clause = ("OR $ncs.last_comment_timestamp > (***CURRENT_TIME*** - $limit)");
73 $clause2 = "OR $field < $ncs.last_comment_timestamp";
76 // NULL means a history record doesn't exist. That's clearly new content.
77 // Unless it's very very old content. Everything in the query is already
78 // type safe cause none of it is coming from outside here.
79 $this->query->add_where_expression($this->options['group'], "($field IS NULL AND ($node.changed > (***CURRENT_TIME*** - $limit) $clause)) OR $field < $node.changed $clause2");
82 function admin_summary() {
83 if (!empty($this->options['exposed'])) {