X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttConfigHelper.class.php;h=20af19ad0fbee07952d094712cace8859d3a95cd;hb=a48e5ff4ad629b551f6a94143a5e9d0f235b1953;hp=95cd12186c4967f8b875adb0f79c186ebb726663;hpb=99041558bf625b082fc5058a93e1bd2634c2c9d2;p=timetracker.git diff --git a/WEB-INF/lib/ttConfigHelper.class.php b/WEB-INF/lib/ttConfigHelper.class.php index 95cd1218..20af19ad 100644 --- a/WEB-INF/lib/ttConfigHelper.class.php +++ b/WEB-INF/lib/ttConfigHelper.class.php @@ -44,7 +44,28 @@ class ttConfigHelper { // getDefinedValue determines if a value identified by name is defined. function getDefinedValue($name) { - return in_array($name, $this->$config_array); + return in_array($name, $this->config_array); + } + + // setDefinedValue either sets or deletes a defined value identified by name. + function setDefinedValue($name, $set = true) { + if ($set) { + // Setting part. + if (!$this->getDefinedValue($name)) { + $this->config_array[] = $name; + $this->config = implode(',', $this->config_array); + return; + } + } else { + // Deleting part. + foreach ($this->config_array as $key => $value) { + if ($value === $name) { + unset($this->config_array[$key]); + $this->config = implode(',', $this->config_array); + return; + } + } + } } // The getIntValue parses an integer value from the source config string. @@ -73,12 +94,11 @@ class ttConfigHelper { foreach ($this->config_array as $key => $unparsed_value) { if (substr($unparsed_value, 0, $len) === $name_with_colon) { // Found an already existing value. - // Remove value if our new value is NULL. if ($value !== null) { // Replace value. $this->config_array[$key] = $name.':'.$value; } else { - // Remove value. + // Remove value if our new value is NULL. unset($this->config_array[$key]); } $this->config = implode(',', $this->config_array);