~spreadubuntu/spreadubuntu/devel-drupal6

« back to all changes in this revision

Viewing changes to modules/views/modules/comment/views_handler_argument_comment_user_uid.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_argument_comment_user_uid.inc,v 1.1 2008/09/03 19:21:29 merlinofchaos Exp $
 
3
 
 
4
/**
 
5
 * Argument handler to accept a user id to check for nodes that
 
6
 * user posted or commented on.
 
7
 */
 
8
class views_handler_argument_comment_user_uid extends views_handler_argument {
 
9
  function title() {
 
10
    if (!$this->argument) {
 
11
      $title = variable_get('anonymous', t('Anonymous'));
 
12
    }
 
13
    else {
 
14
      $title = db_result(db_query("SELECT u.name FROM {users} u WHERE u.uid = %d", $this->argument));
 
15
    }
 
16
    if (empty($title)) {
 
17
      return t('No user');
 
18
    }
 
19
 
 
20
    return check_plain($title);
 
21
  }
 
22
 
 
23
  function default_actions($which = NULL) {
 
24
    // Disallow summary views on this argument.
 
25
    if (!$which) {
 
26
      $actions = parent::default_actions();
 
27
      unset($actions['summary asc']);
 
28
      unset($actions['summary desc']);
 
29
      return $actions;
 
30
    }
 
31
 
 
32
    if ($which != 'summary asc' && $which != 'summary desc') {
 
33
      return parent::default_actions($which);
 
34
    }
 
35
  }
 
36
 
 
37
  function query() {
 
38
    $this->ensure_my_table();
 
39
    $this->query->add_where(0, "$this->table_alias.uid = %d OR (SELECT COUNT(*) FROM {comments} c WHERE c.uid = %d AND c.nid = $this->table_alias.nid)", $this->argument, $this->argument);
 
40
  }
 
41
}