Projet

Général

Profil

Paste
Télécharger (1 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / cas / includes / views / handlers / cas_handler_field_cas_name.inc @ a2baadd1

1
<?php
2

    
3
/**
4
 * @file
5
 * Field handler to provide a list of CAS user names.
6
 */
7

    
8
/**
9
 * Field handler to provide a list of CAS user names.
10
 */
11
class cas_handler_field_cas_name extends views_handler_field_prerender_list {
12
  function construct() {
13
    parent::construct();
14
    $this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid');
15
  }
16

    
17
  function query() {
18
    $this->add_additional_fields();
19
    $this->field_alias = $this->aliases['uid'];
20
  }
21

    
22
  function pre_render(&$values) {
23
    $uids = array();
24
    $this->items = array();
25

    
26
    foreach ($values as $result) {
27
      $uids[] = $this->get_value($result, NULL, TRUE);
28
    }
29

    
30
    if ($uids) {
31
      $result = db_query("SELECT aid, uid, cas_name FROM {cas_user} WHERE uid IN (:uids)",
32
        array(':uids' => $uids));
33
      foreach ($result as $cas_user) {
34
        $this->items[$cas_user->uid][$cas_user->aid]['cas_name'] = check_plain($cas_user->cas_name);
35
      }
36
    }
37
  }
38

    
39
  function render_item($count, $item) {
40
    return $item['cas_name'];
41
  }
42
}