You are here

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

Same name and namespace in other branches
  1. 7.2 ldap_servers/LdapServer.class.php \LdapServer::__construct()
  2. 7 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_test/LdapServerTest.class.php
Constructor Method

File

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

Class

LdapServer
LDAP Server Class

Code

function __construct($sid) {
  if (!is_scalar($sid)) {
    return;
  }
  $this->detailed_watchdog_log = config('ldap_help.settings')
    ->get('watchdog_detail');
  $server_record = FALSE;
  if (module_exists('ctools')) {
    ctools_include('export');
    $result = ctools_export_load_object('ldap_servers', 'names', array(
      $sid,
    ));
    if (isset($result[$sid])) {
      $server_record = new stdClass();
      foreach ($result[$sid] as $db_field_name => $value) {
        $server_record->{$db_field_name} = $value;
      }
    }

    //debug('ctools record'); debug($server_record);
  }
  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 = config('ldap_help.settings')
      ->get('watchdog_detail');
    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);
}