/**
  * @see LTIToolProviderOutcomesResourceEntityControllerInterface::save
  */
 public function save($entity)
 {
     $transaction = db_transaction();
     try {
         $entity->is_new = empty($enity->lti_tool_provider_outcomes_resource_id);
         if (empty($entity->lti_tool_provider_outcomes_resource_timestamp_created)) {
             $entity->lti_tool_provider_outcomes_resource_timestamp_created = REQUEST_TIME;
         }
         field_attach_presave('lti_tool_provider_outcomes_resource', $entity);
         $primary_key = $entity->lti_tool_provider_outcomes_resource_id ? 'lti_tool_provider_outcomes_resource_id' : array();
         if (empty($primary_key)) {
             drupal_write_record('lti_tool_provider_outcomes_resource', $entity);
             field_attach_insert('lti_tool_provider_outcomes_resource', $entity);
             $op = 'insert';
         } else {
             drupal_write_record('lti_tool_provider_outcomes_resource', $entity, $primary_key);
             $op = 'update';
         }
         $function = 'field_attach_' . $op;
         $function('lti_tool_provider_outcomes_resource', $entity);
         module_invoke_all('entity_' . $op, $entity, 'lti_tool_provider_outcomes_resource');
         unset($entity->is_new);
         db_ignore_slave();
         return $entity;
     } catch (Exception $e) {
         $transaction->rollback();
         drupal_set_message(t('%e', array('%e' => $entity->{$e})));
         watchdog_exception('lti_tool_provider_outcomes_resource', $e, NULL, WATCHDOG_ERROR);
         return FALSE;
     }
 }
Exemple #2
0
/**
 * Allow other modules to act when invite accepted.
 *
 * @param Invite $invite
 */
function hook_invite_accept($invite)
{
    global $user;
    // Add message, when user accepts invite.
    $message = array('iid' => $invite->iid, 'uid' => $invite->uid, 'inviter' => $invite->uid, 'invitee' => $invite->invitee, 'message_type' => 'inviter_notification');
    drupal_write_record('invite_notifications', $message);
}
 /**
  * Save the record to the database
  */
 public function save($new = FALSE)
 {
     $bean_type = array('name' => check_plain($this->type), 'label' => check_plain($this->getLabel()), 'description' => check_plain($this->getDescription()));
     $primary_key = $new == FALSE ? 'name' : array();
     drupal_write_record('bean_type', $bean_type, $primary_key);
     bean_reset();
 }
 /**
  * Test the div formatter.
  */
 function testDiv()
 {
     $data = array('label' => 'Wrapper', 'weight' => '1', 'children' => array(0 => 'field_test'), 'format_type' => 'div', 'format_settings' => array('label' => 'Link', 'instance_settings' => array('required_fields' => 0, 'id' => 'wrapper-id', 'classes' => 'test-class', 'description' => '', 'show_label' => FALSE, 'label_element' => 'h3', 'effect' => 'blink', 'speed' => 'fast'), 'formatter' => 'open'));
     $group = $this->createGroup('default', $data);
     $groups = field_group_info_groups('node', 'article', 'default', TRUE);
     $this->drupalGet('node/' . $this->node->nid);
     // Test group ids and classes.
     $this->assertFieldByXPath("//div[contains(@id, 'wrapper-id')]", NULL, t('Wrapper id set on wrapper div'));
     $this->assertFieldByXPath("//div[contains(@class, 'test-class')]", NULL, t('Test class set on wrapper div') . 'class="' . $group->group_name . ' test-class');
     // Test group label.
     $this->assertNoRaw('<h3><span>' . $data['label'] . '</span></h3>', t('Label is not shown'));
     // Set show label to true.
     $group->data['format_settings']['instance_settings']['show_label'] = TRUE;
     drupal_write_record('field_group', $group, array('identifier'));
     $groups = field_group_info_groups('node', 'article', 'default', TRUE);
     $this->drupalGet('node/' . $this->node->nid);
     $this->assertRaw('<h3><span>' . $data['label'] . '</span></h3>', t('Label is shown'));
     // Change to collapsible
     $group->data['format_settings']['formatter'] = 'collapsible';
     drupal_write_record('field_group', $group, array('identifier'));
     $groups = field_group_info_groups('node', 'article', 'default', TRUE);
     $this->drupalGet('node/' . $this->node->nid);
     $this->assertFieldByXPath("//div[contains(@class, 'speed-fast')]", NULL, t('Speed class is set'));
     $this->assertFieldByXPath("//div[contains(@class, 'effect-blink')]", NULL, t('Effect class is set'));
 }
 public function save($entity)
 {
     $entity = (object) $entity;
     // Determine if we will be inserting a new entity.
     $entity->is_new = !(isset($entity->bid) && is_numeric($entity->bid));
     $transaction = db_transaction();
     // Set the timestamp fields.
     if (empty($entity->created)) {
         $entity->created = REQUEST_TIME;
     }
     $entity->changed = REQUEST_TIME;
     field_attach_presave('command_button', $entity);
     module_invoke_all('entity_presave', $entity, 'command_button');
     try {
         if (!$entity->is_new) {
             drupal_write_record('command_buttons', $entity, 'bid');
             field_attach_update('command_button', $entity);
             module_invoke_all('entity_update', $entity, 'command_button');
         } else {
             drupal_write_record('command_buttons', $entity);
             field_attach_insert('command_button', $entity);
             module_invoke_all('entity_insert', $entity, 'command_button');
         }
         return $entity;
     } catch (Exception $e) {
         $transaction->rollback();
         watchdog_exception('command_button', $e);
     }
     return FALSE;
 }
