X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/99041558bf625b082fc5058a93e1bd2634c2c9d2..f05a2db179417c20c7d841f0363bca4988c8a2ca:/WEB-INF/lib/ttConfigHelper.class.php 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);