Projet

Général

Profil

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

root / drupal7 / sites / all / modules / ldap / ldap_query / ldap_query.install @ 91af538d

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
 * Implements hook_schema().
24
 */
25

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

    
31
  $schema['ldap_query'] = [
32
    'export' => [
33
      'key' => 'qid',
34
      'key name' => 'Query Name',
35
      'identifier' => 'qid',
36
      'primary key' => 'query_numeric_id',
37
      'api' => [
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' => ['query_numeric_id'],
47
    'foreign keys' => [
48
      'sid' => [
49
        'table' => 'ldap_servers',
50
        'columns' => ['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
  // Get LDAP_SCOPE_SUBTREE constant.
72
  ldap_servers_module_load_include('module', 'ldap_servers', 'ldap_servers');
73
  // Make sure 'create_consumers' field is there for old 7.x-1.x-dev versions.
74
  if (!db_field_exists('ldap_query', 'scope')) {
75
    db_add_field('ldap_query', 'scope', [
76
      'type' => 'int',
77
      'size' => 'small',
78
      'not null' => FALSE,
79
      'default' => LDAP_SCOPE_SUBTREE,
80
    ]);
81
    return t('"scope" field added to ldap_query table');
82
  }
83
  else {
84
    return t('No database changes made.');
85
  }
86

    
87
}
88

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

    
98
  return t('ldap_query table field "filter" changed to type "text"');
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', [
107
    'type' => 'int',
108
    'size' => 'small',
109
    'not null' => TRUE,
110
    'default' => 0,
111
  ]);
112

    
113
}