function os_poker_set_application_default_settings()
{
    $application =& os_poker_get_poker_application();
    if ($application) {
        $settings = !empty($application->settings) ? unserialize($application->settings) : array();
        $defaults = array('os_poker_skin' => url('poker/skin.css', array('absolute' => true)));
        foreach ($defaults as $name => $value) {
            if (!is_object($settings[$name])) {
                $settings[$name] = new stdClass();
            }
            if ($settings[$name]->default != $value) {
                $settings[$name]->default = $value;
            } else {
                unset($defaults[$name]);
            }
        }
        if (count($defaults) > 0) {
            $application->settings = serialize($settings);
            if (drupal_write_record('applications', $application, 'id') == SAVED_UPDATED) {
                foreach ($defaults as $name => $value) {
                    drupal_set_message(t('Application preference %name set to default value %value.', array('%name' => $name, '%value' => $value)));
                }
            }
        }
    } else {
        drupal_set_message('Cannot set default settings for %name application, it doesn\'t exist in the database', array('%name' => 'jpoker'));
    }
}
Exemple #7
0
 /**
  * @Then I should see a valid catalog xml
  */
 public function iShouldSeeAValidCatalogXml()
 {
     // Change /catalog.xml path to /catalog during tests. The '.' on the filename breaks tests on CircleCI's server.
     $dcat = open_data_schema_map_api_load('dcat_v1_1');
     if ($dcat->endpoint !== 'catalog') {
         $dcat->endpoint = 'catalog';
         drupal_write_record('open_data_schema_map', $dcat, 'id');
         drupal_static_reset('open_data_schema_map_api_load_all');
         menu_rebuild();
     }
     // Change /catalog.json path to /catalogjson during tests. The '.' on the filename breaks tests on CircleCI's server.
     $dcat_json = open_data_schema_map_api_load('dcat_v1_1_json');
     if ($dcat_json->endpoint !== 'catalogjson') {
         $dcat_json->endpoint = 'catalogjson';
         drupal_write_record('open_data_schema_map', $dcat_json, 'id');
         drupal_static_reset('open_data_schema_map_api_load_all');
         menu_rebuild();
     }
     // Get base URL.
     $url = $this->getMinkParameter('base_url') ? $this->getMinkParameter('base_url') : "http://127.0.0.1::8888";
     $url_xml = $url . '/catalog';
     $url_json = $url . '/catalogjson';
     $this->visitPath($url_xml);
     $this->assertSession()->statusCodeEquals('200');
     // Validate DCAT.
     $results = open_data_schema_dcat_process_validate($url_json, TRUE);
     if ($results['errors']) {
         throw new \Exception(sprintf('catalog.xml is not valid.'));
     }
 }
