public function LdapAuthorizationConsumerConfAdmin::save in Lightweight Directory Access Protocol (LDAP) 8.2
Same name and namespace in other branches
- 7.2 ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php \LdapAuthorizationConsumerConfAdmin::save()
- 7 ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php \LdapAuthorizationConsumerConfAdmin::save()
1 call to LdapAuthorizationConsumerConfAdmin::save()
File
- ldap_authorization/
LdapAuthorizationConsumerConfAdmin.class.php, line 16
Class
- LdapAuthorizationConsumerConfAdmin
- LDAP Authorization Consumer Configration Admin Class
Code
public function save() {
$op = $this->inDatabase ? 'edit' : 'insert';
$values = new stdClass();
// $this;
$values->sid = $this->sid;
$values->numeric_consumer_conf_id = $this->numericConsumerConfId;
$values->consumer_type = $this->consumerType;
$values->consumer_module = $this->consumer->consumerModule;
$values->status = $this->status ? 1 : 0;
$values->only_ldap_authenticated = (int) $this->onlyApplyToLdapAuthenticated;
$values->use_first_attr_as_groupid = (int) $this->useFirstAttrAsGroupId;
$values->mappings = serialize($this->mappings);
$values->use_filter = (int) $this->useMappingsAsFilter;
$values->synch_to_ldap = (int) $this->synchToLdap;
$values->synch_on_logon = (int) $this->synchOnLogon;
$values->revoke_ldap_provisioned = (int) $this->revokeLdapProvisioned;
$values->create_consumers = (int) $this->createConsumers;
$values->regrant_ldap_provisioned = (int) $this->regrantLdapProvisioned;
if (module_exists('ctools')) {
ctools_include('export');
// Populate our object with ctool's properties
$object = ctools_export_crud_new('ldap_authorization');
foreach ($object as $property => $value) {
if (!isset($values->{$property})) {
$values->{$property} = $value;
}
}
try {
$values->export_type = NULL;
$result = ctools_export_crud_save('ldap_authorization', $values);
} catch (Exception $e) {
// debug($e); Integrity constraint violation: 1062 Duplicate entry
$values->export_type = EXPORT_IN_DATABASE;
$result = ctools_export_crud_save('ldap_authorization', $values);
}
ctools_export_load_object_reset('ldap_authorization');
// ctools_export_crud_save doesn't invalidate cache
}
else {
if ($op == 'edit') {
$result = drupal_write_record('ldap_authorization', $values, 'consumer_type');
}
else {
// insert
$result = drupal_write_record('ldap_authorization', $values);
}
if ($result) {
$this->inDatabase = TRUE;
}
else {
drupal_set_message(t('Failed to write LDAP Authorization to the database.'));
}
}
}