You are here

public static function LdapServerAdmin::getLdapServerObjects in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_servers/LdapServerAdmin.class.php \LdapServerAdmin::getLdapServerObjects()
  2. 7.2 ldap_servers/LdapServerAdmin.class.php \LdapServerAdmin::getLdapServerObjects()

Parameters

$type = 'all', 'enabled':

2 calls to LdapServerAdmin::getLdapServerObjects()
LdapServerAdmin::validate in ldap_servers/LdapServerAdmin.class.php
_ldap_servers_get_servers in ldap_servers/ldap_servers.inc
see ldap_servers_get_servers()

File

ldap_servers/LdapServerAdmin.class.php, line 20

Class

LdapServerAdmin

Code

public static function getLdapServerObjects($sid = NULL, $type = NULL, $class = 'LdapServer', $reset = FALSE) {
  $servers = array();
  if (module_exists('ctools')) {
    ctools_include('export');
    if ($reset) {
      ctools_export_load_object_reset('ldap_servers');
    }
    $select = ctools_export_load_object('ldap_servers', 'all');
  }
  else {
    try {
      $select = db_select('ldap_servers', 'ldap_servers')
        ->fields('ldap_servers')
        ->execute();
    } catch (Exception $e) {
      drupal_set_message(t('server index query failed. Message = %message, query= %query', array(
        '%message' => $e
          ->getMessage(),
        '%query' => $e->query_string,
      )), 'error');
      return array();
    }
  }
  foreach ($select as $result) {
    $servers[$result->sid] = $class == 'LdapServer' ? new LdapServer($result->sid) : new LdapServerAdmin($result->sid);
  }
  return $servers;
}