Code

Added Functionality to info button
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 25 Apr 2007 08:50:08 +0000 (08:50 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 25 Apr 2007 08:50:08 +0000 (08:50 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6190 594d385d-05f5-0310-b6e9-bd551577e9d8

setup/class_setupStep_Migrate.inc
setup/setup_migrate.tpl

index 4e40268e6dceca3803baeba2c46f59f3252169c1..438e3152428076ba12ba5012a7dfe53c7c7a2bdf 100644 (file)
@@ -141,6 +141,9 @@ class Step_Migrate extends setup_step
     $ldap->search("(&(objectClass=organizationalUnit)(!(objectClass=gosaDepartment)))",array("ou","description","dn"));
     while($attrs = $ldap->fetch()){
       $attrs['checked'] = FALSE;
+      $attrs['before']  = "";
+      $attrs['after']   = "";
+
       $this->deps_to_migrate[] = $attrs;
     }
   
@@ -177,7 +180,7 @@ class Step_Migrate extends setup_step
 
     
   /* Start deparmtment migration */  
-  function migrate_organizationalUnits()
+  function migrate_organizationalUnits($only_ldif = FALSE)
   {
     /* Get collected configuration settings */
     $cv = $this->parent->captured_values;
@@ -189,7 +192,7 @@ class Step_Migrate extends setup_step
                      FALSE,
                      $cv['tls']);
 
-    foreach($this->deps_to_migrate as $dep){
+    foreach($this->deps_to_migrate as $key => $dep){
       if($dep['checked']){
 
         $ldap->cat($dep['dn'],array("objectClass","description"));
@@ -204,11 +207,18 @@ class Step_Migrate extends setup_step
         if(!isset($attrs['description'])){
           $new_attrs['description'][] = "GOsa department";
         }
+      
         
-        $ldap->cd($attrs['dn']);
-        if(!$ldap->modify($new_attrs)){
-          print_red(sprintf(_("Failed to migrate the department '%s' into GOsa, error message is as follows '%s'."),$attrs['dn'],$ldap->get_error()));
-          return(false);
+   
+        if($only_ldif){
+          $this->deps_to_migrate[$key]['before'] = $this->array_to_ldif($attrs);
+          $this->deps_to_migrate[$key]['after']  = $this->array_to_ldif($new_attrs);
+        }else{
+          $ldap->cd($attrs['dn']);
+          if(!$ldap->modify($new_attrs)){
+            print_red(sprintf(_("Failed to migrate the department '%s' into GOsa, error message is as follows '%s'."),$attrs['dn'],$ldap->get_error()));
+            return(false);
+          }
         }
       }
     }
@@ -248,6 +258,11 @@ class Step_Migrate extends setup_step
       }
     }
 
+    /* Start migration */
+    if(isset($_POST['deps_visible_migrate_whatsdone'])){
+      $this->migrate_organizationalUnits(TRUE);
+    }
+
     /* Display migration dialog */
     if($this->migration_dialog){
       $smarty = get_smarty();
@@ -276,6 +291,38 @@ class Step_Migrate extends setup_step
     }
 
   }
+
+  function array_to_ldif($atts)
+  {
+    $ret = "";
+    unset($atts['count']);
+    unset($atts['dn']);
+    foreach($atts as $name => $value){
+
+      if(is_numeric($name)) {
+        continue;
+      }
+
+      if(is_array($value)){
+        unset($value['count']);
+        foreach($value as $a_val){
+          if(!preg_match('/^[a-z0-9+@#.=, \/ -]+$/i', $a_val)){
+            $ret .= $name.":: ". base64_encode($a_val)."\n";
+          }else{
+            $ret .= $name.": ". $a_val."\n";
+          }
+        }
+      }else{
+        if(!preg_match('/^[a-z0-9+@#.=, \/ -]+$/i', $value)){
+          $ret .= $name.": ". base64_encode($value)."\n";
+        }else{
+          $ret .= $name.": ". $value."\n";
+        }
+      }
+    }
+    return(preg_replace("/\n$/","",$ret));
+  }
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index bcae3c6084bdff21ac43db7d2448f33802c638db..a35e4b0e99b3c0a5fdd07027e38eefd4b0cb309b 100644 (file)
 
                                {if $deps_to_migrate.$key.checked}
                                        <input type='checkbox' name='migrate_{$key}' checked>
+                                       {$deps_to_migrate.$key.dn}
+                                       {if $deps_to_migrate.$key.after != ""}
+                                               <div class="step2_entry_container_info" id="sol_8">
+
+{t}Current{/t}
+<div style='padding-left:20px;'>
+<pre>
+dn: {$deps_to_migrate.$key.dn}
+{$deps_to_migrate.$key.before}
+</pre>
+</div>
+{t}After migration{/t}
+<div style='padding-left:20px;'>
+<pre>
+dn: {$deps_to_migrate.$key.dn}
+{$deps_to_migrate.$key.after}
+</pre>
+</div>
+                                               </div>
+                                       {/if}
                                {else}
                                        <input type='checkbox' name='migrate_{$key}'>
+                                       {$deps_to_migrate.$key.dn}
                                {/if}
-                               {$deps_to_migrate.$key.dn}
+
                                <br>
+                               
+
                        {/foreach}
+                       <br>
 
                        <input type='submit' name='deps_visible_migrate_refresh' value='{t}Reload list{/t}'>
                        <input type='submit' name='deps_visible_migrate_migrate' value='{t}Migrate{/t}'>