You are here

function ldap_authorization_admin_form in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_authorization/ldap_authorization.admin.inc \ldap_authorization_admin_form()
  2. 7 ldap_authorization/ldap_authorization.admin.inc \ldap_authorization_admin_form()

form for adding, updating, and deleting a single ldap authorization configuration

Parameters

form array $form:

form state array $form_state:

string $op (add, edit, or delete):

string $consumer_type e.g. drupal_roles, og_group, etc. Only needed for adds:

Return value

drupal form array

1 string reference to 'ldap_authorization_admin_form'
ldap_authorization_menu in ldap_authorization/ldap_authorization.module
Implements hook_menu().

File

ldap_authorization/ldap_authorization.admin.inc, line 48
Administrative page callbacks for the ldap_authorization module. Consumer configuration form and index.

Code

function ldap_authorization_admin_form($form, &$form_state, $consumer_type, $op = NULL) {
  ldap_servers_module_load_include('php', 'ldap_authorization', 'LdapAuthorizationConsumerConfAdmin.class');
  $consumer = ldap_authorization_get_consumer_object($consumer_type);
  if ($op == 'add' && is_object($consumer->consumerConf) && $consumer->consumerConf->inDatabase) {
    drupal_set_message(t('Only one configuration is allowed per consumer type.
      Configuration already exists for the cosumer type %consumer_type.  Please edit that configuration.', array(
      '%consumer_type' => $consumer_type,
    )), 'warning');
    drupal_goto(LDAP_SERVERS_MENU_BASE_PATH . '/authorization');
  }
  if (($op == 'edit' || $op == 'delete') && !is_object($consumer->consumerConf)) {
    drupal_set_message(t('Bad LDAP Authorization Configuration URL.'), 'error');
    drupal_goto(LDAP_SERVERS_MENU_BASE_PATH . '/authorization');
  }
  $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 authorization.'), 'error');
    drupal_goto('admin/config/people/ldap/authorization');
  }
  $new = $op == 'add';
  $consumer_conf_admin = new LdapAuthorizationConsumerConfAdmin($consumer, $new);
  foreach ($servers as $sid => $server) {
    $server_options[$sid] = $server->name;
  }
  return $consumer_conf_admin
    ->drupalForm($server_options, $op);
}