public function LdapQueryAdmin::drupalForm in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_query/LdapQueryAdmin.class.php \LdapQueryAdmin::drupalForm()
- 7 ldap_query/LdapQueryAdmin.class.php \LdapQueryAdmin::drupalForm()
File
- ldap_query/
LdapQueryAdmin.class.php, line 187
Class
Code
public function drupalForm($op) {
$form['#prefix'] = t('<p>Setup an LDAP query to be used by other modules
such as LDAP Feeds.</p>');
$form['basic'] = [
'#type' => 'fieldset',
'#title' => t('Basic LDAP Query Settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
];
$form['query'] = [
'#type' => 'fieldset',
'#title' => t('Query'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
];
$form['query_advanced'] = [
'#type' => 'fieldset',
'#title' => t('Advanced Query Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
];
foreach ($this
->fields() as $field_id => $field) {
$field_group = isset($field['form']['field_group']) ? $field['form']['field_group'] : FALSE;
if (isset($field['form'])) {
$form_item = $field['form'];
$form_item['#default_value'] = $this->{$field['property_name']};
if ($field_group) {
$form[$field_group][$field_id] = $form_item;
// Sirrelevant to form api.
unset($form[$field_group][$field_id]['field_group']);
}
else {
$form[$field_id] = $form_item;
}
}
}
$form['basic']['qid']['#disabled'] = $op == 'edit';
$servers = ldap_servers_get_servers(NULL, 'enabled');
if (count($servers) == 0) {
drupal_set_message(t('No ldap servers configured. Please configure a server before an ldap query.'), 'error');
}
foreach ($servers as $sid => $server) {
$server_options[$sid] = $server->name;
}
$form['basic']['sid']['#options'] = $server_options;
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Save Query'),
];
$action = $op == 'add' ? 'Add' : 'Update';
$form['submit'] = [
'#type' => 'submit',
'#value' => $action,
'#weight' => 100,
];
return $form;
}