Code

Updated migration process
[gosa.git] / gosa-core / include / class_configRegistry.inc
index fb78771d4361503c9a73ffbdaa2c7b0f68f7f34c..d2c71a5946dadc093e145ef78618a49b79bb6d5b 100644 (file)
@@ -50,6 +50,20 @@ class configRegistry{
             }
         }
 
+        // Search for config flags defined in the config file (MENU section)
+        foreach($this->config->data['MENU'] as $section => $entries){
+            foreach($entries as $entry){
+                if(count($entry) > 2 && isset($entry['CLASS'])){
+                    $class = $entry['CLASS'];
+                    foreach($entry as $name => $value){
+                        if(!in_array($name, array('CLASS','ACL'))){
+                            $this->fileStoredProperties[strtolower($class)][strtolower($name)] = $value;
+                        }
+                    }
+                }
+            }
+        }
+
         // Search for config flags defined in the config file (MAIN section)
         foreach($this->config->data['MAIN'] as $name => $value){
             $this->fileStoredProperties['core'][strtolower($name)] = $value;
@@ -237,23 +251,24 @@ class gosaProperty
         // Initialize with the current value
         $this->_restoreCurrentValue(); 
 
+    }
+
+    function migrationRequired()
+    {
         // Instantiate migration class 
-        if(!empty($this->migrate)){
+        if(!empty($this->migrate) && $this->migrationClass == NULL){
             if(!class_available($this->migrate)){
                 trigger_error("Cannot start migration for gosaProperty::'{$this->getName()}' class not found ({$this->migrate})!");
             }else{
                 $class = $this->migrate;
-                $tmp = new $class($this);
+                $tmp = new $class($this->parent->config,$this);
                 if(! $tmp instanceof propertyMigration){ 
                     trigger_error("Cannot start migration for gosaProperty::'{$this->getName()}' doesn't implement propertyMigration!");
+                }else{
+                    $this->migrationClass = $tmp;
                 }
-                $this->migrationClass = $tmp;
             }
         }
-    }
-
-    function migrationRequired()
-    {
         if(empty($this->migrate) || $this->migrationClass == NULL){
             return(FALSE);
         }
@@ -383,7 +398,7 @@ class gosaProperty
 
         // Display the reason for failing this check.         
         if($message && ! $match){
-            msg_dialog::display(_("Warning"), msgPool::invalid($name,$value),  WARNING_DIALOG);
+            msg_dialog::display(_("Warning"), msgPool::invalid($name,$value,'','cn=user,ou=people,dc=example,dc=de'),  WARNING_DIALOG);
         }
         
         return($match);
@@ -391,11 +406,11 @@ class gosaProperty
 
     static function isRdn($message,$class,$name,$value, $type)
     {
-        $match = preg_match("/^([a-z]*=[^=,]*,)*[^=]*=[^=]*$/i", $value);
+        $match = preg_match("/^([a-z]*=[^=,]*,)*[^=]*=[^=]*,$/i", $value);
 
         // Display the reason for failing this check.         
         if($message && ! $match){
-            msg_dialog::display(_("Warning"), msgPool::invalid($name,$value),  WARNING_DIALOG);
+            msg_dialog::display(_("Warning"), msgPool::invalid($name,$value,'','ou=people,'),  WARNING_DIALOG);
         }
         
         return($match);
@@ -412,9 +427,9 @@ class gosaProperty
         }
 
         // Second check for values in the config file.
-        if(isset($this->parent->fileStoredProperties[$this->class][strtolower($this->name)])){
+        if(isset($this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)])){
             $this->setStatus('file');
-            $this->value = $this->parent->fileStoredProperties[$this->class][strtolower($this->name)];
+            $this->value = $this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)];
             return;
         }
 
@@ -546,7 +561,7 @@ class gosaProperty
 
 interface propertyMigration
 {
-    function __construct($property);
+    function __construct($config,$property);
 }