summaryrefslogtreecommitdiff
path: root/includes/common.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-05-16 20:54:37 +0000
committerDries Buytaert <dries@buytaert.net>2001-05-16 20:54:37 +0000
commit6f02738cc2ca88d01d541b9b81cc7cf860980c33 (patch)
tree81ef242e0ae747e1715142dd370450bbed651ceb /includes/common.inc
parent0b13183e097ae941db44a52b5ce5dc97faef99c2 (diff)
downloadbrdo-6f02738cc2ca88d01d541b9b81cc7cf860980c33.tar.gz
brdo-6f02738cc2ca88d01d541b9b81cc7cf860980c33.tar.bz2
- 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
Diffstat (limited to 'includes/common.inc')
-rw-r--r--includes/common.inc37
1 files changed, 37 insertions, 0 deletions
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 "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". check_textfield($value) ."\">\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";