name, l(t('edit'), 'admin/settings/ldapgroups/edit/'. $row->sid), l(t('reset'), 'admin/settings/ldapgroups/reset/'. $row->sid), ); } $header = array( t('LDAP Config'), array('data' => t('Operations'), 'colspan' => 2), ); return theme('table', $header, $rows); } /** * Implements the LDAP server edit page. * * @param $form_state * A form state array. * @param $op * An operatin - edit or reset. * @param $sid * A LDAP server ID. * * @return * The form structure. */ function ldapgroups_admin_edit(&$form_state, $op, $sid) { if (($op == 'reset') && $sid) { $form['sid'] = array( '#type' => 'value', '#value' => $sid, ); return confirm_form( $form, t('Are you sure you want to reset the groups mapping to defaults ?'), 'admin/settings/ldapgroups', t('This action cannot be undone.
'), t('Reset'), t('Cancel') ); } elseif ($op == 'edit' && $sid) { $edit = db_fetch_array(db_query("SELECT ldapgroups_in_dn, ldapgroups_in_dn_desc, ldapgroups_dn_attribute, ldapgroups_in_attr, ldapgroups_attr, ldapgroups_as_entries, ldapgroups_entries, ldapgroups_entries_attribute FROM {ldapauth} WHERE sid = %d", $sid)); $form['group_dn'] = array( '#type' => 'fieldset', '#title' => 'Group by DN', '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['group_dn']['ldapgroups_in_dn'] = array( '#type' => 'checkbox', '#title' => t('Group is specified in user\'s DN'), '#default_value' => $edit['ldapgroups_in_dn'], '#description' => 'Check this option if your users\' DNs look like cn=jdoe,ou=Group1,cn=example,cn=com and Group1 turns out to be the group you want.
' ); $form['group_dn']['ldapgroups_dn_attribute'] = array( '#type' => 'textfield', '#title' => t('Attribute of the DN which contains the group name'), '#default_value' => $edit['ldapgroups_dn_attribute'], '#size' => 50, '#maxlength' => 255, '#description' => t('The name of the attribute which contains the group name. In the example above, it would be ou, as the DN contains the string ou=Group1 and Group1 happens to be the desired group name.'), ); $form['group_attr'] = array( '#type' => 'fieldset', '#title' => 'Group by attribute', '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['group_attr']['ldapgroups_in_attr'] = array( '#type' => 'checkbox', '#title' => t('Groups are specified by LDAP attributes'), '#default_value' => $edit['ldapgroups_in_attr'], ); $form['group_attr']['ldapgroups_attr'] = array( '#type' => 'textarea', '#title' => t('Attribute names (one per line)'), '#default_value' => $edit['ldapgroups_attr'], '#cols' => 50, '#rows' => 6, '#description' => t('If the groups are stored in the user entries, along with the rest of their data, then enter here a list of attributes which may contain them.'), ); $form['group_entry'] = array( '#type' => 'fieldset', '#title' => 'Group by entry', '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['group_entry']['ldapgroups_as_entries'] = array( '#type' => 'checkbox', '#title' => t('Groups exist as LDAP entries where a multivalued attribute contains the members\' CNs'), '#default_value' => $edit['ldapgroups_as_entries'], ); $form['group_entry']['ldapgroups_entries'] = array( '#type' => 'textarea', '#title' => t('Nodes containing groups (one per line)'), '#default_value' => $edit['ldapgroups_entries'], '#cols' => 50, '#rows' => 6, '#description' => t('Enter here a list of nodes from where groups should be searched for. The module will look them up recursively from the given nodes.'), ); $form['group_entry']['ldapgroups_entries_attribute'] = array( '#type' => 'textfield', '#title' => t('Attribute holding group members'), '#default_value' => $edit['ldapgroups_entries_attribute'], '#size' => 50, '#maxlength' => 255, '#description' => t('Name of the multivalued attribute which holds the CNs of group members, for example: !attr', array('!attr' => theme('placeholder', LDAP_DEFAULT_GROUP_ENTRIES_ATTRIBUTE))), ); $form['sid'] = array( '#type' => 'hidden', '#value' => $sid, ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Update', ); return $form; } else { drupal_goto('admin/settings/ldapgroups'); } } /** * Submit hook for the settings form. */ function ldapgroups_admin_edit_submit($form, &$form_state) { $values = $form_state['values']; if ($values['op'] == t('Reset') && $values['confirm'] == 1) { // Settings reset. db_query("UPDATE {ldapauth} SET ldapgroups_in_dn = '0', ldapgroups_in_dn_desc = '0', ldapgroups_dn_attribute = '', ldapgroups_in_attr = '0', ldapgroups_attr = '', ldapgroups_as_entries = '0', ldapgroups_entries = '', ldapgroups_entries_attribute = '' WHERE sid = %d", $values['sid']); drupal_set_message(t('The configuration options have been reset to their default values.')); } else { // Update the ldapgroups configuration. db_query("UPDATE {ldapauth} SET ldapgroups_in_dn = %d, ldapgroups_in_dn_desc = %d, ldapgroups_dn_attribute = '%s', ldapgroups_in_attr = %d, ldapgroups_attr = '%s', ldapgroups_as_entries = %d, ldapgroups_entries = '%s', ldapgroups_entries_attribute = '%s' WHERE sid = %d", $values['ldapgroups_in_dn'], $values['ldapgroups_in_dn_desc'], $values['ldapgroups_dn_attribute'], $values['ldapgroups_in_attr'], $values['ldapgroups_attr'], $values['ldapgroups_as_entries'], $values['ldapgroups_entries'], $values['ldapgroups_entries_attribute'], $values['sid']); drupal_set_message(t('The configuration options have been saved.')); } $form_state['redirect'] = 'admin/settings/ldapgroups'; }