コード例 #1
0
 public function delete()
 {
     if ($this->consumerType) {
         $this->inDatabase = FALSE;
         if (module_exists('ctools')) {
             ctools_export_load_object_reset('ldap_authorization');
         }
         return db_delete('ldap_authorization')->condition('consumer_type', $this->consumerType)->execute();
     } else {
         return FALSE;
     }
 }
コード例 #2
0
 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.'));
         }
     }
 }
コード例 #3
0
 public function save($op)
 {
     $op = $this->inDatabase ? 'edit' : 'insert';
     if (module_exists('ctools')) {
         // add or edit with ctolls
         ctools_include('export');
         $ctools_values = clone $this;
         foreach ($this->fields() as $field_id => $field) {
             $value = $this->{$field['property_name']};
             if (isset($field['exportable']) && $field['exportable'] === FALSE) {
                 // field not exportable
                 unset($ctools_values->{$field['property_name']});
             } elseif (isset($field['schema']) && $field['property_name'] != $field_id) {
                 // field in property with different name
                 $ctools_values->{$field_id} = $value;
                 unset($ctools_values->{$field['property_name']});
             } else {
                 // do nothing.  property is already in cloned objecat
             }
         }
         // Populate our object with ctool's properties.  copying all properties for backward compatibility
         $object = ctools_export_crud_new('ldap_query');
         foreach ($object as $property_name => $value) {
             if (!isset($ctools_values->{$property_name})) {
                 $ctools_values->{$property_name} = $value;
             }
         }
         $result = ctools_export_crud_save('ldap_query', $ctools_values);
         ctools_export_load_object_reset('ldap_query');
         // ctools_export_crud_save doesn't invalidate cache
     } else {
         $values = array();
         foreach ($this->fields() as $field_id => $field) {
             if (isset($field['schema'])) {
                 $values[$field_id] = $this->{$field['property_name']};
             }
         }
         if ($op == 'edit') {
             // edit w/o ctools
             $result = drupal_write_record('ldap_query', $values, 'qid');
         } else {
             // insert
             $result = drupal_write_record('ldap_query', $values);
         }
     }
     if ($result) {
         $this->inDatabase = TRUE;
     } else {
         drupal_set_message(t('Failed to write LDAP Query to the database.'));
     }
 }
コード例 #4
0
 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->useFirstAttrAsGroupId = (int) $this->useFirstAttrAsGroupId;
     $values->mappings = $this->arrayToPipeList($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;
             }
         }
         $values->export_type = $this->numericConsumerConfId ? EXPORT_IN_DATABASE : NULL;
         $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.'));
         }
     }
     // revert mappings to array and remove temporary properties from ctools export
     $this->mappings = $this->pipeListToArray($values->mappings, FALSE);
     foreach (array('consumer_type', 'consumer_module', 'only_ldap_authenticated', 'use_filter', 'synch_to_ldap', 'synch_on_logon', 'revoke_ldap_provisioned', 'create_consumers', 'regrant_ldap_provisioned') as $prop_name) {
         unset($this->{$prop_name});
     }
 }
コード例 #5
0
ファイル: LdapServerAdmin.class.php プロジェクト: tierce/ppbe
 public function delete($sid)
 {
     if ($sid == $this->sid) {
         $result = db_delete('ldap_servers')->condition('sid', $sid)->execute();
         if (module_exists('ctools')) {
             ctools_include('export');
             ctools_export_load_object_reset('ldap_servers');
             // invalidate cache
         }
         $this->inDatabase = FALSE;
         return $result;
     } else {
         return FALSE;
     }
 }
コード例 #6
0
ファイル: CtoolsConfiguration.php プロジェクト: mrsad/Dru.io
 /**
  * Implements Drupal\configuration\Config\Configuration::prepareBuild().
  */
 public function prepareBuild()
 {
     ctools_include('export');
     ctools_export_load_object_reset();
     $this->data = ctools_export_crud_load($this->getComponent(), $this->getIdentifier());
     return $this;
 }
コード例 #7
0
 public function delete($qid)
 {
     if ($qid == $this->qid) {
         $this->inDatabase = FALSE;
         if (module_exists('ctools')) {
             ctools_include('export');
             ctools_export_load_object_reset('ldap_query');
         }
         return db_delete('ldap_query')->condition('qid', $qid)->execute();
     } else {
         return FALSE;
     }
 }