/**
 * When a node or its menu item are updated, notify other modules.
 *
 * Note that this hook runs for each menu item that belongs to the node
 * (yes, core allows that), so normally you would use $link->mlid as the
 * primary key.
 *
 * @param $link
 *   An object representing a single row from the {menu_links} table.
 *   This object defines the menu link and can be used to load additional
 *   data using menu_get_item().
 * @param $node
 *   The node object being acted upon.
 */
function hook_menu_node_update($link, $node)
{
    // Update data in my custom table, which tracks the owners of nodes
    // placed in the site menu.
    $record = array('nid' => $node->nid, 'mlid' => $link->mlid, 'uid' => $node->uid);
    drupal_write_record('mytable', $record, array('mlid', 'uid'));
}
Exemple #9
0
 /**
  * Save the last run info, either updating an existing database record or
  * creating a new one.
  */
 public function save()
 {
     if ($this->new) {
         drupal_write_record(self::$table, $this);
     } else {
         drupal_write_record(self::$table, $this, array('sid', 'iid'));
     }
 }
 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 static function setUpBeforeClass()
 {
     // Change /data.json path to /json during tests.
     $data_json = open_data_schema_map_api_load('data_json_1_1');
     $data_json->endpoint = 'json';
     drupal_write_record('open_data_schema_map', $data_json, 'id');
     drupal_static_reset('open_data_schema_map_api_load_all');
     menu_rebuild();
 }
Exemple #12
0
 /**
  * {@inheritdoc}
  */
 public function save(EntityInterface $entity)
 {
     // We return SAVED_UPDATED by default because the logic below might not
     // update the entity if its values haven't changed, so returning FALSE
     // would be confusing in that situation.
     $return = SAVED_UPDATED;
     $transaction = $this->database->startTransaction();
     try {
         // Load the stored entity, if any.
         if (!$entity->isNew() && !isset($entity->original)) {
             $id = $entity->id();
             if ($entity->getOriginalId() !== NULL) {
                 $id = $entity->getOriginalId();
             }
             $entity->original = $this->loadUnchanged($id);
         }
         if ($entity->isNew()) {
             $entity->mlid = $this->database->insert($this->entityType->getBaseTable())->fields(array('menu_name' => $entity->menu_name))->execute();
             $entity->enforceIsNew();
         }
         // Unlike the save() method from EntityDatabaseStorage, we invoke the
         // 'presave' hook first because we want to allow modules to alter the
         // entity before all the logic from our preSave() method.
         $this->invokeHook('presave', $entity);
         $entity->preSave($this);
         // If every value in $entity->original is the same in the $entity, there
         // is no reason to run the update queries or clear the caches. We use
         // array_intersect_key() with the $entity as the first parameter because
         // $entity may have additional keys left over from building a router entry.
         // The intersect removes the extra keys, allowing a meaningful comparison.
         if ($entity->isNew() || array_intersect_key(get_object_vars($entity), get_object_vars($entity->original)) != get_object_vars($entity->original)) {
             $return = drupal_write_record($this->entityType->getBaseTable(), $entity, $this->idKey);
             if ($return) {
                 if (!$entity->isNew()) {
                     $this->resetCache(array($entity->{$this->idKey}));
                     $entity->postSave($this, TRUE);
                     $this->invokeHook('update', $entity);
                 } else {
                     $return = SAVED_NEW;
                     $this->resetCache();
                     $entity->enforceIsNew(FALSE);
                     $entity->postSave($this, FALSE);
                     $this->invokeHook('insert', $entity);
                 }
             }
         }
         // Ignore replica server temporarily.
         db_ignore_replica();
         unset($entity->original);
         return $return;
     } catch (\Exception $e) {
         $transaction->rollback();
         watchdog_exception($this->entityTypeId, $e);
         throw new EntityStorageException($e->getMessage(), $e->getCode(), $e);
     }
 }
