Code

Added migration for faiBaseRDN
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 14 May 2010 09:57:54 +0000 (09:57 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 14 May 2010 09:57:54 +0000 (09:57 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18473 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/migration/class_migrateFaiRDN.inc
gosa-plugins/fai/admin/fai/migration/class_migrate_faiBaseRDN.inc

index be91061ffa6e6b36418c81df3781989b3514736d..b49c357f27a4643f590e406029b8515d57342067 100644 (file)
@@ -17,6 +17,8 @@ class migrateFaiRDN extends migrateRDN implements propertyMigration
     protected $suffix = ""; 
     protected $prefix = ""; 
 
+    public $faiBaseRDN;
+
     function __construct($config,$property)
     {
         $this->property = &$property;
@@ -35,7 +37,9 @@ class migrateFaiRDN extends migrateRDN implements propertyMigration
         $initialValue = $this->prefix.$this->property->getValue().$this->suffix;
         $targetValue = $this->prefix.$this->property->getValue(TRUE).$this->suffix;
 
-        $prefix = $this->config->get_cfg_value('faiManagement','faiBaseRDN');
+        $prefixProp  = $this->config->configRegistry->getProperty('faiManagement','faiBaseRDN');
+        $prefix      = $prefixProp->getValue();
+        $prefixNew   = $prefixProp->getValue(TRUE);
 
         $dnMatch = "";
         if(!empty($initialValue) || !empty($prefix)){
@@ -93,7 +97,7 @@ class migrateFaiRDN extends migrateRDN implements propertyMigration
             $name = substr($dn,0, (strlen($dn)  - strlen($initialValue.$releaseRDN.$prefix.$basePart)));
 
             // Build new container name and check if it exists.
-            $newContainer = $targetValue.$releaseRDN.$prefix.$basePart;
+            $newContainer = $targetValue.$releaseRDN.$prefixNew.$basePart;
             if(!$ldap->dn_exists($newContainer)){
                 $this->found['add'][$newContainer] = array(); 
             }
index d1e748cff6e8711a90fe48b7bf43cf3ea4e74c29..86380dc89970fc9419d245358e38d2078daa19bf 100644 (file)
@@ -2,5 +2,41 @@
 class migrate_faiBaseRDN extends migrateFaiRDN implements propertyMigration
 {
     protected $filter = "(&(objectClass=nothing)%s)";
+
+
+
+    function checkForIssues()
+    {
+    
+        // Check every single property which is connected to this property.
+        $ret = array('add' => array(), 'move' => array());
+        foreach(array(
+                    'faiScript'=> 'faiScriptRDN',
+                    'faiHook'=> 'faiHookRDN',
+                    'faiTemplate'=> 'faiTemplateRDN',
+                    'faiVariable'=> 'faiVariableRDN',
+                    'faiProfile'=> 'faiProfileRDN',
+                    'faiPartitionTable'=> 'faiPartitionRDN',
+                    'faiPackage'=> 'faiPackageRDN') as $class => $name){
+
+            if($this->config->configRegistry->propertyExists($class,$name)){
+                $prop = $this->config->configRegistry->getProperty($class,$name);
+                if($prop->migrationRequired()){
+                    $migrator = $prop->getMigrationClass();
+                    if($migrator){
+                        $tmp = $migrator->getChanges();
+                        if(isset($tmp['add'])){
+                            $ret['add'] = array_merge($tmp['add'],$ret['add']);
+                        }
+                        if(isset($tmp['move'])){
+                            $ret['move'] = array_merge($tmp['move'],$ret['move']);
+                        }
+                    }
+                }
+            }
+        }
+        $this->found = $ret;
+        return(count($ret['add']) || count($ret['move']));
+    }
 }
 ?>