Code

Added copy & paste for profiles
[gosa.git] / setup / class_setupStep_Migrate.inc
index aadcba569ae61f5569248d7d7af430daf0ef88f7..5dcd8e649d9ccba0c9fdf273b1e8a08f0dc6d26c 100644 (file)
@@ -350,7 +350,7 @@ class Step_Migrate extends setup_step
     $valid_deps['/'] = $cv['base'];
     $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn","ou"));
     while($attrs = $ldap->fetch()){
-      $valid_deps[$attrs['ou'][0]] = $attrs['dn'];
+      $valid_deps[] = $attrs['dn'];
     }
 
     /***********
@@ -364,8 +364,9 @@ class Step_Migrate extends setup_step
       return(false);
     }
 
+    $this->outside_groups = array();
     while($attrs = $ldap->fetch()){
-      $group_db_base = preg_replace("/^[^,]+,".normalizePreg($group_ou)."/","",$attrs['dn']);
+      $group_db_base = preg_replace("/^[^,]+,".normalizePreg($group_ou)."+,/i","",$attrs['dn']);
 
       /* Check if entry is not an addressbook only user
        *  and verify that he is in a valid department
@@ -375,7 +376,7 @@ class Step_Migrate extends setup_step
         ){
         $attrs['selected'] = FALSE;
         $attrs['ldif']     = "";
-        $this->outside_users[base64_encode($attrs['dn'])] = $attrs;
+        $this->outside_groups[base64_encode($attrs['dn'])] = $attrs;
       }
     }
 
@@ -416,7 +417,7 @@ class Step_Migrate extends setup_step
     $valid_deps['/'] = $cv['base'];
     $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn","ou"));
     while($attrs = $ldap->fetch()){
-      $valid_deps[$attrs['ou'][0]] = $attrs['dn'];
+      $valid_deps[] = $attrs['dn'];
     }
 
     /***********
@@ -440,7 +441,7 @@ class Step_Migrate extends setup_step
     }
 
     while($attrs = $ldap->fetch()){
-      $people_db_base = preg_replace("/^[^,]+,".normalizePreg($people_ou)."/","",$attrs['dn']);
+      $people_db_base = preg_replace("/^[^,]+,".normalizePreg($people_ou)."/i","",$attrs['dn']);
 
       /* Check if entry is not an addressbook only user
        *  and verify that he is in a valid department
@@ -674,7 +675,7 @@ class Step_Migrate extends setup_step
     /* Skip GOsa internal departments */
     $skip_dns = array("/".$cv['peopleou']."/","/".$cv['groupou']."/","/^ou=people,/","/^ou=groups,/",
         "/(,|)ou=configs,/","/(,|)ou=systems,/",
-        "/^ou=apps,/","/^ou=mime,/","/^ou=aclroles,/","/^ou=incoming,/",
+        "/(,|)ou=apps,/","/(,|)ou=mime,/","/(,|)ou=devices/","/^ou=aclroles,/","/^ou=incoming,/",
         "/ou=snapshots,/","/(,|)dc=addressbook,/","/^(,|)ou=machineaccounts,/",
         "/(,|)ou=winstations,/");
 