Exemple #13
0
 /**
  * Save
  *
  * Saves the remote to the database.
  *
  * @return bool|int False if the save failed, otherwise the remote ID.
  */
 public function save()
 {
     if (empty($this->rid)) {
         $result = drupal_write_record('publisher_remotes', $this);
     } else {
         $result = drupal_write_record('publisher_remotes', $this, 'rid');
     }
     menu_rebuild();
     return $result;
 }
 public function save()
 {
     // Check to see if the ID is numeric and exists.
     $does_exist = is_numeric($this->record['pid']) && self::load($this->record['pid']) !== false;
     $primary_keys = array();
     if ($does_exist) {
         $primary_keys = 'pid';
     }
     return drupal_write_record('ablecore_menu_item_path', $this->record, $primary_keys);
 }
/**
 * Update webform captcha
 */
function osha_update_webform_captcha($last_id)
{
    $form_id = 'webform_client_form_' . $last_id;
    $query = db_query("SELECT * FROM captcha_points WHERE form_id = '{$form_id}' ")->fetchField();
    $data = array('form_id' => $form_id, 'module' => NULL, 'captcha_type' => 'default');
    if ($query) {
        drupal_write_record('captcha_points', $data, 'form_id');
    } else {
        drupal_write_record('captcha_points', $data);
    }
}
 /**
  * Import all the cities from the xml.
  */
 private function importHeadings($xmlElement)
 {
     // Clear them first.
     db_query('TRUNCATE {cnapi_headings}');
     // Import rows.
     $headings = $xmlElement->xpath('heading_categorisation');
     foreach ($headings as $heading) {
         $headingAttributes = $heading->attributes();
         $record = array('hid' => (int) $headingAttributes['heading_id'], 'cid' => (string) $headingAttributes['cnet_id']);
         drupal_write_record('cnapi_headings', $record);
     }
 }
 /**
  * Insert label to db
  */
 public function insert()
 {
     if (isset($this->label_id)) {
         // The label already exists in the database, update the record.
         drupal_write_record('versioncontrol_labels', $this, 'label_id');
     } else {
         // The label does not yet exist, create it.
         // drupal_write_record() also assigns the new id to $this->label_id.
         drupal_write_record('versioncontrol_labels', $this);
     }
     unset($this->repo_id);
 }
 /**
  * Save an entry to the sustainers log.
  *
  * @param array $values
  *   Values to save that are different from the old values, plus did. Donation
  *   ID (did) is a required key.
  * @param null|object $old_record
  *   The original record. If one is not provided it gets queried. This is used
  *   for default values and the old_state.
  *
  * @return bool|int
  *   FALSE or SAVED_NEW because a new record is always saved.
  */
 public function log(array $values, $old_record = NULL)
 {
     if (is_null($old_record)) {
         $old_record = _fundraiser_sustainers_get_recurring_by_did($values['did']);
     }
     $new_record = new stdClass();
     $new_record->timestamp = REQUEST_TIME;
     $new_record->did = $values['did'];
     if (isset($values['lock_id'])) {
         $new_record->lock_id = $values['lock_id'];
     } elseif (isset($old_record->lock_id)) {
         $new_record->lock_id = $old_record->lock_id;
     } else {
         $new_record->lock_id = '0';
     }
     if (isset($values['next_charge'])) {
         $new_record->next_charge = $values['next_charge'];
     } elseif (isset($old_record->next_charge)) {
         $new_record->next_charge = $old_record->next_charge;
     } else {
         $new_record->next_charge = 0;
     }
     if (isset($values['old_state'])) {
         $new_record->old_state = $values['old_state'];
     } elseif (isset($old_record->gateway_resp)) {
         $new_record->old_state = $old_record->gateway_resp;
     } else {
         $new_record->old_state = NULL;
     }
     // New state of NULL means no transition happened.
     if (isset($values['new_state'])) {
         $new_record->new_state = $values['new_state'];
     } elseif (isset($values['gateway_resp'])) {
         $new_record->new_state = $values['gateway_resp'];
     } else {
         $new_record->new_state = NULL;
     }
     if (isset($values['attempts'])) {
         $new_record->attempts = $values['attempts'];
     } elseif (isset($old_record->attempts)) {
         $new_record->attempts = $old_record->attempts;
     } else {
         $new_record->attempts = 0;
     }
     if (isset($values['cancellation_reason'])) {
         $new_record->cancellation_reason = $values['cancellation_reason'];
     } elseif (isset($old_record->cancellation_reason)) {
         $new_record->cancellation_reason = $old_record->cancellation_reason;
     } else {
         $new_record->cancellation_reason = '';
     }
     return drupal_write_record('fundraiser_sustainers_log', $new_record);
 }
