From 625455b53b0fd13cc9b154bf53a49bd871b6d23a Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 14 Oct 2001 15:27:00 +0000 Subject: [PATCH] - I tidied up most SQL tables to be more consistent with the rest of the tables: I changed all "id"s to "xid"s where "x" is the first letter of the table name. I also renamed all remaining "userid"s to "uid"s as I mentioned I would do. Take a look at ./drupal/updates/3.00-to-x.xx.sql for the MySQL updates. --- includes/common.inc | 2 +- includes/theme.inc | 2 +- modules/locale.module | 29 ++++++++++++++--------------- modules/locale/locale.module | 29 ++++++++++++++--------------- modules/rating.module | 4 ++-- modules/watchdog.module | 6 +++--- modules/watchdog/watchdog.module | 6 +++--- updates/3.00-to-x.xx.sql | 8 ++++++++ 8 files changed, 46 insertions(+), 40 deletions(-) diff --git a/includes/common.inc b/includes/common.inc index 594140a5427..644e453c775 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -34,7 +34,7 @@ function error_handler($errno, $message, $filename, $line, $variables) { function watchdog($type, $message) { global $user; - db_query("INSERT INTO watchdog (userid, type, message, location, hostname, timestamp) VALUES ('$user->uid', '". check_input($type) ."', '". check_input($message) ."', '". check_input(getenv("REQUEST_URI")) ."', '". check_input(getenv("REMOTE_ADDR")) ."', '". time() ."')"); + db_query("INSERT INTO watchdog (uid, type, message, location, hostname, timestamp) VALUES ('$user->uid', '". check_input($type) ."', '". check_input($message) ."', '". check_input(getenv("REQUEST_URI")) ."', '". check_input(getenv("REMOTE_ADDR")) ."', '". time() ."')"); } function throttle($type, $rate) { diff --git a/includes/theme.inc b/includes/theme.inc index 5a01e0a915e..ac6b5cf86da 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -99,7 +99,7 @@ function theme_blocks($region, &$theme) { break; case "/index.php": - if ($user->uid) $result = db_query("SELECT * FROM blocks b LEFT JOIN layout l ON b.name = l.block WHERE (b.status = 2 OR (b.status = 1 AND l.userid = '$user->uid'))". (($region == "left" OR $region == "right") ? ($region == "left" ? " AND b.region = 0" : " AND b.region = 1") : "") ." ORDER BY weight"); + if ($user->uid) $result = db_query("SELECT * FROM blocks b LEFT JOIN layout l ON b.name = l.block WHERE (b.status = 2 OR (b.status = 1 AND l.uid = '$user->uid'))". (($region == "left" OR $region == "right") ? ($region == "left" ? " AND b.region = 0" : " AND b.region = 1") : "") ." ORDER BY weight"); else $result = db_query("SELECT * FROM blocks WHERE status = 2". (($region == "left" OR $region == "right") ? ($region == "left" ? " AND region = 0" : " AND region = 1") : "") ." ORDER BY weight"); while ($result && ($block = db_fetch_object($result))) { $blocks = module_invoke($block->module, "block"); diff --git a/modules/locale.module b/modules/locale.module index abfea68d47c..c363e64a725 100644 --- a/modules/locale.module +++ b/modules/locale.module @@ -50,23 +50,22 @@ function locale_conf_options() { return form_select("Locale support", "locale", variable_get("locale", 0), array("Disabled", "Enabled"), "Disable locale support if your site does not require translation or internationalization support."); } -function locale_delete($id) { - db_query("DELETE FROM locales WHERE id = '$id'"); +function locale_delete($lid) { + db_query("DELETE FROM locales WHERE lid = '$lid'"); } -function locale_save($id, $edit) { +function locale_save($lid, $edit) { foreach ($edit as $key=>$value) { - db_query("UPDATE locales SET $key = '". check_input($value) ."' WHERE id = '$id'"); + db_query("UPDATE locales SET $key = '". check_input($value) ."' WHERE lid = '$lid'"); } } -function locale_edit($id) { +function locale_edit($lid) { global $languages; - $result = db_query("SELECT * FROM locales WHERE id = '$id'"); + $result = db_query("SELECT * FROM locales WHERE lid = '$lid'"); if ($translation = db_fetch_object($result)) { $form .= form_item(t("Original text"), "
". wordwrap(check_output($translation->string)) ."
"); foreach ($languages as $code=>$language) $form .= (strlen($translation->string) > 30) ? form_textarea($language, $code, $translation->$code, 50, 10) : form_textfield($language, $code, $translation->$code, 50, 128); - $form .= form_hidden("id", $id); $form .= form_submit("Save translations"); return form($form); @@ -104,7 +103,7 @@ function locale_overview() { $output .= "\n"; $output .= " \n"; while ($locale = db_fetch_object($result)) { - $output .= " "; + $output .= " "; } $output .= "
stringlanguagesoperations
". check_output($locale->string) ."
". check_output($locale->location) ."
". check_output(locale_languages($locale)) ."id\">edit localeid\">delete locale
". check_output($locale->string) ."
". check_output($locale->location) ."
". check_output(locale_languages($locale)) ."lid\">edit localelid\">delete locale
\n"; @@ -117,7 +116,7 @@ function locale_translated($language) { $output .= "\n"; $output .= " \n"; while ($locale = db_fetch_object($result)) { - $output .= " "; + $output .= " "; } $output .= "
original stringtranslated stringoperations
". check_output($locale->string) ."". check_output($locale->$language) ."id\"> edit localeid\">delete locale
". check_output($locale->string) ."". check_output($locale->$language) ."lid\"> edit localelid\">delete locale
\n"; @@ -130,7 +129,7 @@ function locale_untranslated($language) { $output .= "\n"; $output .= " \n"; while ($locale = db_fetch_object($result)) { - $output .= " "; + $output .= " "; } $output .= "
stringoperations
". check_output($locale->string) ."
$locale->location
id\"> edit localeid\">delete locale
". check_output($locale->string) ."
$locale->location
lid\"> edit localelid\">delete locale
\n"; @@ -138,9 +137,9 @@ function locale_untranslated($language) { } function locale_seek() { - global $edit, $languages, $op, $locale_settings; + global $id, $edit, $languages, $op, $locale_settings; - if ($edit[id] && session_is_registered("locale_settings")) { + if (session_is_registered("locale_settings")) { $edit = $locale_settings; } @@ -173,7 +172,7 @@ function locale_seek() { $output .= "\n"; $output .= " \n"; while ($locale = db_fetch_object($result)) { - $output .= " "; + $output .= " "; } $output .= "
stringlanguagesoperations
". check_output($locale->string) ."
". check_output($locale->location) ."
". check_output(locale_languages($locale)) ."id\">edit localeid\">delete locale
". check_output($locale->string) ."
". check_output($locale->location) ."
". check_output(locale_languages($locale)) ."lid\">edit localelid\">delete locale
\n"; } @@ -232,11 +231,11 @@ function locale_admin() { function locale($string) { global $locale; if (variable_get("locale", 0)) { - $result = db_query("SELECT id, $locale FROM locales WHERE STRCMP(string, '". addslashes($string) ."') = 0"); + $result = db_query("SELECT lid, $locale FROM locales WHERE STRCMP(string, '". addslashes($string) ."') = 0"); if ($translation = db_fetch_object($result)) $string = ($translation->$locale) ? check_output($translation->$locale) : $string; else db_query("INSERT INTO locales (string, location) VALUES ('". addslashes($string) ."', '". check_input(getenv("REQUEST_URI")) ."')"); } return $string; } -?> \ No newline at end of file +?> diff --git a/modules/locale/locale.module b/modules/locale/locale.module index abfea68d47c..c363e64a725 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -50,23 +50,22 @@ function locale_conf_options() { return form_select("Locale support", "locale", variable_get("locale", 0), array("Disabled", "Enabled"), "Disable locale support if your site does not require translation or internationalization support."); } -function locale_delete($id) { - db_query("DELETE FROM locales WHERE id = '$id'"); +function locale_delete($lid) { + db_query("DELETE FROM locales WHERE lid = '$lid'"); } -function locale_save($id, $edit) { +function locale_save($lid, $edit) { foreach ($edit as $key=>$value) { - db_query("UPDATE locales SET $key = '". check_input($value) ."' WHERE id = '$id'"); + db_query("UPDATE locales SET $key = '". check_input($value) ."' WHERE lid = '$lid'"); } } -function locale_edit($id) { +function locale_edit($lid) { global $languages; - $result = db_query("SELECT * FROM locales WHERE id = '$id'"); + $result = db_query("SELECT * FROM locales WHERE lid = '$lid'"); if ($translation = db_fetch_object($result)) { $form .= form_item(t("Original text"), "
". wordwrap(check_output($translation->string)) ."
"); foreach ($languages as $code=>$language) $form .= (strlen($translation->string) > 30) ? form_textarea($language, $code, $translation->$code, 50, 10) : form_textfield($language, $code, $translation->$code, 50, 128); - $form .= form_hidden("id", $id); $form .= form_submit("Save translations"); return form($form); @@ -104,7 +103,7 @@ function locale_overview() { $output .= "\n"; $output .= " \n"; while ($locale = db_fetch_object($result)) { - $output .= " "; + $output .= " "; } $output .= "
stringlanguagesoperations
". check_output($locale->string) ."
". check_output($locale->location) ."
". check_output(locale_languages($locale)) ."id\">edit localeid\">delete locale
". check_output($locale->string) ."
". check_output($locale->location) ."
". check_output(locale_languages($locale)) ."lid\">edit localelid\">delete locale
\n"; @@ -117,7 +116,7 @@ function locale_translated($language) { $output .= "\n"; $output .= " \n"; while ($locale = db_fetch_object($result)) { - $output .= " "; + $output .= " "; } $output .= "
original stringtranslated stringoperations
". check_output($locale->string) ."". check_output($locale->$language) ."id\"> edit localeid\">delete locale
". check_output($locale->string) ."". check_output($locale->$language) ."lid\"> edit localelid\">delete locale
\n"; @@ -130,7 +129,7 @@ function locale_untranslated($language) { $output .= "\n"; $output .= " \n"; while ($locale = db_fetch_object($result)) { - $output .= " "; + $output .= " "; } $output .= "
stringoperations
". check_output($locale->string) ."
$locale->location
id\"> edit localeid\">delete locale
". check_output($locale->string) ."
$locale->location
lid\"> edit localelid\">delete locale
\n"; @@ -138,9 +137,9 @@ function locale_untranslated($language) { } function locale_seek() { - global $edit, $languages, $op, $locale_settings; + global $id, $edit, $languages, $op, $locale_settings; - if ($edit[id] && session_is_registered("locale_settings")) { + if (session_is_registered("locale_settings")) { $edit = $locale_settings; } @@ -173,7 +172,7 @@ function locale_seek() { $output .= "\n"; $output .= " \n"; while ($locale = db_fetch_object($result)) { - $output .= " "; + $output .= " "; } $output .= "
stringlanguagesoperations
". check_output($locale->string) ."
". check_output($locale->location) ."
". check_output(locale_languages($locale)) ."id\">edit localeid\">delete locale
". check_output($locale->string) ."
". check_output($locale->location) ."
". check_output(locale_languages($locale)) ."lid\">edit localelid\">delete locale
\n"; } @@ -232,11 +231,11 @@ function locale_admin() { function locale($string) { global $locale; if (variable_get("locale", 0)) { - $result = db_query("SELECT id, $locale FROM locales WHERE STRCMP(string, '". addslashes($string) ."') = 0"); + $result = db_query("SELECT lid, $locale FROM locales WHERE STRCMP(string, '". addslashes($string) ."') = 0"); if ($translation = db_fetch_object($result)) $string = ($translation->$locale) ? check_output($translation->$locale) : $string; else db_query("INSERT INTO locales (string, location) VALUES ('". addslashes($string) ."', '". check_input(getenv("REQUEST_URI")) ."')"); } return $string; } -?> \ No newline at end of file +?> diff --git a/modules/rating.module b/modules/rating.module index 062f89f5b03..dd00aafb90d 100644 --- a/modules/rating.module +++ b/modules/rating.module @@ -39,7 +39,7 @@ function rating_cron() { $r2 = db_query("SELECT uid FROM users ORDER BY rating DESC"); while ($account = db_fetch_object($r2)) { - db_query("INSERT INTO rating (userid, new, old) VALUES ('$account->uid', '". ++$j ."', '". $rating[$account->uid] ."')"); + db_query("INSERT INTO rating (uid, new, old) VALUES ('$account->uid', '". ++$j ."', '". $rating[$account->uid] ."')"); } } } @@ -81,7 +81,7 @@ function rating_gravity($id) { } function rating_list($limit) { - $result = db_query("SELECT u.rating, u.name, u.uid, r.* FROM users u LEFT JOIN rating r ON u.uid = r.userid ORDER BY u.rating DESC LIMIT $limit"); + $result = db_query("SELECT u.rating, u.name, u.uid, r.* FROM users u LEFT JOIN rating r ON u.uid = r.uid ORDER BY u.rating DESC LIMIT $limit"); $output .= "\n"; while ($account = db_fetch_object($result)) { diff --git a/modules/watchdog.module b/modules/watchdog.module index a98ebb55066..ad7724030bf 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -33,13 +33,13 @@ function watchdog_overview($type) { $color = array(user => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C"); $query = array(user => "WHERE type = 'user'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'"); - $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.userid = u.uid ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000"); + $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000"); $output .= "
\n"; $output .= " \n"; while ($watchdog = db_fetch_object($result)) { if ($background = $color[$watchdog->type]) { - $output .= " \n"; + $output .= " \n"; } } $output .= "
datemessageuseroperations
". format_date($watchdog->timestamp, "small") ."". substr(check_output($watchdog->message), 0, 64) ."". format_name($watchdog) ."id\">details
". format_date($watchdog->timestamp, "small") ."". substr(check_output($watchdog->message), 0, 64) ."". format_name($watchdog) ."wid\">details
\n"; @@ -48,7 +48,7 @@ function watchdog_overview($type) { } function watchdog_view($id) { - $result = db_query("SELECT l.*, u.name, u.uid FROM watchdog l LEFT JOIN users u ON l.userid = u.uid WHERE l.id = '$id'"); + $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid WHERE w.wid = '$id'"); if ($watchdog = db_fetch_object($result)) { $output .= "\n"; diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index a98ebb55066..ad7724030bf 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -33,13 +33,13 @@ function watchdog_overview($type) { $color = array(user => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C"); $query = array(user => "WHERE type = 'user'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'"); - $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.userid = u.uid ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000"); + $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000"); $output .= "
\n"; $output .= " \n"; while ($watchdog = db_fetch_object($result)) { if ($background = $color[$watchdog->type]) { - $output .= " \n"; + $output .= " \n"; } } $output .= "
datemessageuseroperations
". format_date($watchdog->timestamp, "small") ."". substr(check_output($watchdog->message), 0, 64) ."". format_name($watchdog) ."id\">details
". format_date($watchdog->timestamp, "small") ."". substr(check_output($watchdog->message), 0, 64) ."". format_name($watchdog) ."wid\">details
\n"; @@ -48,7 +48,7 @@ function watchdog_overview($type) { } function watchdog_view($id) { - $result = db_query("SELECT l.*, u.name, u.uid FROM watchdog l LEFT JOIN users u ON l.userid = u.uid WHERE l.id = '$id'"); + $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid WHERE w.wid = '$id'"); if ($watchdog = db_fetch_object($result)) { $output .= "\n"; diff --git a/updates/3.00-to-x.xx.sql b/updates/3.00-to-x.xx.sql index a905bf27d1a..9d29dfb03c0 100644 --- a/updates/3.00-to-x.xx.sql +++ b/updates/3.00-to-x.xx.sql @@ -55,3 +55,11 @@ ALTER TABLE watchdog CHANGE user userid int(10) DEFAULT '0' NOT NULL; ALTER TABLE rating CHANGE user userid int(10) DEFAULT '0' NOT NULL; ALTER TABLE layout CHANGE user userid int(10) DEFAULT '0' NOT NULL; ALTER TABLE blocks CHANGE offset delta tinyint(2) DEFAULT '0' NOT NULL; + +# 14/10/01 + +ALTER TABLE watchdog CHANGE id wid int(5) DEFAULT '0' NOT NULL auto_increment; +ALTER TABLE watchdog CHANGE userid uid int(10) DEFAULT '0' NOT NULL; +ALTER TABLE layout CHANGE userid uid int(10) DEFAULT '0' NOT NULL; +ALTER TABLE rating CHANGE userid uid int(10) DEFAULT '0' NOT NULL; +ALTER TABLE locales CHANGE id lid int(10) DEFAULT '0' NOT NULL;