• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

modules/comment/views_handler_field_ncs_last_comment_name.inc

00001 <?php
00002 
00008 class views_handler_field_ncs_last_comment_name extends views_handler_field {
00009   function query() {
00010     // last_comment_name only contains data if the user is anonymous. So we
00011     // have to join in a specially related user table.
00012     $this->ensure_my_table();
00013     // join 'users' to this table via vid
00014     $join = new views_join();
00015     $join->construct('users', $this->table_alias, 'last_comment_uid', 'uid');
00016     $join->extra = array(array('field' => 'uid', 'operator' => '!=', 'value' => '0'));
00017 
00018     // ncs_user alias so this can work with the sort handler, below.
00019 //    $this->user_table = $this->query->add_relationship(NULL, $join, 'users', $this->relationship);
00020     $this->user_table = $this->query->ensure_table('ncs_users', $this->relationship, $join);
00021 
00022     $this->field_alias = $this->query->add_field(NULL, "COALESCE($this->user_table.name, $this->table_alias.$this->field)", $this->table_alias . '_' . $this->field);
00023 
00024     $this->user_field = $this->query->add_field($this->user_table, 'name');
00025     $this->uid = $this->query->add_field($this->table_alias, 'last_comment_uid');
00026   }
00027 
00028   function option_definition() {
00029     $options = parent::option_definition();
00030 
00031     $options['link_to_user'] = array('default' => TRUE);
00032 
00033     return $options;
00034   }
00035 
00036   function render($values) {
00037     if (!empty($this->options['link_to_user'])) {
00038       $account = new stdClass();
00039       $account->name = $this->get_value($values);
00040       $account->uid = $values->{$this->uid};
00041       return theme('username', array(
00042         'account' => $account
00043       ));
00044     }
00045     else {
00046       return $this->sanitize_value($this->get_value($values));
00047     }
00048   }
00049 }

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1