Projet

Général

Profil

Révision 32700c57

Ajouté par Assos Assos il y a environ 5 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ldap/ldap_query/ldap_query.admin.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * Defines functions for administrative interface for servers
6
 *
5
 * Defines functions for administrative interface for servers.
7 6
 */
8 7

  
9 8
/**
10
 * @return index of ldap queries
9
 * @return string
10
 *   Index of ldap queries
11 11
 */
12

  
13 12
function ldap_query_index() {
14 13

  
15 14
  return ldap_query_list(NULL, TRUE);
16 15

  
17 16
}
17

  
18 18
/**
19 19
 * LDAP queries list.
20 20
 *
......
22 22
 *   query id.  if empty list all queries
23 23
 * @param $actions
24 24
 *   True or False indicating if query edit, delete, enable, disable, etc links should show in table
25
 *
25 26
 * @return
26 27
 *   The HTML table with the servers list.
27 28
 */
28 29
function ldap_query_list($qid = NULL, $actions = FALSE) {
29 30

  
30 31
  $ldap_queries = ldap_query_get_queries($qid, 'all');
31
  $variables = array(
32
  $variables = [
32 33
    'ldap_queries' => $ldap_queries,
33 34
    'action' => TRUE,
34 35
    'type' => 'table',
35
    );
36
  ];
36 37

  
37 38
  $html = theme('ldap_query_list', $variables);
38 39

  
39 40
  return $html;
40 41
}
41 42

  
42

  
43 43
/**
44 44
 * Implements the LDAP query edit page.
45 45
 *
......
53 53
 * @return
54 54
 *   The form structure.
55 55
 */
56

  
57 56
function ldap_query_admin_form($form, &$form_state, $op = NULL, $qid = NULL) {
58 57
  ldap_servers_module_load_include('php', 'ldap_query', 'LdapQueryAdmin.class');
59 58
  $server = new LdapQueryAdmin($qid);
......
73 72
  foreach ($errors as $error_name => $error_text) {
74 73
    form_set_error($error_name, t($error_text));
75 74
  }
76
 // $warnings = $server->drupalFormWarnings($op, $form_state['values']);
77
  //foreach ($warnings as $warning_name => $warning_text) {
78
   // drupal_set_message($warning_text, 'warning');
79
  //}
80

  
81
  //$form_state['ldap_warnings'] = (boolean)(count($warnings) > 0);
82

  
83 75
}
84 76

  
85 77
/**
......
91 83
  $verb = ($op == 'edit') ? 'edited' : $op . 'ed';
92 84
  ldap_servers_module_load_include('php', 'ldap_query', 'LdapQueryAdmin.class');
93 85
  $query = new LdapQueryAdmin($form_state['values']['qid']);
94
  $query->drupalFormSubmit($op, $form_state['values']);  // add form data to object and save or create
86
  // Add form data to object and save or create.
87
  $query->drupalFormSubmit($op, $form_state['values']);
95 88

  
96 89
  if ($query->hasError() == FALSE) {
97
    drupal_set_message(t('LDAP Query %name !verb.', array('!verb' => $verb, '%name' => $query->name)), 'status');
90
    drupal_set_message(t('LDAP Query %name !verb.', ['!verb' => $verb, '%name' => $query->name]), 'status');
98 91
    ldap_query_cache_clear();
99
   // if ($form_state['ldap_warnings'] && $op != 'add') {
100
      // do nothing, but don't redirect away from form.
101
      // if there are warnings, want them to see form even if its been saved
102
   // }
103
   // else {
104
      drupal_goto(LDAP_QUERY_MENU_BASE_PATH . '/query');
105
   // }
92
    // If ($form_state['ldap_warnings'] && $op != 'add') {
93
    // do nothing, but don't redirect away from form.
94
    // if there are warnings, want them to see form even if its been saved
95
    // }
96
    // else {.
97
    drupal_goto(LDAP_QUERY_MENU_BASE_PATH . '/query');
98
    // }.
106 99
  }
107 100
  else {
108 101
    form_set_error($query->errorName(), $query->errorMsg());
......
124 117
 */
