本文整理汇总了PHP中drupal_write_record函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_write_record函数的具体用法?PHP drupal_write_record怎么用?PHP drupal_write_record使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drupal_write_record函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* @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;
}
}
示例2: hook_invite_accept
/**
* 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);
}
示例3: save
/**
* 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();
}
示例4: testDiv
/**
* 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'));
}
示例5: save
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;
}
示例6: os_poker_set_application_default_settings
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'));
}
}
示例7: iShouldSeeAValidCatalogXml
/**
* @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.'));
}
}
示例8: hook_menu_node_update
/**
* 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'));
}
示例9: save
/**
* 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'));
}
}
示例10: save
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});
}
}
示例11: setUpBeforeClass
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();
}
示例12: save
/**
* {@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);
}
}
示例13: save
/**
* 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;
}
示例14: save
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);
}
示例15: osha_update_webform_captcha
/**
* 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);
}
}