Exemple #19
0
 public static function write(&$issue)
 {
     $update = isset($issue->liid) ? array('liid') : NULL;
     self::invokeByRef('dissue_write', $issue, 'before', !$update);
     // Serialize our data attribute, but hold on to a copy
     $data = $issue->data;
     $issue->data = json_encode($issue->data);
     drupal_write_record('dissue', $issue, $update);
     // Restore non-serialized data
     $issue->data = $data;
     self::invokeByRef('dissue_write', $issue, 'after', !$update);
 }
 /**
  * Import all the cities from the xml.
  */
 private function importCities($xmlElement)
 {
     // Clear them first.
     db_query('TRUNCATE {culturefeed_search_cities}');
     // Import rows.
     foreach ($xmlElement->cities->city as $city) {
         $cityAttributes = $city->attributes();
         $record = array('cid' => (string) $cityAttributes['id'], 'name' => (string) $cityAttributes['label'], 'zip' => (string) $cityAttributes['zip'], 'slug' => (string) $cityAttributes['zip'] . '-' . culturefeed_search_slug((string) $cityAttributes['label'], 251));
         drupal_write_record('culturefeed_search_cities', $record);
         $this->logMessages[] = array('message' => 'Imported city ' . (string) $cityAttributes['label'], 'code' => 'success');
     }
 }
 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.'));
         }
     }
 }
Exemple #22
0
 /**
  * Writes node_expire record.
  */
 public static function writeRecord($node_expire, $nid)
 {
     // Check, is it insert or update.
     $cnt = self::getNodeExpireCountByNid($nid);
     // Write the record.
     if ($cnt == 0) {
         // Insert.
         drupal_write_record('node_expire', $node_expire);
     } else {
         // Update.
         drupal_write_record('node_expire', $node_expire, 'nid');
     }
 }
 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});
     }
 }
Exemple #24
0
 /**
  * Save the picture mapping.
  *
  * @return
  *   If the record insert or update failed, returns FALSE. If it succeeded,
  *   returns SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
  */
 public function save()
 {
     $update = array();
     $this->cleanMappings();
     $data = $this->toArray();
     if (isset($this->id) && $this->id) {
         $update = array('id');
         $data['id'] = $this->id;
     }
     $return = drupal_write_record('picture_mapping', $data, $update);
     $this->setValues(ctools_export_get_schema('picture_mapping'), $data);
     $this->loadBreakpointGroup();
     return $return;
 }
