summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-05-30 07:11:08 +0000
committerDries Buytaert <dries@buytaert.net>2009-05-30 07:11:08 +0000
commit79c566c7107012dffa4caea1f8b440d3bff791a6 (patch)
tree8a4ae07e1879b28505f2f0c9a1fcf1c404aae2cd
parent39877809cc20d58b4ac60c5d1949b33e38eb105b (diff)
downloadbrdo-79c566c7107012dffa4caea1f8b440d3bff791a6.tar.gz
brdo-79c566c7107012dffa4caea1f8b440d3bff791a6.tar.bz2
- Patch #476928 by Berdir: more database abstraction layer conversions.
-rw-r--r--modules/filter/filter.admin.inc23
1 files changed, 16 insertions, 7 deletions
diff --git a/modules/filter/filter.admin.inc b/modules/filter/filter.admin.inc
index 246c1d787..f8d87b972 100644
--- a/modules/filter/filter.admin.inc
+++ b/modules/filter/filter.admin.inc
@@ -184,7 +184,7 @@ function filter_admin_format_form(&$form_state, $format) {
function filter_admin_format_form_validate($form, &$form_state) {
if (!isset($form_state['values']['format'])) {
$name = trim($form_state['values']['name']);
- $result = db_fetch_object(db_query("SELECT format FROM {filter_format} WHERE name='%s'", $name));
+ $result = db_query("SELECT format FROM {filter_format} WHERE name = :name", array(':name' => $name))->fetchField();
if ($result) {
form_set_error('name', t('Text format names must be unique. A format named %name already exists.', array('%name' => $name)));
}
@@ -203,25 +203,34 @@ function filter_admin_format_form_submit($form, &$form_state) {
// Add a new text format.
if (!$format) {
$new = TRUE;
- db_query("INSERT INTO {filter_format} (name) VALUES ('%s')", $name);
- $format = db_result(db_query("SELECT MAX(format) AS format FROM {filter_format}"));
+ db_insert('filter_format')
+ ->fields(array('name' => $name))
+ ->execute();
+ $format = db_query("SELECT MAX(format) AS format FROM {filter_format}")->fetchField();
drupal_set_message(t('Added text format %format.', array('%format' => $name)));
}
else {
drupal_set_message(t('The text format settings have been updated.'));
}
-
- db_query("DELETE FROM {filter} WHERE format = %d", $format);
+ db_delete('filter')
+ ->condition('format', $format)
+ ->execute();
+ $query = db_insert('filter')->fields(array('format', 'module', 'delta', 'weight'));
foreach ($form_state['values']['filters'] as $id => $checked) {
if ($checked) {
list($module, $delta) = explode('/', $id);
// Add new filters to the bottom.
$weight = isset($current[$id]->weight) ? $current[$id]->weight : 10;
- db_query("INSERT INTO {filter} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $format, $module, $delta, $weight);
-
+ $query->values(array(
+ 'format' => $format,
+ 'module' => $module,
+ 'delta' => $delta,
+ 'weight' => $weight,
+ ));
// Check if there are any 'no cache' filters.
$cache &= !module_invoke($module, 'filter', 'no cache', $delta);
}
+ $query->execute();
}
// We store the roles as a string for ease of use.