X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttConfigHelper.class.php;h=20af19ad0fbee07952d094712cace8859d3a95cd;hb=7faef0e6d81444ad3ae10d1a2ce62fa753c80a9f;hp=b33734c8197c7f89b2850140a730d0d1b1b3361e;hpb=6968ef66a0264c35eff9bdd8ed92af48b34b8d19;p=timetracker.git diff --git a/WEB-INF/lib/ttConfigHelper.class.php b/WEB-INF/lib/ttConfigHelper.class.php index b33734c8..20af19ad 100644 --- a/WEB-INF/lib/ttConfigHelper.class.php +++ b/WEB-INF/lib/ttConfigHelper.class.php @@ -47,6 +47,27 @@ class ttConfigHelper { 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. function getIntValue($name) { $name_with_colon = $name.':'; @@ -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);