function populate_lingwo_entry_info()
{
    $cur = variable_get('oss_db_update', 0);
    $ret = db_query("SELECT n.nid, le.pos FROM {node} n, {lingwo_entry} le WHERE n.type = '%s' AND le.nid = n.tnid AND n.nid > %d ORDER BY n.nid LIMIT 50", LingwoEntry::$settings->content_type, $cur);
    while ($obj = db_fetch_object($ret)) {
        $node = node_load($obj->nid);
        $node->pos = $obj->pos;
        $entry = LingwoEntry::fromNode($node);
        $entry_hash = _lingwo_entry_generate_hash($entry);
        $info = (object) array('nid' => $entry->nid, 'language' => implode('-', $entry->getLanguages()), 'source_language' => $entry->sourceLanguage, 'target_language' => $entry->targetLanguage, 'pos' => $obj->pos, 'translation' => $entry->isTranslation(), 'entry_hash' => $entry_hash);
        drupal_write_record('lingwo_entry_info', $info);
        node_load(NULL, NULL, TRUE);
        $cur = $entry->nid;
    }
    variable_set('oss_db_update', $cur);
}
 /**
  * Update the record in the database.
  */
 public function update($options = array())
 {
     if (empty($this->elid)) {
         throw new Exception('Attempted to update a Versioncontrol event which has not yet been inserted in the database.', E_ERROR);
     }
     // Append default options.
     $options += $this->defaultCrudOptions['update'];
     if (empty($this->repo_id)) {
         $this->repo_id = $this->getRepository()->repo_id;
     }
     drupal_write_record('versioncontrol_event_log', $this, 'elid');
     $this->backendUpdate($options);
     // Everything's done, invoke the hook.
     module_invoke_all('versioncontrol_entity_event_update', $this);
     return $this;
 }
 /**
  * Parse attachments from message mimeparts.
  */
 function process(&$message, $source)
 {
     $message['attachments'] = array();
     foreach ($message['mimeparts'] as $attachment) {
         // 'unnamed_attachment' files are not really attachments, but mimeparts like HTML or Plain Text.
         // We only want to save real attachments, like images and files.
         if ($attachment->filename !== 'unnamed_attachment') {
             $destination = 'temporary://';
             $filename = mb_decode_mimeheader($attachment->filename);
             $file = file_save_data($attachment->data, $destination . $filename);
             $file->status = 0;
             drupal_write_record('file_managed', $file, 'fid');
             $message['attachments'][] = new FeedsEnclosure($file->uri, $attachment->filemime);
         }
     }
     unset($message['mimeparts']);
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp('comment', 'feeds_comment_processor');
     // Create an importer configuration.
     $this->createImporterConfiguration('Test', 'comment');
     // Set and configure plugins.
     $this->setPlugin('comment', 'FeedsCSVParser');
     $this->setPlugin('comment', 'FeedsCommentProcessor');
     $edit = array('bundle' => 'comment_node_article');
     $this->setSettings('comment', 'FeedsCommentProcessor', $edit);
     $this->addMappings('comment', array(0 => array('source' => 'subject', 'target' => 'subject'), 1 => array('source' => 'guid', 'target' => 'nid_by_guid'), 2 => array('source' => 'body', 'target' => 'comment_body', 'format' => 'plain_text'), 3 => array('source' => 'status', 'target' => 'status'), 4 => array('source' => 'hostname', 'target' => 'hostname')));
     $parent = (object) array('title' => 'Parent', 'type' => 'article');
     node_save($parent);
     // Insert a feeds_item record.
     $item = (object) array('guid' => 10, 'url' => '', 'entity_type' => 'node', 'entity_id' => $parent->nid, 'feed_nid' => 0, 'id' => 'node_importer');
     drupal_write_record('feeds_item', $item);
 }
 /**
  * Insert the record in the database.
  */
 public function insert($options = array())
 {
     if (!empty($this->label_id)) {
         // This is supposed to be a new branch, but has a label_id already.
         throw new Exception('Attempted to insert a Versioncontrol branch which is already present in the database.', E_ERROR);
     }
     // Append default options.
     $options += $this->defaultCrudOptions['insert'];
     // Make sure repository id is set for drupal_write_record().
     if (empty($this->repo_id)) {
         $this->repo_id = $this->repository->repo_id;
     }
     drupal_write_record('versioncontrol_labels', $this);
     $this->backendInsert($options);
     // Everything's done, invoke the hook.
     module_invoke_all('versioncontrol_entity_branch_insert', $this);
     return $this;
 }
 /**
  * Save a scheduled transition. If the transition is executed, save as logged transition.
  */
 public function save()
 {
     // If executed, save as logged transition.
     if ($this->is_executed) {
         return parent::save();
     }
     // Avoid duplicate entries.
     $this->delete();
     // Save (insert or update) a record to the database based upon the schema.
     drupal_write_record('workflow_scheduled_transition', $this);
     // Get name of state.
     if ($state = WorkflowState::load($this->new_sid)) {
         $message = '@entity_title scheduled for state change to %state_name on %scheduled_date';
         $args = array('@entity_type' => $this->entity_type, '@entity_title' => $this->entity->title, '%state_name' => $state->label(), '%scheduled_date' => format_date($this->scheduled));
         $uri = entity_uri($this->entity_type, $this->entity);
         watchdog('workflow', $message, $args, WATCHDOG_NOTICE, l('view', $uri['path'] . '/workflow'));
         drupal_set_message(t($message, $args));
     }
 }