You are here

function _ldap_servers_get_servers in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_servers/ldap_servers.module \_ldap_servers_get_servers()
  2. 7.2 ldap_servers/ldap_servers.module \_ldap_servers_get_servers()

see ldap_servers_get_servers()

1 call to _ldap_servers_get_servers()
ldap_servers_get_servers in ldap_servers/ldap_servers.module
return ldap server conf objects

File

ldap_servers/ldap_servers.inc, line 30
collection of functions that don't belong in server object

Code

function _ldap_servers_get_servers($sid, $type, $flatten, $reset) {

  // dpm('_ldap_servers_get_servers params'); dpm(array($sid, $type, $flatten, $reset));
  ldap_server_module_load_include('php', 'ldap_servers', 'LdapServerAdmin.class');
  static $servers;
  $type = $type ? $type : 'all';
  if ($reset) {
    $servers = array();
  }
  if (!isset($servers['all'])) {
    $servers['all'] = LdapServerAdmin::getLdapServerObjects('all', NULL, 'LdapServer', $reset);
  }
  if (!isset($servers['enabled'])) {
    $servers['enabled'] = array();
    foreach ($servers['all'] as $_sid => $ldap_server) {
      if ($ldap_server->status == 1) {
        $servers['enabled'][$_sid] = $ldap_server;
      }
    }
  }
  if ($sid) {
    if (!isset($servers[$type][$sid])) {
      return FALSE;
    }
    return $flatten ? $servers[$type][$sid] : array(
      $sid => $servers[$type][$sid],
    );
  }
  if (isset($servers[$type])) {
    return $servers[$type];
  }
}