--- ldapgroups.module 2006-12-21 11:10:17.526044866 -0500 +++ ldapgroups-5.0rc1.module 2006-12-21 11:14:26.726510378 -0500 @@ -21,15 +21,18 @@ * 1. Drupal hooks * *********************************/ + /** + * Implementation of hook_help() + */ + function ldapgroups_help($section) { $output = ''; switch ($section) { case 'admin/modules#ldapgroups': - $output = 'ldapgroups'; - break; - case 'admin/modules#description': + $output = t('LDAP Groups'); case 'admin/help#ldapgroups': + case 'user/help#ldapgroups': $output = t('Maps LDAP groups to Drupal roles for users authenticated via ldapauth module.'); break; } @@ -37,6 +40,62 @@ return $output; } +/** + * Implementation of hook_menu() + */ + +function ldapgroups_menu($may_cache) { + $items = array(); + if ($may_cache) { + $items[] = array( 'path' => 'admin/settings/ldapgroups', + 'title' => t('LDAP Groups'), + 'description' => t('Configure LDAP Groups Settings'), + 'callback' => 'drupal_get_form', + 'callback arguments' => 'ldapgroups_admin', + 'type' => MENU_NORMAL_ITEM, + 'access' => user_access('administer site configuration') + ); + } + + return $items; +} + +function ldapgroups_admin() { + // Reminding admins about conf.php + $form['server-settings']['ldap-note'] = array( '#value' => t('

PLEASE NOTE: advanced configuration for this module can be set by editing the module\'s config file, located at modules/ldap_integration/ldapgroups.conf.php in your Drupal install.

')); + + $form['server-settings']['ldap_groups_in_dn'] = array( '#type' => 'checkbox', '#title' => t('Group is specified in user\'s DN'), '#default_value' => variable_get('ldap_groups_in_dn', false), '#prefix' => '
', '#suffix' => ''); + + $form['server-settings']['ldap_groups_in_dn_desc'] = array( '#value' => '

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['server-settings']['ldap_group_dn_pattern'] = array( '#type' => 'textfield', '#title' => t('Attribute of the DN which contains the group name'), '#default_value' => variable_get('ldap_group_dn_attribute', LDAP_DEFAULT_GROUP_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.'), '#suffix' => '
'); + + $form['server-settings']['ldap_groups_in_attr'] = array( '#type' => 'checkbox', '#title' => t('Groups are specified by LDAP attributes'), '#default_value' => variable_get('ldap_groups_in_attr', false), '#prefix' => '
', '#suffix' => ''); + + $form['server-settings']['ldap_group_attr'] = array( '#type' => 'textarea', '#title' => t('Attribute names (one per line)'), '#default_value' => variable_get('ldap_group_attr', LDAP_DEFAULT_GROUP_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.'), '#suffix' => '
'); + + $form['server-settings']['ldap_groups_as_entries'] = array( '#type' => 'checkbox', '#title' => t('Groups exist as LDAP entries where a multivalued attribute contains the members\' CNs'), '#default_value' => variable_get('ldap_groups_as_entries', false), '#prefix' => '
', '#suffix' => ''); + + $form['server-settings']['ldap_group_entries'] = array( '#type' => 'textarea', '#title' => t('Nodes containing groups (one per line)'), '#default_value' => variable_get('ldap_group_entries', LDAP_DEFAULT_GROUP_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['server-settings']['ldap_group_entries_attribute'] = array( '#type' => 'textfield', '#title' => t('Attribute holding group members'), '#default_value' => variable_get('ldap_group_entries_attribute', LDAP_DEFAULT_GROUP_ENTRIES_ATTRIBUTE), '#size' => 50, '#maxlength' => 255, '#description' => t('Name of the multivalued attribute which holds the CNs of group members, for example: ' . LDAP_DEFAULT_GROUP_ENTRIES_ATTRIBUTE . '.'),); + + $options_grouproles = array( + LDAP_GROUP_IN_DN => array('choice' => t('Group is specified in user\'s DN'), 'extended' => $option_grouproles_1), + LDAP_GROUP_IN_ATTR => array('choice' => t('Groups are specified by LDAP attributes'), 'extended' => $option_grouproles_2), + LDAP_GROUP_AS_ENTRIES => array('choice' => t('Groups exist as LDAP entries where a multivalued attribute contains the members\' CNs'), 'extended' => $option_grouproles_3)); + + return system_settings_form($form); + +} + + +/** + * 4.7.3 format - deprecated + */ + +/* + function ldapgroups_settings() { // Reminding admins about conf.php $form['ldap-note'] = array( @@ -117,6 +176,8 @@ return $form; } +*/ + function ldapgroups_user($op, &$edit, &$user, $category = NULL) { switch($op) { case 'login':