protected function LdapAuthorizationConsumerConf::loadFromDb in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_authorization/LdapAuthorizationConsumerConf.class.php \LdapAuthorizationConsumerConf::loadFromDb()
- 7 ldap_authorization/LdapAuthorizationConsumerConf.class.php \LdapAuthorizationConsumerConf::loadFromDb()
1 call to LdapAuthorizationConsumerConf::loadFromDb()
- LdapAuthorizationConsumerConf::__construct in ldap_authorization/
LdapAuthorizationConsumerConf.class.php - Constructor Method.
File
- ldap_authorization/
LdapAuthorizationConsumerConf.class.php, line 78 - Class to encapsulate an ldap entry to authorization consumer ids mapping configuration.
Class
- LdapAuthorizationConsumerConf
- LDAP Authorization Consumer Configuration.
Code
protected function loadFromDb() {
if (module_exists('ctools')) {
ctools_include('export');
$result = ctools_export_load_object('ldap_authorization', 'names', [
$this->consumerType,
]);
// @todo, this is technically wrong, but I don't quite grok what we're doing in the non-ctools case - justintime
$server_record = array_pop($result);
// There's no ctools api call to get the reserved properties, so instead of hardcoding a list of them
// here, we just grab everything. Basically, we sacrifice a few bytes of RAM for forward-compatibility.
}
else {
$select = db_select('ldap_authorization', 'ldap_authorization');
$select
->fields('ldap_authorization');
$select
->condition('ldap_authorization.consumer_type', $this->consumerType);
$server_record = $select
->execute()
->fetchObject();
}
if (!$server_record) {
$this->inDatabase = FALSE;
return FALSE;
}
foreach ($this
->field_to_properties_map() as $db_field_name => $property_name) {
if (isset($server_record->{$db_field_name})) {
if (in_array($db_field_name, $this
->field_to_properties_serialized())) {
$this->{$property_name} = unserialize($server_record->{$db_field_name});
}
else {
$this->{$property_name} = $server_record->{$db_field_name};
}
}
}
$this->numericConsumerConfId = isset($server_record->numeric_consumer_conf_id) ? $server_record->numeric_consumer_conf_id : NULL;
$this->server = ldap_servers_get_servers($this->sid, NULL, TRUE);
return TRUE;
}