public function save() { $op = $this->inDatabase ? 'edit' : 'insert'; $values = new stdClass(); // $this; $values->sid = $this->sid; $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->derive_from_dn = (int) $this->deriveFromDn; $values->derive_from_dn_attr = $this->deriveFromDnAttr; $values->derive_from_attr = (int) $this->deriveFromAttr; $values->derive_from_attr_attr = $this->arrayToLines($this->deriveFromAttrAttr); $values->derive_from_attr_use_first_attr = (int) $this->deriveFromAttrUseFirstAttr; $values->derive_from_attr_nested = (int) $this->deriveFromAttrNested; $values->derive_from_entry = (int) $this->deriveFromEntry; $values->derive_from_entry_search_all = (int) $this->deriveFromEntrySearchAll; $values->derive_from_entry_entries = $this->arrayToLines($this->deriveFromEntryEntries); $values->derive_from_entry_entries_attr = $this->deriveFromEntryEntriesAttr; $values->derive_from_entry_attr = $this->deriveFromEntryMembershipAttr; $values->derive_from_entry_user_ldap_attr = $this->deriveFromEntryAttrMatchingUserAttr; $values->derive_from_entry_use_first_attr = (int) $this->deriveFromEntryUseFirstAttr; $values->derive_from_entry_nested = (int) $this->deriveFromEntryNested; $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; } } $result = ctools_export_crud_save('ldap_authorization', $values); } elseif ($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, TRUE); foreach (array('consumer_type', 'consumer_module', 'only_ldap_authenticated', 'derive_from_dn', 'derive_from_dn_attr', 'derive_from_attr', 'derive_from_attr_attr', 'derive_from_attr_use_first_attr', 'derive_from_attr_nested', 'derive_from_entry', 'derive_from_entry_entries', 'derive_from_entry_attr', 'derive_from_entry_search_all', 'derive_from_entry_use_first_attr', 'derive_from_entry_nested', 'use_filter', 'synch_to_ldap', 'synch_on_logon', 'revoke_ldap_provisioned', 'create_consumers', 'regrant_ldap_provisioned') as $prop_name) { unset($this->{$prop_name}); } }
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.')); } } }
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.')); } }
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}); } }
/** * An internal representation of a panelizer object, used to seed when * we have none and want something to get started. */ public function get_internal_default_panelizer($bundle, $view_mode) { ctools_include('export'); $load_name = implode(':', array($this->entity_type, $bundle, 'default')); $panelizer = ctools_export_crud_new('panelizer_defaults'); $panelizer->name = $load_name; // Attach the view mode to the name, which is specially generated // to ignore the specialty "page_manager" view mode. if ($view_mode != 'page_manager') { $panelizer->name .= ':' . $view_mode; } $panelizer->panelizer_type = $this->entity_type; $panelizer->panelizer_key = $bundle; $panelizer->view_mode = $view_mode; $panelizer->display = $this->get_default_display($bundle, $view_mode); $panelizer->api_version = 1; $panelizer->title = t('Default'); return $panelizer; }
/** * Page callback to import information for an exportable item. */ function import_page($js, $input, $step = NULL) { drupal_set_title($this->get_page_title('import'), PASS_THROUGH); // Import is basically a multi step wizard form, so let's go ahead and // use CTools' wizard.inc for it. // If a step not set, they are trying to create a new item. If a step // is set, they're in the process of creating an item. if (!empty($step)) { $item = $this->edit_cache_get(NULL, 'import'); } if (empty($item)) { $item = ctools_export_crud_new($this->plugin['schema']); } $form_state = array('plugin' => $this->plugin, 'object' => &$this, 'ajax' => $js, 'item' => $item, 'op' => 'add', 'form type' => 'import', 'rerender' => TRUE, 'no_redirect' => TRUE, 'step' => $step, 'function args' => func_get_args()); // import always uses the wizard. $output = $this->edit_execute_form_wizard($form_state); if (!empty($form_state['executed'])) { $this->redirect($form_state['op'], $form_state['item']); } return $output; }
/** * Overrides ctools_export_ui::add_page(). * * Allows passing of options to drupal_goto() as opposed to just a path. * * @see http://drupal.org/node/1373048 */ function add_page($js, $input, $step = NULL) { drupal_set_title($this->get_page_title('add')); // If a step not set, they are trying to create a new item. If a step // is set, they're in the process of creating an item. if (!empty($this->plugin['use wizard']) && !empty($step)) { $item = $this->edit_cache_get(NULL, 'add'); } if (empty($item)) { $item = ctools_export_crud_new($this->plugin['schema']); } $form_state = array('plugin' => $this->plugin, 'object' => &$this, 'ajax' => $js, 'item' => $item, 'op' => 'add', 'form type' => 'add', 'rerender' => TRUE, 'no_redirect' => TRUE, 'step' => $step, 'function args' => func_get_args()); $output = $this->edit_execute_form($form_state); if (!empty($form_state['executed'])) { // @see @see http://drupal.org/node/1373048 $export_key = $this->plugin['export']['key']; $args = (array) $this->plugin['redirect']['add']; $args[0] = str_replace('%ctools_export_ui', $form_state['item']->{$export_key}, $args[0]); call_user_func_array('drupal_goto', $args); } return $output; }
/** * @param string enum $op 'add', 'update' */ public function save($op) { $values = new stdClass(); foreach ($this->field_to_properties_map() as $field_name => $property_name) { $field_name_lcase = drupal_strtolower($field_name); $values->{$field_name_lcase} = $this->{$property_name}; } if (isset($this->bindpw) && $this->bindpw) { $values->bindpw = ldap_servers_encrypt($this->bindpw); } if ($this->bindpw_new) { $values->bindpw = ldap_servers_encrypt($this->bindpw_new); } elseif ($this->bindpw_clear) { $values->bindpw = NULL; } $values->tls = (int) $this->tls; $values->followrefs = (int) $this->followrefs; if (module_exists('ctools')) { ctools_include('export'); // Populate our object with ctool's properties $object = ctools_export_crud_new('ldap_servers'); foreach ($object as $property => $value) { $property_lcase = drupal_strtolower($property); if (!isset($values->{$property}) || !isset($values->{$property_lcase})) { $values->{$property_lcase} = $value; } } try { $values->export_type = NULL; $result = ctools_export_crud_save('ldap_servers', $values); } catch (Exception $e) { $values->export_type = EXPORT_IN_DATABASE; $result = ctools_export_crud_save('ldap_servers', $values); } ctools_export_load_object_reset('ldap_servers'); // ctools_export_crud_save doesn't invalidate cache } else { // directly via db unset($values->numeric_sid); if ($op == 'add') { $result = drupal_write_record('ldap_servers', $values); } else { $result = drupal_write_record('ldap_servers', $values, 'sid'); } ldap_servers_cache_clear(); } // debug("values sent to save op=$op, ctools=". (int)module_exists('ctools')); debug($values); if ($result) { $this->inDatabase = TRUE; } else { drupal_set_message(t('Failed to write LDAP Server to the database.')); } }
/** * Page callback to import information for an exportable item. */ function import_page($js, $input, $step = NULL) { drupal_set_title($this->get_page_title('import')); // Import is basically a multi step wizard form, so let's go ahead and // use CTools' wizard.inc for it. // If a step not set, they are trying to create a new item. If a step // is set, they're in the process of creating an item. if (!empty($step)) { $item = $this->edit_cache_get(NULL, 'import'); } if (empty($item)) { $item = ctools_export_crud_new($this->plugin['schema']); } $form_state = array('plugin' => $this->plugin, 'object' => &$this, 'ajax' => $js, 'item' => $item, 'op' => 'add', 'form type' => 'import', 'rerender' => TRUE, 'no_redirect' => TRUE, 'step' => $step, 'function args' => func_get_args()); // import always uses the wizard. $output = $this->edit_execute_form_wizard($form_state); if (!empty($form_state['executed'])) { $export_key = $this->plugin['export']['key']; drupal_goto(str_replace('%ctools_export_ui', $form_state['item']->{$export_key}, $this->plugin['redirect']['add'])); } return $output; return; $form_info = array('id' => 'ctools_export_ui_import', 'path' => ctools_export_ui_plugin_menu_path($this->plugin, 'import') . '/%step', 'return path' => $this->plugin['redirect']['import'], 'show trail' => TRUE, 'show back' => TRUE, 'show return' => FALSE, 'show cancel' => TRUE, 'finish callback' => 'ctools_export_ui_import_finish', 'cancel callback' => 'ctools_export_ui_import_cancel', 'order' => array('code' => t('Import code'), 'edit' => t('Edit')), 'forms' => array('code' => array('form id' => 'ctools_export_ui_import_code'), 'edit' => array('form id' => 'ctools_export_ui_import_edit'))); $form_state = array('plugin' => $this->plugin, 'input' => $input, 'rerender' => TRUE, 'no_redirect' => TRUE, 'object' => &$this, 'export' => '', 'overwrite' => FALSE, 'function args' => func_get_args()); if ($step == 'code') { // This is only used if the BACK button was hit. if (!empty($_SESSION['ctools_export_ui_import'][$this->plugin['name']])) { $form_state['item'] = $_SESSION['ctools_export_ui_import'][$this->plugin['name']]; $form_state['export'] = $form_state['item']->export_ui_code; $form_state['overwrite'] = $form_state['item']->export_ui_allow_overwrite; } } else { if ($step == 'begin') { $step = 'code'; if (!empty($_SESSION['ctools_export_ui_import'][$this->plugin['name']])) { unset($_SESSION['ctools_export_ui_import'][$this->plugin['name']]); } } else { if ($step != 'code') { $form_state['item'] = $_SESSION['ctools_export_ui_import'][$this->plugin['name']]; $form_state['op'] = 'add'; if (!empty($form_state['item']->export_ui_allow_overwrite)) { // if allow overwrite was enabled, set this to 'edit' only if the key already existed. $export_key = $this->plugin['export']['key']; if (ctools_export_crud_load($this->plugin['schema'], $form_state['item']->{$export_key})) { $form_state['op'] = 'edit'; } } } } } ctools_include('wizard'); return ctools_wizard_multistep_form($form_info, $step, $form_state); }
public function save($op) { $entry = $this; foreach ($this->field_to_properties_map() as $field_name => $property_name) { $entry->{$field_name} = $this->{$property_name}; } if (isset($this->bindpw) && $this->bindpw) { $entry->bindpw = ldap_servers_encrypt($this->bindpw); } if ($this->bindpw_new) { $entry->bindpw = ldap_servers_encrypt($this->bindpw_new); } elseif ($this->bindpw_clear) { $entry->bindpw = NULL; } $entry->tls = (int) $entry->tls; $result = FALSE; if ($op == 'edit') { if (module_exists('ctools')) { ctools_include('export'); $result = ctools_export_crud_save('ldap_servers', $entry); } else { $result = drupal_write_record('ldap_servers', $entry, 'sid'); } } else { if (module_exists('ctools')) { ctools_include('export'); // Populate our object with ctool's properties $object = ctools_export_crud_new('ldap_servers'); foreach ($object as $property => $value) { if (!isset($entry->{$property})) { $entry->{$property} = $value; } } $result = ctools_export_crud_save('ldap_servers', $entry); } else { $result = drupal_write_record('ldap_servers', $entry); } } if ($result) { $this->inDatabase = TRUE; } else { drupal_set_message(t('Failed to write LDAP Server to the database.')); } }
public function save($op) { $entry = $this->entry(); $result = FALSE; if ($op == 'edit') { if (module_exists('ctools')) { ctools_include('export'); $result = ctools_export_crud_save('ldap_servers', $entry); ctools_export_load_object_reset('ldap_servers'); // ctools_export_crud_save doesn't invalidate cache } else { $result = drupal_write_record('ldap_servers', $entry, 'sid'); } } else { if (module_exists('ctools')) { ctools_include('export'); // Populate our object with ctool's properties $object = ctools_export_crud_new('ldap_servers'); foreach ($object as $property => $value) { if (!isset($entry->{$property})) { $entry->{$property} = $value; } } $result = ctools_export_crud_save('ldap_servers', $entry); ctools_export_load_object_reset('ldap_servers'); // ctools_export_crud_save doesn't invalidate cache } else { $result = drupal_write_record('ldap_servers', $entry); } } if ($result) { $this->inDatabase = TRUE; } else { drupal_set_message(t('Failed to write LDAP Server to the database.')); } }