~spreadubuntu/spreadubuntu/devel-drupal6

« back to all changes in this revision

Viewing changes to modules/views/modules/node/views_handler_filter_history_user_timestamp.inc

  • Committer: ruben
  • Date: 2009-06-08 09:38:49 UTC
  • Revision ID: ruben@captive-20090608093849-s1qtsyctv2vwp1x1
SpreadUbuntu moving to Drupal6. Based on ubuntu-drupal theme and adding our modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
// $Id: views_handler_filter_history_user_timestamp.inc,v 1.1 2008/09/03 19:21:29 merlinofchaos Exp $
 
3
/**
 
4
 * Filter for new content
 
5
 */
 
6
class views_handler_filter_history_user_timestamp extends views_handler_filter {
 
7
  function can_expose() { return FALSE; }
 
8
  function query() {
 
9
    global $user;
 
10
    // This can only work if we're logged in.
 
11
    if (!$user || !$user->uid) {
 
12
      return;
 
13
    }
 
14
 
 
15
    // Hey, Drupal kills old history, so nodes that haven't been updated
 
16
    // since NODE_NEW_LIMIT are bzzzzzzzt outta here!
 
17
 
 
18
    $limit = time() - NODE_NEW_LIMIT;
 
19
 
 
20
    $this->ensure_my_table();
 
21
    $field = "$this->table_alias.$this->real_field";
 
22
    $node = $this->query->ensure_table('node');
 
23
 
 
24
    if (module_exists('comment')) {
 
25
      $ncs = $this->query->ensure_table('node_comment_statistics');
 
26
      $clause = ("OR $ncs.last_comment_timestamp > (***CURRENT_TIME*** - $limit)");
 
27
      $clause2 = "OR $field < $ncs.last_comment_timestamp";
 
28
    }
 
29
 
 
30
    // NULL means a history record doesn't exist. That's clearly new content.
 
31
    // Unless it's very very old content. Everything in the query is already
 
32
    // type safe cause none of it is coming from outside here.
 
33
    $this->query->add_where($this->options['group'], "($field IS NULL AND ($node.changed > (***CURRENT_TIME*** - $limit) $clause)) OR $field < $node.changed $clause2");
 
34
  }
 
35
 
 
36
  /**
 
37
   * Blank this, because there is nothing to say about this one.
 
38
   */
 
39
  function admin_summary() { }
 
40
}
 
41