You are here

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

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

Constructor Method

1 call to LdapQuery::__construct()
LdapQueryAdmin::__construct in ldap_query/LdapQueryAdmin.class.php
Constructor Method
1 method overrides LdapQuery::__construct()
LdapQueryAdmin::__construct in ldap_query/LdapQueryAdmin.class.php
Constructor Method

File

ldap_query/LdapQuery.class.php, line 46
Defines server classes and related functions.

Class

LdapQuery
LDAP Server Class

Code

function __construct($qid) {
  if (!is_scalar($qid)) {
    return;
  }
  $query_records = array();
  if (module_exists('ctools')) {
    ctools_include('export');
    $result = ctools_export_load_object('ldap_query', 'names', array(
      $qid,
    ));
    if (isset($result[$qid])) {
      $query_record = $result[$qid];
      foreach ($query_record as $property_name => $value) {
        $this->{$property_name} = $value;
      }
    }
  }
  else {
    $select = db_select('ldap_query')
      ->fields('ldap_query')
      ->condition('ldap_query.qid', $qid)
      ->execute();
    foreach ($select as $record) {
      $query_records[$record->qid] = $record;
    }
    if (!isset($query_records[$qid])) {
      $this->inDatabase = FALSE;
      return;
    }
    $query_record = $query_records[$qid];
    foreach ($this
      ->fields() as $field_id => $field) {
      if (isset($query_record->{$field_id})) {
        $this->{$field['property_name']} = @$query_record->{$field_id};
      }
    }
  }

  // special properties that don't map directly from storage and defaults
  $this->inDatabase = TRUE;
  $this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0);
  $this->baseDn = $this
    ->linesToArray($this->base_dn_str);
  $this->attributes = $this->attributes_str ? $this
    ->csvToArray($this->attributes_str, TRUE) : array();
}