summaryrefslogtreecommitdiff
path: root/lib/plugins/config/settings/config.class.php
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2010-11-30 18:27:04 +0100
committerMichael Hamann <michael@content-space.de>2010-11-30 18:38:11 +0100
commit38dc5fa6df9a0cd5afd16dc95600d7cf11b08877 (patch)
tree3286648c8b6cbc72cf8475c8453ad93689b59196 /lib/plugins/config/settings/config.class.php
parent75291d1adf94c43d47ac62994badb5591b52e0b5 (diff)
downloadrpg-38dc5fa6df9a0cd5afd16dc95600d7cf11b08877.tar.gz
rpg-38dc5fa6df9a0cd5afd16dc95600d7cf11b08877.tar.bz2
Added min and max options for configuration metadata
Diffstat (limited to 'lib/plugins/config/settings/config.class.php')
-rw-r--r--lib/plugins/config/settings/config.class.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php
index 4f2129c70..252bc79a9 100644
--- a/lib/plugins/config/settings/config.class.php
+++ b/lib/plugins/config/settings/config.class.php
@@ -618,6 +618,24 @@ if (!class_exists('setting_numeric')) {
// much more restrictive, but should eliminate syntax errors.
var $_pattern = '/^[-]?[0-9]+(?:[-+*][0-9]+)*$/';
//FIXME - make the numeric error checking better.
+ var $_min = null;
+ var $_max = null;
+
+ function update($input) {
+ $local = $this->_local;
+ $valid = parent::update($input);
+ if ($valid && !(is_null($this->_min) && is_null($this->_max))) {
+ $numeric_local = (int) eval('return '.$this->_local.';');
+ if ((!is_null($this->_min) && $numeric_local < $this->_min) ||
+ (!is_null($this->_max) && $numeric_local > $this->_max)) {
+ $this->_error = true;
+ $this->_input = $input;
+ $this->_local = $local;
+ $valid = false;
+ }
+ }
+ return $valid;
+ }
function out($var, $fmt='php') {