Projet

Général

Profil

Paste
Télécharger (2,5 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ldap / ldap_query / ldap_query.install @ bc175c27

1
<?php
2

    
3
/**
4
 * @file
5
 * Install, update and uninstall functions for the LDAP API module.
6
 */
7

    
8
/**
9
 * Implements hook_install().
10
 */
11
function ldap_query_install() {
12

    
13
}
14

    
15
/**
16
 * Implements hook_uninstall().
17
 */
18
function ldap_query_uninstall() {
19

    
20
}
21

    
22

    
23
/**
24
 * Implements hook_schema().
25
 */
26
/**
27
 * Implements hook_schema().
28
 */
29
function ldap_query_schema() {
30

    
31
  $schema['ldap_query'] = array(
32
    'export' => array(
33
      'key' => 'qid',
34
      'key name' => 'Query Name',
35
      'identifier' => 'qid',
36
      'primary key' => 'query_numeric_id',
37
      'api' => array(
38
        'owner' => 'ldap_query',
39
        'api' => 'ldap_query',
40
        'minimum_version' => 1,
41
        'current_version' => 1,
42
      ),
43
    ),
44

    
45
    'description' => "LDAP Query Data leveraged by other LDAP Modules",
46
    'primary key' => array('query_numeric_id'),
47
    'foreign keys' => array(
48
      'sid' => array(
49
        'table' => 'ldap_servers',
50
        'columns' => array('sid' => 'sid'),
51
      ),
52
    ),
53
  );
54
  module_load_include('module', 'ldap_servers');
55
  ldap_servers_module_load_include('php', 'ldap_query', 'LdapQuery.class');
56
  $fields = LdapQuery::fields();
57
  foreach ($fields as $field_id => $field) {
58
    if (isset($field['schema'])) {
59
      $schema['ldap_query']['fields'][$field_id] = $field['schema'];
60
    }
61
  }
62

    
63
  return $schema;
64
}
65

    
66
/**
67
 * Add scope field to ldap_query table.
68
 */
69
function ldap_query_update_7100() {
70
  module_load_include('inc', 'ldap_servers', 'ldap_servers.functions');
71
  ldap_servers_module_load_include('module', 'ldap_servers', 'ldap_servers'); // get LDAP_SCOPE_SUBTREE constant
72
  // make sure 'create_consumers' field is there for old 7.x-1.x-dev versions
73
  if (!db_field_exists('ldap_query', 'scope')) {
74
    db_add_field('ldap_query', 'scope', array(
75
      'type' => 'int',
76
      'size' => 'small',
77
      'not null' => FALSE,
78
      'default' => LDAP_SCOPE_SUBTREE,
79
    ));
80
    return t('"scope" field added to ldap_query table');
81
  }
82
  else {
83
    return t('No database changes made.');
84
  }
85

    
86
}
87

    
88
/**
89
 * Make filter field type 'text' for longer filters
90
 */
91
function ldap_query_update_7101() {
92
  db_change_field('ldap_query', 'filter', 'filter', array(
93
    'type' => 'text',
94
    'not null' => FALSE,
95
  ));
96

    
97
  return t('ldap_query table field "filter" changed to type "text"');
98
}
99

    
100

    
101
/**
102
 * make ldap_query.scope field small int instead of tiny int for ctools bug
103
 */
104
function ldap_query_update_7102() {
105

    
106
  db_change_field('ldap_query', 'scope', 'scope', array(
107
    'type' => 'int',
108
    'size' => 'small',
109
    'not null' => TRUE,
110
    'default' => 0,
111
  ));
112

    
113
}