Commit 337b3c9d authored by Dries's avatar Dries

- Committed a slightly modified version of Slavica's table prefix patch.
parent 1c2fc43b
Drupal x.x.x, xxxx-xx-xx (to be released)
------------------------
- database backend:
* added support for database table prefxing.
Drupal 4.2.0, xxxx-xx-xx (to be released)
------------------------
......@@ -69,7 +75,7 @@ Drupal 4.0.0, 2002-06-15
- themes:
* cleaned up the theme system.
* moved themes that are not maintained to contributions CVS repository.
- database abstraction:
- database backend:
* changed to PEAR database abstraction layer.
* using ANSI SQL queries to be more portable.
- rewrote the user system:
......
......@@ -37,12 +37,12 @@ function error_handler($errno, $message, $filename, $line, $variables) {
function watchdog($type, $message, $link = NULL) {
global $user;
db_query("INSERT INTO watchdog (uid, type, message, link, location, hostname, timestamp) VALUES (%d, '%s', '%s', '%s', '%s', '%s', %d)", $user->uid, $type, $message, $link, request_uri(), getenv("REMOTE_ADDR"), time());
db_query("INSERT INTO {watchdog} (uid, type, message, link, location, hostname, timestamp) VALUES (%d, '%s', '%s', '%s', '%s', '%s', %d)", $user->uid, $type, $message, $link, request_uri(), getenv("REMOTE_ADDR"), time());
}
function throttle($type, $rate) {
if (!user_access("access administration pages")) {
if ($throttle = db_fetch_object(db_query("SELECT * FROM watchdog WHERE type = '$type' AND hostname = '". getenv("REMOTE_ADDR") ."' AND ". time() ." - timestamp < $rate"))) {
if ($throttle = db_fetch_object(db_query("SELECT * FROM {watchdog} WHERE type = '$type' AND hostname = '". getenv("REMOTE_ADDR") ."' AND ". time() ." - timestamp < $rate"))) {
watchdog("warning", "throttle: '". getenv("REMOTE_ADDR") ."' exceeded submission rate - $throttle->type");
die(message_throttle());
}
......@@ -169,7 +169,7 @@ function t($string, $args = 0) {
}
function variable_init($conf = array()) {
$result = db_query("SELECT * FROM variable");
$result = db_query("SELECT * FROM {variable} ");
while ($variable = db_fetch_object($result)) {
if (!isset($conf[$variable->name])) {
$conf[$variable->name] = unserialize($variable->value);
......@@ -188,8 +188,8 @@ function variable_get($name, $default) {
function variable_set($name, $value) {
global $conf;
db_query("DELETE FROM variable WHERE name = '%s'", $name);
db_query("INSERT INTO variable (name, value) VALUES ('%s', '%s')", $name, serialize($value));
db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
$conf[$name] = $value;
}
......@@ -197,7 +197,7 @@ function variable_set($name, $value) {
function variable_del($name) {
global $conf;
db_query("DELETE FROM variable WHERE name = '%s'", $name);
db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
unset($conf[$name]);
}
......@@ -490,7 +490,7 @@ function xss_check_input_data($data) {
// check attributes:
$match += preg_match("/\W(dynsrc|datasrc|data|lowsrc|on[a-z]+)\s*=[^>]+?>/i", $data);
// check tags:
$match += preg_match("/<\s*(applet|script|object|style|embed|form|blink|meta|html|frame|iframe|layer|ilayer|head|frameset|xml)/i", $data);
......@@ -703,25 +703,25 @@ function format_size($size) {
}
function cache_get($key) {
$cache = db_fetch_object(db_query("SELECT data, created FROM cache WHERE cid = '%s'", $key));
$cache = db_fetch_object(db_query("SELECT data, created FROM {cache} WHERE cid = '%s'", $key));
return $cache->data ? $cache : 0;
}
function cache_set($cid, $data, $expire = 0) {
if (db_fetch_object(db_query("SELECT cid FROM cache WHERE cid = '%s'", $cid))) {
db_query("UPDATE cache SET data = '%s', created = %d, expire = %d WHERE cid = '%s'", $data, time(), $expire, $cid);
if (db_fetch_object(db_query("SELECT cid FROM {cache} WHERE cid = '%s'", $cid))) {
db_query("UPDATE {cache} SET data = '%s', created = %d, expire = %d WHERE cid = '%s'", $data, time(), $expire, $cid);
}
else {
db_query("INSERT INTO cache (cid, data, created, expire) VALUES('%s', '%s', %d, %d)", $cid, $data, time(), $expire);
db_query("INSERT INTO {cache} (cid, data, created, expire) VALUES('%s', '%s', %d, %d)", $cid, $data, time(), $expire);
}
}
function cache_clear_all($cid = NULL) {
if (empty($cid)) {
db_query("DELETE FROM cache WHERE expire <> 0");
db_query("DELETE FROM {cache} WHERE expire <> 0");
}
else {
db_query("DELETE FROM cache WHERE cid = %d", $cid);
db_query("DELETE FROM {cache} WHERE cid = %d", $cid);
}
}
......
......@@ -15,9 +15,14 @@
# $db_url = "mysql://user:password@hostname/database";
# $db_url = "pgsql://user:password@hostname/database";
# $db_url = "mssql://user:password@hostname/database";
$db_url = "mysql://drupal:drupal@localhost/drupal";
# If $db_prefix is specified all database table names will be
# prepended with this string. Be sure to use valid database
# characters only, usually alphanumeric and underscore. If no
# prefixes are desired, set to empty string "".
$db_prefix = "";
#
# Base URL:
#
......
<?php
// $Id$
function db_prefix_tables($sql) {
global $db_prefix;
return strtr($sql, array("{" => $db_prefix, "}" => ""));
}
$db_type = substr($db_url, 0, strpos($db_url, "://"));
......@@ -11,4 +18,4 @@
db_connect($db_url);
?>
\ No newline at end of file
?>
......@@ -23,6 +23,7 @@ function db_connect($url) {
function db_query($query) {
$args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) {
$args = array_map("check_query", $args);
$args[0] = $query;
......@@ -36,6 +37,7 @@ function db_query($query) {
// debug version
function db_queryd($query) {
$args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) {
$args = array_map("check_query", $args);
$args[0] = $query;
......@@ -111,9 +113,9 @@ function db_next_id($name) {
** when needed
*/
db_query("LOCK TABLES sequences WRITE");
$id = db_result(db_query("SELECT id FROM sequences WHERE name = '%s'", $name)) + 1;
db_query("REPLACE INTO sequences VALUES ('%s', %d)", $name, $id);
db_query("LOCK TABLES {sequences} WRITE");
$id = db_result(db_query("SELECT id FROM {sequences} WHERE name = '%s'", $name)) + 1;
db_query("REPLACE INTO {sequences} VALUES ('%s', %d)", $name, $id);
db_query("UNLOCK TABLES");
return $id;
......@@ -136,11 +138,13 @@ function db_query_range($query) {
$from = array_pop($args);
if (count(func_get_args()) > 3) {
$args = array_map("check_query", $args);
$query = db_prefix_tables($query);
$args[0] = $query;
$query = call_user_func_array("sprintf", $args);
}
else {
$query = func_get_arg(0);
$query = db_prefix_tables($query);
}
$query .= " LIMIT $from, $count";
return _db_query($query);
......
......@@ -25,6 +25,7 @@ function db_connect($url) {
function db_query($query) {
$args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) {
$args = array_map("check_query", $args);
$args[0] = $query;
......@@ -38,6 +39,7 @@ function db_query($query) {
// debug version
function db_queryd($query) {
$args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) {
$args = array_map("check_query", $args);
$args[0] = $query;
......@@ -147,11 +149,14 @@ function db_query_range($query) {
$from = array_pop($args);
if (count(func_get_args()) > 3) {
$args = array_map("check_query", $args);
$query = db_prefix_tables($query);
$args[0] = $query;
$result = $db_handle->limitQuery(call_user_func_array("sprintf", $args), $from, $count);
}
else {
$result = $db_handle->limitQuery(func_get_arg(0), $from, $count);
$query = func_get_arg(0);
$query = db_prefix_tables($query);
$result = $db_handle->limitQuery( $query, $from, $count);
}
if (variable_get("dev_query", 0)) {
......
......@@ -50,7 +50,7 @@ function module_list($refresh = 0) {
if (!$list) {
$list = array("admin" => "admin", "system" => "system", "user" => "user", "watchdog" => "watchdog");
$result = db_query("SELECT name, filename FROM system WHERE type = 'module' AND status = '1' ORDER BY name");
$result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = '1' ORDER BY name");
while ($module = db_fetch_object($result)) {
if (file_exists($module->filename)) {
$list[$module->name] = $module->name;
......
......@@ -84,7 +84,7 @@ function footer() {
print $output;
}
}
} // End of BaseTheme class //
function theme_mark() {
/*
......@@ -130,7 +130,7 @@ function theme_list($refresh = 0) {
if (!$list) {
$list = array();
$result = db_query("SELECT * FROM system where type = 'theme' AND status = '1' ORDER BY name");
$result = db_query("SELECT * FROM {system} where type = 'theme' AND status = '1' ORDER BY name");
while ($theme = db_fetch_object($result)) {
if (file_exists($theme->filename)) {
$list[$theme->name] = $theme;
......@@ -189,7 +189,7 @@ function theme_init() {
function theme_blocks($region) {
global $user;
$result = db_query("SELECT * FROM blocks WHERE (status = '1' OR custom = '1') ". ($region != "all" ? "AND region = %d " : "") ."ORDER BY weight, module", $region == "left" ? 0 : 1);
$result = db_query("SELECT * FROM {blocks} WHERE (status = '1' OR custom = '1') ". ($region != "all" ? "AND region = %d " : "") ."ORDER BY weight, module", $region == "left" ? 0 : 1);
while ($result && ($block = db_fetch_object($result))) {
if ((($block->status && (!$user->uid || !$block->custom)) || ($block->custom && $user->block[$block->module][$block->delta])) && (!$block->path || preg_match($block->path, str_replace("?q=", "", request_uri())))) {
......
......@@ -644,8 +644,9 @@ function parseResponse($data="") {
$xmlrpc_value=new xmlrpcval;
if ($this->debug)
print "<pre>---GOT---\n" . htmlspecialchars($data) .
"\n---END---\n</pre>";
##print "<pre>---GOT---\n" . htmlspecialchars($data) . "\n---END---\n</pre>";
##print "<p>---GOT---\n" . nl2br(htmlspecialchars($data)) . "\n---END---\n</p>";
print "<p>---GOT---\n" . nl2br($data) . "\n---END---\n</p>";
if ($data=="") {
error_log("No response received from server.");
$r=new xmlrpcresp(0, $xmlrpcerr["no_data"],
......
This diff is collapsed.
This diff is collapsed.
......@@ -62,7 +62,7 @@ function archive_calendar($original = 0) {
$next = mktime(23, 59, 59, $month + 1, min(date("t", $nextmonth), $day), $year);
$result = db_query("SELECT created FROM node WHERE status = 1 AND created > $start_of_month AND created < $end_of_month");
$result = db_query("SELECT created FROM {node} WHERE status = 1 AND created > $start_of_month AND created < $end_of_month");
$days_with_posts = array();
while ($day_with_post = db_fetch_object($result)) {
......@@ -223,7 +223,7 @@ function archive_page() {
*/
if ($year && $month && $day) {
$result = db_query_range("SELECT nid FROM node WHERE status = '1' AND created > %d ORDER BY created", $date, 0, 20);
$result = db_query_range("SELECT nid FROM {node} WHERE status = '1' AND created > %d ORDER BY created", $date, 0, 20);
while ($nid = db_fetch_object($result)) {
node_view(node_load(array("nid" => $nid->nid)), 1);
......
......@@ -62,7 +62,7 @@ function archive_calendar($original = 0) {
$next = mktime(23, 59, 59, $month + 1, min(date("t", $nextmonth), $day), $year);
$result = db_query("SELECT created FROM node WHERE status = 1 AND created > $start_of_month AND created < $end_of_month");
$result = db_query("SELECT created FROM {node} WHERE status = 1 AND created > $start_of_month AND created < $end_of_month");
$days_with_posts = array();
while ($day_with_post = db_fetch_object($result)) {
......@@ -223,7 +223,7 @@ function archive_page() {
*/
if ($year && $month && $day) {
$result = db_query_range("SELECT nid FROM node WHERE status = '1' AND created > %d ORDER BY created", $date, 0, 20);
$result = db_query_range("SELECT nid FROM {node} WHERE status = '1' AND created > %d ORDER BY created", $date, 0, 20);
while ($nid = db_fetch_object($result)) {
node_view(node_load(array("nid" => $nid->nid)), 1);
......
......@@ -58,14 +58,14 @@ function block_link($type) {
function block_block($op = "list", $delta = 0) {
if ($op == "list") {
$result = db_query("SELECT bid, title, info FROM boxes ORDER BY title");
$result = db_query("SELECT bid, title, info FROM {boxes} ORDER BY title");
while ($block = db_fetch_object($result)) {
$blocks[$block->bid]["info"] = $block->info;
}
return $blocks;
}
else {
$block = db_fetch_object(db_query("SELECT * FROM boxes WHERE bid = %d", $delta));
$block = db_fetch_object(db_query("SELECT * FROM {boxes} WHERE bid = %d", $delta));
$data["subject"] = $block->title;
$data["content"] = ($block->type == 1) ? eval($block->body) : $block->body;
return $data;
......@@ -75,7 +75,7 @@ function block_block($op = "list", $delta = 0) {
function block_admin_save($edit) {
foreach ($edit as $module => $blocks) {
foreach ($blocks as $delta => $block) {
db_query("UPDATE blocks SET region = %d, status = %d, custom = %d, path = '%s', weight = %d WHERE module = '%s' AND delta = '%s'",
db_query("UPDATE {blocks} SET region = %d, status = %d, custom = %d, path = '%s', weight = %d WHERE module = '%s' AND delta = '%s'",
$block["region"], $block["status"], $block["custom"], $block["path"], $block["weight"], $module, $delta);
}
}
......@@ -91,12 +91,12 @@ function block_admin_save($edit) {
* @access private
*/
function _block_rehash($order_by = array("weight")) {
$result = db_query("SELECT * FROM blocks");
$result = db_query("SELECT * FROM {blocks} ");
while ($old_block = db_fetch_object($result)) {
$old_blocks[$old_block->module][$old_block->delta] = $old_block;
}
db_query("DELETE FROM blocks");
db_query("DELETE FROM {blocks} ");
foreach (module_list() as $module) {
$module_blocks = module_invoke($module, "block", "list");
......@@ -117,7 +117,7 @@ function _block_rehash($order_by = array("weight")) {
}
// reinsert blocks into table
db_query("INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)",
db_query("INSERT INTO {blocks} (module, delta, status, weight, region, path, custom) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)",
$block["module"], $block["delta"], $block["status"], $block["weight"], $block["region"], $block["path"], $block["custom"]);
$blocks[] = $block;
......@@ -161,7 +161,7 @@ function block_admin_display() {
function block_admin_preview() {
$result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 0 ORDER BY weight");
$result = db_query("SELECT * FROM {blocks} WHERE status > 0 AND region = 0 ORDER BY weight");
$lblocks .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
while ($block = db_fetch_object($result)) {
$block_data = module_invoke($block->module, "block", "list");
......@@ -170,7 +170,7 @@ function block_admin_preview() {
}
$lblocks .= "</table>\n";
$result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 1 ORDER BY weight");
$result = db_query("SELECT * FROM {blocks} WHERE status > 0 AND region = 1 ORDER BY weight");
$rblocks .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
while ($block = db_fetch_object($result)) {
$block_data = module_invoke($block->module, "block", "list");
......@@ -186,7 +186,7 @@ function block_admin_preview() {
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">". t("footer") ."</td></tr>\n";
$output .= "</table>\n";
$result = db_query("SELECT * FROM blocks WHERE status > 0 ORDER BY weight");
$result = db_query("SELECT * FROM {blocks} WHERE status > 0 ORDER BY weight");
$blocks .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
while ($block = db_fetch_object($result)) {
$block_data = module_invoke($block->module, "block", "list");
......@@ -213,7 +213,7 @@ function block_admin_preview() {
}
function block_box_get($bid) {
return db_fetch_array(db_query("SELECT * FROM boxes WHERE bid = %d", $bid));
return db_fetch_array(db_query("SELECT * FROM {boxes} WHERE bid = %d", $bid));
}
function block_box_form($edit = array()) {
......@@ -241,18 +241,18 @@ function block_box_save($edit) {
}
if ($edit["bid"]) {
db_query("UPDATE boxes SET title = '%s', body = '%s', info = '%s', type = %d WHERE bid = %d", $edit["title"], $edit["body"], $edit["info"], $edit["type"], $edit["bid"]);
db_query("UPDATE {boxes} SET title = '%s', body = '%s', info = '%s', type = %d WHERE bid = %d", $edit["title"], $edit["body"], $edit["info"], $edit["type"], $edit["bid"]);
return t("the block has been updated.");
}
else {
db_query("INSERT INTO boxes (title, body, info, type) VALUES ('%s', '%s', '%s', %d)", $edit["title"], $edit["body"], $edit["info"], $edit["type"]);
db_query("INSERT INTO {boxes} (title, body, info, type) VALUES ('%s', '%s', '%s', %d)", $edit["title"], $edit["body"], $edit["info"], $edit["type"]);
return t("the new block has been added.");
}
}
function block_box_delete($bid) {
if ($bid) {
db_query("DELETE FROM boxes WHERE bid = %d", $bid);
db_query("DELETE FROM {boxes} WHERE bid = %d", $bid);
return t("the block has been deleted.");
}
}
......@@ -303,7 +303,7 @@ function block_admin() {
function block_user($type, &$edit, &$user) {
switch ($type) {
case "register_form":
$result = db_query("SELECT * FROM blocks WHERE custom = %d ORDER BY module, delta", 1);
$result = db_query("SELECT * FROM {blocks} WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$form .= form_hidden("block][$block->module][$block->delta", $block->status);
......@@ -311,7 +311,7 @@ function block_user($type, &$edit, &$user) {
return $form;
case "edit_form":
$result = db_query("SELECT * FROM blocks WHERE custom = %d ORDER BY module, delta", 1);
$result = db_query("SELECT * FROM {blocks} WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, "block", "list");
......
......@@ -58,14 +58,14 @@ function block_link($type) {
function block_block($op = "list", $delta = 0) {
if ($op == "list") {
$result = db_query("SELECT bid, title, info FROM boxes ORDER BY title");
$result = db_query("SELECT bid, title, info FROM {boxes} ORDER BY title");
while ($block = db_fetch_object($result)) {
$blocks[$block->bid]["info"] = $block->info;
}
return $blocks;
}
else {
$block = db_fetch_object(db_query("SELECT * FROM boxes WHERE bid = %d", $delta));
$block = db_fetch_object(db_query("SELECT * FROM {boxes} WHERE bid = %d", $delta));
$data["subject"] = $block->title;
$data["content"] = ($block->type == 1) ? eval($block->body) : $block->body;
return $data;
......@@ -75,7 +75,7 @@ function block_block($op = "list", $delta = 0) {
function block_admin_save($edit) {
foreach ($edit as $module => $blocks) {
foreach ($blocks as $delta => $block) {
db_query("UPDATE blocks SET region = %d, status = %d, custom = %d, path = '%s', weight = %d WHERE module = '%s' AND delta = '%s'",
db_query("UPDATE {blocks} SET region = %d, status = %d, custom = %d, path = '%s', weight = %d WHERE module = '%s' AND delta = '%s'",
$block["region"], $block["status"], $block["custom"], $block["path"], $block["weight"], $module, $delta);
}
}
......@@ -91,12 +91,12 @@ function block_admin_save($edit) {
* @access private
*/
function _block_rehash($order_by = array("weight")) {
$result = db_query("SELECT * FROM blocks");
$result = db_query("SELECT * FROM {blocks} ");
while ($old_block = db_fetch_object($result)) {
$old_blocks[$old_block->module][$old_block->delta] = $old_block;
}
db_query("DELETE FROM blocks");
db_query("DELETE FROM {blocks} ");
foreach (module_list() as $module) {
$module_blocks = module_invoke($module, "block", "list");
......@@ -117,7 +117,7 @@ function _block_rehash($order_by = array("weight")) {
}
// reinsert blocks into table
db_query("INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)",
db_query("INSERT INTO {blocks} (module, delta, status, weight, region, path, custom) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)",
$block["module"], $block["delta"], $block["status"], $block["weight"], $block["region"], $block["path"], $block["custom"]);
$blocks[] = $block;
......@@ -161,7 +161,7 @@ function block_admin_display() {
function block_admin_preview() {
$result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 0 ORDER BY weight");
$result = db_query("SELECT * FROM {blocks} WHERE status > 0 AND region = 0 ORDER BY weight");
$lblocks .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
while ($block = db_fetch_object($result)) {
$block_data = module_invoke($block->module, "block", "list");
......@@ -170,7 +170,7 @@ function block_admin_preview() {
}
$lblocks .= "</table>\n";
$result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 1 ORDER BY weight");
$result = db_query("SELECT * FROM {blocks} WHERE status > 0 AND region = 1 ORDER BY weight");
$rblocks .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
while ($block = db_fetch_object($result)) {
$block_data = module_invoke($block->module, "block", "list");
......@@ -186,7 +186,7 @@ function block_admin_preview() {
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">". t("footer") ."</td></tr>\n";
$output .= "</table>\n";
$result = db_query("SELECT * FROM blocks WHERE status > 0 ORDER BY weight");
$result = db_query("SELECT * FROM {blocks} WHERE status > 0 ORDER BY weight");
$blocks .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
while ($block = db_fetch_object($result)) {
$block_data = module_invoke($block->module, "block", "list");
......@@ -213,7 +213,7 @@ function block_admin_preview() {
}
function block_box_get($bid) {
return db_fetch_array(db_query("SELECT * FROM boxes WHERE bid = %d", $bid));
return db_fetch_array(db_query("SELECT * FROM {boxes} WHERE bid = %d", $bid));
}
function block_box_form($edit = array()) {
......@@ -241,18 +241,18 @@ function block_box_save($edit) {
}
if ($edit["bid"]) {
db_query("UPDATE boxes SET title = '%s', body = '%s', info = '%s', type = %d WHERE bid = %d", $edit["title"], $edit["body"], $edit["info"], $edit["type"], $edit["bid"]);
db_query("UPDATE {boxes} SET title = '%s', body = '%s', info = '%s', type = %d WHERE bid = %d", $edit["title"], $edit["body"], $edit["info"], $edit["type"], $edit["bid"]);
return t("the block has been updated.");
}
else {
db_query("INSERT INTO boxes (title, body, info, type) VALUES ('%s', '%s', '%s', %d)", $edit["title"], $edit["body"], $edit["info"], $edit["type"]);
db_query("INSERT INTO {boxes} (title, body, info, type) VALUES ('%s', '%s', '%s', %d)", $edit["title"], $edit["body"], $edit["info"], $edit["type"]);
return t("the new block has been added.");
}
}
function block_box_delete($bid) {
if ($bid) {
db_query("DELETE FROM boxes WHERE bid = %d", $bid);
db_query("DELETE FROM {boxes} WHERE bid = %d", $bid);
return t("the block has been deleted.");
}
}
......@@ -303,7 +303,7 @@ function block_admin() {
function block_user($type, &$edit, &$user) {
switch ($type) {
case "register_form":
$result = db_query("SELECT * FROM blocks WHERE custom = %d ORDER BY module, delta", 1);
$result = db_query("SELECT * FROM {blocks} WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$form .= form_hidden("block][$block->module][$block->delta", $block->status);
......@@ -311,7 +311,7 @@ function block_user($type, &$edit, &$user) {
return $form;
case "edit_form":
$result = db_query("SELECT * FROM blocks WHERE custom = %d ORDER BY module, delta", 1);
$result = db_query("SELECT * FROM {blocks} WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, "block", "list");
......
......@@ -91,7 +91,7 @@ function blog_feed_user($uid = 0) {
$account = $user;
}
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n LEFT JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$channel["title"] = $account->name. "'s blog";
$channel["link"] = url("blog/view/$uid");
$channel["description"] = $term->description;
......@@ -99,7 +99,7 @@ function blog_feed_user($uid = 0) {
}
function blog_feed_last() {
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 15);
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n LEFT JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 15);
$channel["title"] = variable_get("site_name", "drupal") ." blogs";
$channel["link"] = url("blog");
$channel["description"] = $term->description;
......@@ -116,7 +116,7 @@ function blog_page_user($uid = 0) {
$account = $user;
}
$result = pager_query("SELECT nid FROM node WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
node_view(node_load(array("nid" => $node->nid)), 1);
}
......@@ -127,7 +127,7 @@ function blog_page_user($uid = 0) {
function blog_page_last() {
global $user;
$result = pager_query("SELECT nid FROM node WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
$output = node_view(node_load(array("nid" => $node->nid)), 1);
......@@ -157,7 +157,7 @@ function blog_form(&$node, &$help, &$error) {
$node->body = "<i>". $blog->body ."</i> [". l($blog->name, "node/view/$nid") ."]";
}
if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = %d AND i.fid = f.fid", $iid))) {
if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM {item} i, {feed} f WHERE i.iid = %d AND i.fid = f.fid", $iid))) {
$node->title = $item->title;
$node->body = "<a href=\"$item->link\">$item->title</a> - <i>". check_output($item->description) ."</i> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
}
......@@ -250,7 +250,7 @@ function blog_block($op = "list", $delta = 0) {
}
else {
if (user_access("access content")) {
$block["content"] = node_title_list(db_query_range("SELECT n.title, n.nid FROM node n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10));
$block["content"] = node_title_list(db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10));
$block["content"] .= "<div align=\"right\" id=\"blog_more\">". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."</div>";
$block["subject"] = t("Blogs");
}
......
......@@ -91,7 +91,7 @@ function blog_feed_user($uid = 0) {
$account = $user;
}
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n LEFT JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$channel["title"] = $account->name. "'s blog";
$channel["link"] = url("blog/view/$uid");
$channel["description"] = $term->description;
......@@ -99,7 +99,7 @@ function blog_feed_user($uid = 0) {
}
function blog_feed_last() {
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 15);
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n LEFT JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 15);
$channel["title"] = variable_get("site_name", "drupal") ." blogs";
$channel["link"] = url("blog");
$channel["description"] = $term->description;
......@@ -116,7 +116,7 @@ function blog_page_user($uid = 0) {
$account = $user;