Projet

Général

Profil

Paste
Télécharger (3,32 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ldap / ldap_views / handlers / ldap_views_handler_filter_attribute.inc @ bc175c27

1
<?php
2

    
3
/**
4
 * @file
5
 * Basic textfield filter to handle string filtering commands for a generic ldap attribute
6
 * Includes new criterias
7
 */
8

    
9
class ldap_views_handler_filter_attribute extends ldap_views_handler_filter {
10

    
11
  /**
12
   * Determine if a filter can be exposed.
13
   */
14
  function can_expose() {
15
    return TRUE;
16
  }
17

    
18
  function option_definition() {
19
    $options = parent::option_definition();
20
    $options['attribute_name'] = array('default' => '');
21
    return $options;
22
  }
23

    
24
  /**
25
   * This kind of construct makes it relatively easy for a child class
26
   * to add or remove functionality by overriding this function and
27
   * adding/removing items from this array.
28
   */
29
  function operators() {
30
    $operators = array(
31
      'exists' => array(
32
        'title' => t('Exists'),
33
        'method' => 'op_exists',
34
        'short' => t('exists'),
35
        'values' => 0,
36
      ),
37
      'not exists' => array(
38
        'title' => t('Not exists'),
39
        'method' => 'op_exists',
40
        'short' => t('not exists'),
41
        'values' => 0,
42
      ),
43
    );
44

    
45
    return parent::operators() + $operators;
46
  }
47
  /**
48
   * Provide a simple textfield for equality
49
   */
50
  function value_form(&$form, &$form_state) {
51
/*
52
    $current_display = $this->view->display[$this->view->current_display];
53
    $qid             = isset($current_display->display_options['query']['options']['qid']) ? $current_display->display_options['query']['options']['qid']
54
                                                                                           : $current_display->handler->default_display->display->display_options['query']['options']['qid'];
55
 */
56
    $ldap_data       = new LdapQuery(ldap_views_get_qid($this->view)); //ldap_data_load($qid);
57

    
58
    if (empty($ldap_data)) {
59
      $form['attribute_name'] = array(
60
        '#markup' => 'You must select a valid LDAP search (Advanced::Query settings)',
61
      );
62
      return;
63
    }
64

    
65
    $options         = array();
66
    foreach ($ldap_data->attributes as $attribute) {
67
      $options[$attribute] = $attribute;
68
    }
69

    
70
    if (empty($form_state['exposed'])) {
71
      $form['attribute_name'] = array(
72
        '#type' => 'select',
73
        '#title' => t('Attribute name'),
74
        '#description' => t('The attribute name from LDAP response'),
75
        '#options' => $options,
76
        '#default_value' => $this->options['attribute_name'],
77
        '#required' => TRUE,
78
      );
79
    }
80

    
81
    parent::value_form($form, $form_state);
82
  }
83
  function op_equal($field) {
84
    parent::op_equal($this->options['attribute_name']);
85
  }
86

    
87
  function op_contains($field) {
88
    parent::op_contains($this->options['attribute_name']);
89
  }
90

    
91
  function op_starts($field) {
92
    parent::op_starts($this->options['attribute_name']);
93
  }
94

    
95
  function op_not_starts($field) {
96
    parent::op_not_starts($this->options['attribute_name']);
97
  }
98

    
99
  function op_ends($field) {
100
    parent::op_ends($this->options['attribute_name']);
101
  }
102

    
103
  function op_not_ends($field) {
104
    parent::op_not_ends($this->options['attribute_name']);
105
  }
106

    
107
  function op_not($field) {
108
    parent::op_not($this->options['attribute_name']);
109
  }
110

    
111
  function op_greater_eq($field) {
112
    parent::op_greater_eq($this->options['attribute_name']);
113
  }
114

    
115
  function op_less_eq($field) {
116
    parent::op_less_eq($this->options['attribute_name']);
117
  }
118

    
119
  function op_exists($field) {
120
    parent::op_exists($this->options['attribute_name']);
121
  }
122

    
123
}