00001 <?php
00002
00009 class views_handler_argument_comment_user_uid extends views_handler_argument {
00010 function title() {
00011 if (!$this->argument) {
00012 $title = variable_get('anonymous', t('Anonymous'));
00013 }
00014 else {
00015 $title = db_query('SELECT u.name FROM {users} u WHERE u.uid = :uid', array(':uid' => $this->argument))->fetchField();
00016 }
00017 if (empty($title)) {
00018 return t('No user');
00019 }
00020
00021 return check_plain($title);
00022 }
00023
00024 function default_actions($which = NULL) {
00025
00026 if (!$which) {
00027 $actions = parent::default_actions();
00028 unset($actions['summary asc']);
00029 unset($actions['summary desc']);
00030 return $actions;
00031 }
00032
00033 if ($which != 'summary asc' && $which != 'summary desc') {
00034 return parent::default_actions($which);
00035 }
00036 }
00037
00038 function query($group_by = FALSE) {
00039 $this->ensure_my_table();
00040
00041 $subselect = db_select('comment', 'c');
00042 $subselect->addField('c', 'cid');
00043 $subselect->condition('c.uid', $this->argument);
00044 $subselect->where("c.nid = $this->table_alias.nid");
00045
00046 $condition = db_or()
00047 ->condition("$this->table_alias.uid", $this->argument, '=')
00048 ->exists($subselect);
00049
00050 $this->query->add_where(0, $condition);
00051 }
00052
00053 function get_sort_name() {
00054 return t('Numerical', array(), array('context' => 'Sort order'));
00055 }
00056 }