125 118
function ldap_query_admin_delete($form, &$form_state, $op = NULL, $qid = NULL) {
126 119

  
127

  
128 120
  if ($qid && ($ldap_query = ldap_query_get_queries($qid, 'all', TRUE))) {
129 121
    // array()
130

  
131
    $variables = array(
132
      'ldap_query' => $ldap_query, 'actions' => FALSE, 'type' => 'detail'
133
    );
122
    $variables = [
123
      'ldap_query' => $ldap_query,
124
      'actions' => FALSE,
125
      'type' => 'detail',
126
    ];
134 127
    $form['#prefix'] = '<div>' . theme('ldap_query', $variables) . '</div>';
135
    $form['qid'] = array(
128
    $form['qid'] = [
136 129
      '#type' => 'hidden',
137 130
      '#value' => $qid,
138
    );
139
    $form['name'] = array(
131
    ];
132
    $form['name'] = [
140 133
      '#type' => 'hidden',
141 134
      '#value' => $ldap_query->name,
142
    );
135
    ];
143 136
    return confirm_form(
144 137
      $form,
145 138
      'Delete Confirmation Form',
146 139
      LDAP_QUERY_MENU_BASE_PATH . '/query/list',
147
        '<p>' . t('Are you sure you want to delete the LDAP query named <em><strong>%name</strong></em> ?', array('%name' => $ldap_query->name)) . '</p><p>' .
140
        '<p>' . t('Are you sure you want to delete the LDAP query named <em><strong>%name</strong></em> ?', ['%name' => $ldap_query->name]) . '</p><p>' .
148 141
        t('This action cannot be undone.') . '</p>',
149 142
      t('Delete'),
150 143
      t('Cancel')
......
163 156
  $ldap_query = new LdapQueryAdmin($qid);
164 157
  if ($values['confirm'] && $qid) {
165 158
    if ($result = $ldap_query->delete($qid)) {
166
      $tokens = array('%name' => $ldap_query->name, '!qid' => $qid);
159
      $tokens = ['%name' => $ldap_query->name, '!qid' => $qid];
167 160
      drupal_set_message(t('LDAP Server %name (query id = !qid) has been deleted.', $tokens), 'status');
168 161
      watchdog('ldap_query', 'LDAP Query deleted: %name (qid = !qid) ', $tokens);
169 162
    }
......
178 171
  drupal_goto(LDAP_QUERY_MENU_BASE_PATH . '/query/list');
179 172
}
180 173

  
181

  
182 174
/**
183
 * Implements the LDAP query disable
175
 * Implements the LDAP query disable.
184 176
 *
185 177
 * @param $form_state
186 178
 *   A form state array.
......
190 182
 * @return
191 183
 *   The form structure.
192 184
 */
193

  
194

  
195 185
function ldap_query_admin_enable_disable($form, &$form_state, $action = NULL, $qid = NULL) {
196 186

  
197 187
  if ($ldap_query = ldap_query_get_queries($qid, 'all', TRUE)) {
198
    $variables = array(
199
      'ldap_query' => $ldap_query, 'actions' => FALSE, 'type' => 'detail'
200
    );
188
    $variables = [
189
      'ldap_query' => $ldap_query,
190
      'actions' => FALSE,
191
      'type' => 'detail',
192
    ];
201 193
    $form['#prefix'] = "<div>" . theme('ldap_query', $variables) . "</div>";
202 194

  
203
    $form['qid'] = array(
195
    $form['qid'] = [
204 196
      '#type' => 'hidden',
205 197
      '#value' => $qid,
206
    );
207
    $form['name'] = array(
198
    ];
199
    $form['name'] = [
208 200
      '#type' => 'hidden',
209 201
      '#value' => $ldap_query->name,
210
    );
211
    $form['action'] = array(
202
    ];
203
    $form['action'] = [
212 204
      '#type' => 'hidden',
213 205
      '#value' => $action,
214
    );
206
    ];
215 207
    return confirm_form(
216 208
      $form,
217
      t('Are you sure you want to') . t($action) . ' ' . t('the LDAP query named <em><strong>%name</strong></em>?', array('%name' => $ldap_query->name)),
209
      t('Are you sure you want to') . t($action) . ' ' . t('the LDAP query named <em><strong>%name</strong></em>?', ['%name' => $ldap_query->name]),
218 210
      LDAP_QUERY_MENU_BASE_PATH . '/query/list',
219 211
      t('<p></p>'),
220 212
      t($action),
......
238 230

  
239 231
    $ldap_query->status = $status;
240 232
    $ldap_query->save('edit');
241
    $tokens = array('%name' => $values['name'], '!qid' => $qid, '!action' => t($values['action']) . 'd');
233
    $tokens = ['%name' => $values['name'], '!qid' => $qid, '!action' => t($values['action']) . 'd'];
242 234
    drupal_set_message(t('LDAP Query Configuration %name (query id = !qid) has been !action.', $tokens));
243 235
    $message = t('LDAP Query !action: %name (qid = !qid) ', $tokens);
244 236
    watchdog('ldap_query', $message);
......
247 239

  
248 240
}
249 241

  
250

  
242
/**
243
 *
244
 */
251 245
function ldap_query_test($qid) {
252 246

  
253 247
  $ldap_query = ldap_query_get_queries($qid, 'all', TRUE);
254 248
  $results = $ldap_query->query();
255
  $display = theme('ldap_query_results', array('results' => $results, 'ldap_query' => $ldap_query, 'show_query' => TRUE));
249
  $display = theme('ldap_query_results', ['results' => $results, 'ldap_query' => $ldap_query, 'show_query' => TRUE]);
256 250

  
257 251
  return $display;
258 252

  
259

  
260 253
}

Formats disponibles : Unified diff