From 6f02738cc2ca88d01d541b9b81cc7cf860980c33 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 16 May 2001 20:54:37 +0000 Subject: - Removed the "history"-field from the SQL table "users" and added this information to the "users"-field in both nodes and comments. This database/table change reduces the number of SQL queries and makes Drupal scale better where a lot of voting/moderation takes place. Last but not least it can be considered a new and better foundation for future moderation metrics / algorithms. In other words: it is plain better. --> oops, all voting/moderation results will be lost! --> requires database update, see "2.00-to-x.xx.sql"! - Updated database/database.mysql --- includes/common.inc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'includes/common.inc') diff --git a/includes/common.inc b/includes/common.inc index 0a24fc927..5ca31bf36 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -199,6 +199,43 @@ function form_submit($value) { return "\n"; } +function field_get($object, $variable, $field) { + $data = explode(";", $object->$variable); + for (reset($data); current($data); next($data)) { + $entry = explode(":", current($data)); + if (reset($entry) == $field) $rval = end($entry); + } + return $rval; +} + +function field_set($object, $variable, $name, $value) { + $field = $object->$variable; + + if (!$value) { + // remove entry: + $data = explode(";", $field); + for (reset($data); current($data); next($data)) { + $entry = explode(":", current($data)); + if ($entry[0] != $name) $rval .= "$entry[0]:$entry[1];"; + } + } + else if (strstr($field, "$name:")) { + // found: update exsisting entry: + $data = explode(";", $field); + for (reset($data); current($data); next($data)) { + $entry = explode(":", current($data)); + if ($entry[0] == $name) $entry[1] = $value; + $rval .= "$entry[0]:$entry[1];"; + } + } + else { + // not found: + $rval = "$field$name:$value;"; + } + + return $rval; +} + $conf = conf_init(); include_once "includes/$conf.php"; -- cgit v1.2.3