@@ -698,7 +699,7 @@ class Step_Migrate extends setup_step
      */
     foreach($this->deps_to_migrate as $key => $attrs){
       $dn = $attrs['dn'];
-      $skip = false;
+      $skip = false;;
       foreach($skip_dns as $skip_dn){
         if(preg_match($skip_dn,$dn)){
           $skip = true;
@@ -933,9 +934,9 @@ class Step_Migrate extends setup_step
     }
 
     if($only_ldif){
-      $this->acl_create_changes ="\n".$cv['base']."\n";
+      $this->acl_create_changes ="\n".($ldap->fix($cv['base']))."\n";
       $this->acl_create_changes.=$this->array_to_ldif($attrs)."\n";
-      $this->acl_create_changes.="\n".$cv['base']."\n";
+      $this->acl_create_changes.="\n".($ldap->fix($cv['base']))."\n";
       $this->acl_create_changes.=$this->array_to_ldif($attrs_new);
     }else{
    
@@ -998,7 +999,7 @@ class Step_Migrate extends setup_step
       $dn = "uid=".$uid.",".$people_ou.$cv['base'];
     }
 
-    $methods = @passwordMethod::get_available_methods_if_not_loaded();
+    $methods = @passwordMethod::get_available_methods();
     $p_m = $methods[$cv['encryption']];
     $p_c = new $p_m(array());
     $hash = $p_c->generate_hash($pw2);
@@ -1062,7 +1063,7 @@ class Step_Migrate extends setup_step
         $dn = base64_decode($b_dn);
         $d_dn = preg_replace("/,.*$/",",".base64_decode($destination_dep),$dn);
         if(!$perform){
-          $this->outside_winstations[$b_dn]['ldif'] = _("Winstation will be moved from").":<br>\t".$dn."<br>"._("to").":<br>\t".$d_dn;
+          $this->outside_winstations[$b_dn]['ldif'] = _("Winstation will be moved from").":<br>\t".($ldap->fix($dn))."<br>"._("to").":<br>\t".($ldap->fix($d_dn));
 
 
           /* Check if there are references to this object */
@@ -1110,8 +1111,8 @@ class Step_Migrate extends setup_step
         $dn = base64_decode($b_dn);
         $d_dn = preg_replace("/,.*$/",",".base64_decode($destination_dep),$dn);
         if(!$perform){
-          $this->outside_groups[$b_dn]['ldif'] = _("Group will be moved from").":<br>\t".$dn."<br>"._("to").":<br>\t".$d_dn;
 
+          $this->outside_groups[$b_dn]['ldif'] = _("Group will be moved from").":<br>\t".($ldap->fix($dn))."<br>"._("to").":<br>\t".($ldap->fix($d_dn));
 
           /* Check if there are references to this object */
           $ldap->search("(&(member=".$dn.")(|(objectClass=gosaGroupOfNames)(objectClass=groupOfNames)))",array('dn'));
@@ -1151,14 +1152,14 @@ class Step_Migrate extends setup_step
       print_red(_("Couldn't move users to specified department."));
       return(false);
     }
+      
     foreach($this->outside_users as $b_dn => $data){
       $this->outside_users[$b_dn]['ldif'] ="";
       if($data['selected']){
         $dn = base64_decode($b_dn);
         $d_dn = preg_replace("/,.*$/",",".base64_decode($destination_dep),$dn);
         if(!$perform){
-          $this->outside_users[$b_dn]['ldif'] = _("User will be moved from").":<br>\t".$dn."<br>"._("to").":<br>\t".$d_dn;
+          $this->outside_users[$b_dn]['ldif'] = _("User will be moved from").":<br>\t".($ldap->fix($dn))."<br>"._("to").":<br>\t".($ldap->fix($d_dn));
 
           /* Check if there are references to this object */
           $ldap->search("(&(member=".$dn.")(|(objectClass=gosaGroupOfNames)(objectClass=groupOfNames)))",array('dn'));
@@ -1215,10 +1216,17 @@ class Step_Migrate extends setup_step
     }
     
     if($this->outside_winstations_dialog){
+
+      /* Fix displayed dn syntax */ 
+      $tmp = $this->outside_winstations;
+      foreach($tmp as $key => $data){
+        $tmp[$key]['dn'] = @LDAP::fix($data['dn']);
+      }
+
       $smarty = get_smarty();
       $smarty->assign("ous",$this->get_all_winstation_ous());
       $smarty->assign("method","outside_winstations");
-      $smarty->assign("outside_winstations",$this->outside_winstations);
+      $smarty->assign("outside_winstations",$tmp);
       return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
     }
     /*************
@@ -1254,10 +1262,17 @@ class Step_Migrate extends setup_step
     }
     
     if($this->outside_groups_dialog){
+
+      /* Fix displayed dn syntax */ 
+      $tmp = $this->outside_groups;
+      foreach($tmp as $key => $data){
+        $tmp[$key]['dn'] = @LDAP::fix($data['dn']);
+      }
+
       $smarty = get_smarty();
       $smarty->assign("ous",$this->get_all_group_ous());
       $smarty->assign("method","outside_groups");
-      $smarty->assign("outside_groups",$this->outside_groups);
+      $smarty->assign("outside_groups",$tmp);
       $smarty->assign("group_details", $this->show_details);
       return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
     }
@@ -1295,10 +1310,17 @@ class Step_Migrate extends setup_step
     }
     
     if($this->outside_users_dialog){
+
+      /* Fix displayed dn syntax */ 
+      $tmp = $this->outside_users;
+      foreach($tmp as $key => $data){
+        $tmp[$key]['dn'] = @LDAP::fix($data['dn']);
+      }
+
       $smarty = get_smarty();
       $smarty->assign("ous",$this->get_all_people_ous());
       $smarty->assign("method","outside_users");
-      $smarty->assign("outside_users",$this->outside_users);
+      $smarty->assign("outside_users",$tmp);
       $smarty->assign("user_details", $this->show_details);
       return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
     }
@@ -1412,8 +1434,15 @@ class Step_Migrate extends setup_step
 
     /* Display migration dialog */
     if($this->users_migration_dialog){
+
+      /* Fix displayed dn syntax */ 
+      $tmp = $this->users_to_migrate;
+      foreach($tmp as $key => $data){
+        $tmp[$key]['dn'] = @LDAP::fix($data['dn']);
+      }
+
       $smarty = get_smarty();
-      $smarty->assign("users_to_migrate",$this->users_to_migrate);
+      $smarty->assign("users_to_migrate",$tmp);
       $smarty->assign("method","migrate_users");
       $smarty->assign("user_details", $this->show_details);
       return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
@@ -1461,7 +1490,14 @@ class Step_Migrate extends setup_step
     /* Display migration dialog */
     if($this->dep_migration_dialog){
       $smarty = get_smarty();
-      $smarty->assign("deps_to_migrate",$this->deps_to_migrate);
+   
+      /* Fix displayed dn syntax */ 
+      $tmp = $this->deps_to_migrate;
+      foreach($tmp as $key => $data){
+        $tmp[$key]['dn'] = @LDAP::fix($data['dn']);
+      }
+
+      $smarty->assign("deps_to_migrate",$tmp);
       $smarty->assign("method","migrate_deps");
       $smarty->assign("deps_details", $this->show_details);
       return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
@@ -1700,7 +1736,7 @@ class Step_Migrate extends setup_step
       $ldap->cd($cv['base']);
       $tmp = array();
       $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn"));
-      $tmp['/'] = $cv['base'];
+      $tmp[base64_encode($cv['base'])] = $ldap->fix($cv['base']);
       while($attrs = $ldap->fetch()){
         $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);;
       }
@@ -1808,7 +1844,7 @@ class Step_Migrate extends setup_step
       $ldap->cd($cv['base']);
       $tmp = array();
       $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn"));
-      $tmp['/'] = $cv['base'];
+      $tmp[base64_encode($cv['base'])] = $ldap->fix($cv['base']);
       while($attrs = $ldap->fetch()){
         $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);;
       }