ttOrgImportHelper class impoved to output conflicting login names.
[timetracker.git] / WEB-INF / lib / ttConfigHelper.class.php
index 95cd121..20af19a 100644 (file)
@@ -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);