You are here

function LdapServer::__construct in Lightweight Directory Access Protocol (LDAP) 7

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

Constructor Method

1 call to LdapServer::__construct()
LdapServerAdmin::__construct in ldap_servers/LdapServerAdmin.class.php
Constructor Method
2 methods override LdapServer::__construct()
LdapServerAdmin::__construct in ldap_servers/LdapServerAdmin.class.php
Constructor Method
LdapServerTest::__construct in ldap_servers/tests/LdapServerTest.class.php
Constructor Method

File

ldap_servers/LdapServer.class.php, line 117
Defines server classes and related functions.

Class

LdapServer
LDAP Server Class

Code

function __construct($sid) {
  if (!is_scalar($sid)) {
    return;
  }
  $this->detailed_watchdog_log = variable_get('ldap_help_watchdog_detail', 0);
  $server_record = array();
  if (module_exists('ctools')) {
    ctools_include('export');
    $result = ctools_export_load_object('ldap_servers', 'names', array(
      $sid,
    ));
    if (isset($result[$sid])) {
      $server_record[$sid] = $result[$sid];
      foreach ($server_record[$sid] as $property => $value) {
        $this->{$property} = $value;
      }
    }
  }
  else {
    $select = db_select('ldap_servers')
      ->fields('ldap_servers')
      ->condition('ldap_servers.sid', $sid)
      ->execute();
    foreach ($select as $record) {
      $server_record[$record->sid] = $record;
    }
  }
  if (!isset($server_record[$sid])) {
    $this->inDatabase = FALSE;
    return;
  }
  $server_record = $server_record[$sid];
  if ($server_record) {
    $this->inDatabase = TRUE;
    $this->sid = $sid;
    $this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0);
  }
  else {

    // @todo throw error
  }
  foreach ($this
    ->field_to_properties_map() as $db_field_name => $property_name) {
    if (isset($server_record->{$db_field_name})) {
      $this->{$property_name} = $server_record->{$db_field_name};
    }
  }
  if (is_scalar($this->basedn)) {
    $this->basedn = unserialize($this->basedn);
  }
  if (isset($server_record->bindpw) && $server_record->bindpw != '') {
    $this->bindpw = $server_record->bindpw;
    $this->bindpw = ldap_servers_decrypt($this->bindpw);
  }
  $this->paginationEnabled = (bool) (ldap_servers_php_supports_pagination() && $this->searchPagination);
  $this->queriableWithoutUserCredentials = (bool) ($this->bind_method == LDAP_SERVERS_BIND_METHOD_SERVICE_ACCT || $this->bind_method == LDAP_SERVERS_BIND_METHOD_ANON_USER);
  $this->editPath = 'admin/config/people/ldap/servers/edit/' . $this->sid;
}