You are here

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

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

Constructor Method.

Parameters

$sid:

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_test/LdapServerTest.class.php
Constructor Method.

File

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

Class

LdapServer
LDAP Server Class.

Code

public function __construct($sid) {
  if (!is_scalar($sid)) {
    return;
  }
  $this->detailed_watchdog_log = variable_get('ldap_help_watchdog_detail', 0);
  $server_record = FALSE;
  if (module_exists('ctools')) {
    ctools_include('export');
    $result = ctools_export_load_object('ldap_servers', 'names', [
      $sid,
    ]);
    if (isset($result[$sid])) {
      $server_record = new stdClass();
      foreach ($result[$sid] as $db_field_name => $value) {
        $server_record->{$db_field_name} = $value;
      }
    }
  }
  else {
    $select = db_select('ldap_servers')
      ->fields('ldap_servers')
      ->condition('ldap_servers.sid', $sid)
      ->execute();
    foreach ($select as $record) {
      if ($record->sid == $sid) {
        $server_record = $record;
      }
    }
  }
  $server_record_bindpw = NULL;
  if (!$server_record) {
    $this->inDatabase = FALSE;
  }
  else {
    $this->inDatabase = TRUE;
    $this->sid = $sid;
    $this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0);
    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};
      }
    }
    $server_record_bindpw = property_exists($server_record, 'bindpw') ? $server_record->bindpw : '';
  }
  $this
    ->initDerivedProperties($server_record_bindpw);
}