Code

Updated migration process
[gosa.git] / gosa-core / plugins / addons / configViewer / migration / class_migrateRDN.inc
index ce3d1a859519e906064cd42cfd3816943309cfcd..deefb0be5d9b64e7f429e01574b7ed44c3fd6453 100644 (file)
@@ -9,12 +9,25 @@ class migrateRDN implements propertyMigration
     protected $found = array();
     protected $filter ="";
 
+    // Additional suffixes or prefixes 
+    // e.g. for 'faiScriptRDN' (ou=scripts,) moving to new destination lets say 
+    //  to 'ou=FAIscripts,' would break stuff with having 'ou=fai,ou=systems,ou=config' 
+    // prepended.
+    // 
+    protected $suffix = ""; 
+    protected $prefix = ""; 
+
     function __construct($config,$property)
     {
         $this->property = &$property;
         $this->config = &$config;
     }   
 
+    function getChanges()
+    {
+        return($this->found);
+    }
+
     function checkForIssues()
     {
         $this->found = array();
@@ -24,8 +37,9 @@ class migrateRDN implements propertyMigration
         $ldap2->cd($this->config->current['BASE']);
 
         // If the userRDN wasn't empty, then only search for users inside of the old userRDN.
-        $initialValue = $this->property->getValue();
-        $targetValue = $this->property->getValue(TRUE);
+        $initialValue = $this->prefix.$this->property->getValue().$this->suffix;
+        $targetValue = $this->prefix.$this->property->getValue(TRUE).$this->suffix;
+
         $dnMatch = "";
         if(!empty($initialValue)){
             foreach(preg_split("/,/", $initialValue) as $rdnPart){
@@ -80,6 +94,7 @@ class migrateRDN implements propertyMigration
                         $container = preg_replace("/^[^,]*+,/","",$container);
                     }
 
+
                     $dnTo = $name.",".$targetValue.$container;
                     if(!empty($targetValue) && !$ldap->dn_exists($targetValue.$container)){
                         $this->found['add'][$targetValue.$container] = array(); 
@@ -107,19 +122,19 @@ class migrateRDN implements propertyMigration
             $str.= "<br><h3>"._("Objects that will be moved")."</h3>";
             $str.="<pre>";
             foreach($this->found['move'] as $id => $data){
-                $checked = (!isset($_POST['migrateNow'])) ? 'checked':'';
+                $checked = (!isset($_POST["migrateNow".get_class($this)])) ? 'checked':'';
                 $str.= "<input $checked type='checkbox' value='1' name='migrateEntry_{$id}'>";
                 $str.= sprintf(_("Moving object '%s' to '%s'"), $data['from'], $data['to'])."<br>";
             }
             $str.="</pre>";
         }
-        $str.= "<button name='migrateNow'>"._("Migrate")."</button>";
+        $str.= "<button name='migrateNow".get_class($this)."'>"._("Migrate")."</button>";
         return($str);
     }
    
     function save_object()
     {
-        if(isset($_POST['migrateNow'])){
+        if(isset($_POST["migrateNow".get_class($this)])){
             $ldap = $this->config->get_ldap_link();
             $ldap->cd($this->config->current['BASE']);