summaryrefslogtreecommitdiff
path: root/includes/variable.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-04-06 14:14:16 +0000
committerDries Buytaert <dries@buytaert.net>2001-04-06 14:14:16 +0000
commit8213f5b2627a6b63db9f84b572918bd7e3254dff (patch)
treebdaa19d917ce2d0db1ba54ef884e22a69130846a /includes/variable.inc
parent048664f2786fce9bd049f39eea39a2a7fe2868f0 (diff)
downloadbrdo-8213f5b2627a6b63db9f84b572918bd7e3254dff.tar.gz
brdo-8213f5b2627a6b63db9f84b572918bd7e3254dff.tar.bz2
A lot of small changes (search-n-replace) make a big commit:
- fixed update bug in book.module - provide a log message when both adding and updating book pages - all configurable variables are now accessed through "variable_get()": - rewrote watchdog and submission throttle and removed watchdog.inc - improved robustness of sections.inc - imporved story.module - updated ./database/database.sql
Diffstat (limited to 'includes/variable.inc')
-rw-r--r--includes/variable.inc54
1 files changed, 54 insertions, 0 deletions
diff --git a/includes/variable.inc b/includes/variable.inc
new file mode 100644
index 000000000..20beb5efd
--- /dev/null
+++ b/includes/variable.inc
@@ -0,0 +1,54 @@
+<?php
+
+function variable_init($conf = array()) {
+ $result = db_query("SELECT * FROM variable");
+ while ($variable = db_fetch_object($result)) $conf[$variable->name] = $variable->value;
+ return $conf;
+}
+
+function handler_post_threshold($node, $default) {
+ if ($node->type) {
+ $function = $node->type ."_post_threshold";
+ return $function($node, $default);
+ }
+ else {
+ return $default;
+ }
+}
+
+function handler_dump_threshold($node, $default) {
+ if ($node->type) {
+ $function = $node->type ."_dump_threshold";
+ return $function($node, $default);
+ }
+ else {
+ return $default;
+ }
+}
+
+function handler_timout_threshold($node, $default) {
+ if ($node->type) {
+ $function = $node->type ."_timout_threshold";
+ return $function($node, $default);
+ }
+ else {
+ return $default;
+ }
+}
+
+function variable_get($name, $default, $object = 0) {
+ global $conf;
+
+ switch ($name) {
+ case "post_threshold":
+ return handler_post_threshold($object, $default);
+ case "dump_threshold":
+ return handler_dump_threshold($object, $default);
+ case "timout_threshold":
+ return handler_timout_threshold($object, $default);
+ default:
+ return ($conf[$name] ? $conf[$name] : $default);
+ }
+}
+
+?> \ No newline at end of file