Code

Updated faiManagement properties
[gosa.git] / gosa-core / setup / class_setupStep_Migrate.inc
index ee4df05932460261c9e9313ace9a862236a1eeeb..cc2ac4acde48cd26c846a3f2ed10ede68cc0dae9 100644 (file)
@@ -138,13 +138,13 @@ class Step_Migrate extends setup_step
     $this->checks['root']['ERROR_MSG'] = "";
     $this->checkBase();
 
-    $this->checks['rootOC']['TITLE']     = _("Checking object classes for root object");
+    $this->checks['rootOC']['TITLE']     = _("Inspecting object classes in root object");
     $this->checks['rootOC']['STATUS']    = FALSE;
     $this->checks['rootOC']['STATUS_MSG']= "";
     $this->checks['rootOC']['ERROR_MSG'] = "";
     $this->checkBaseOC();
 
-    $this->checks['permissions']['TITLE']     = _("Checking permissions on LDAP database");
+    $this->checks['permissions']['TITLE']     = _("Checking permission for LDAP database");
     $this->checks['permissions']['STATUS']    = FALSE;
     $this->checks['permissions']['STATUS_MSG']= "";
     $this->checks['permissions']['ERROR_MSG'] = "";
@@ -574,7 +574,6 @@ class Step_Migrate extends setup_step
     /* Try to create dummy object 
      */ 
     $ldap->cd ($dn);
-    $ldap->create_missing_trees($dn);
     $res = $ldap->add($testEntry);
     $ldap->cat($dn);
     if(!$ldap->count()){
@@ -869,6 +868,7 @@ class Step_Migrate extends setup_step
   {
     /* Reset settings 
      */ 
+    $GOsa_26_found = FALSE;
     $this->migrate_users = array();
     $this->acl_migrate_dialog = FALSE;
     $this->migrate_acl_base_entry  = "";
@@ -884,7 +884,7 @@ class Step_Migrate extends setup_step
     $ldap = new ldapMultiplexer($ldap_l);
     $ldap->cd($cv['base']);
     $res = $ldap->cat($cv['base']);
-    
+   
     if(!$res){
       $this->checks['acls']['STATUS']    = FALSE;
       $this->checks['acls']['STATUS_MSG']= _("LDAP query failed");
@@ -920,10 +920,10 @@ class Step_Migrate extends setup_step
         $acls = $attrs['gosaAclEntry'];
         for($i = 0 ; $i < $acls['count'] ; $i++){
           $acl = $acls[$i];
-          $tmp = split(":",$acl);
+          $tmp = explode(":",$acl);
 
           if($tmp[1] == "psub"){
-            $members = split(",",$tmp[2]);
+            $members = explode(",",$tmp[2]);
             foreach($members as $member){
               $member = base64_decode($member);
               if(isset($users[$member])){
@@ -964,7 +964,7 @@ class Step_Migrate extends setup_step
                 $a_str = $ret['gosaAclTemplate'][$e];
                 if(preg_match("/^[0-9]*:psub:/",$a_str) && preg_match("/:all;cmdrw$/",$a_str)){
 
-                  $members = split(",",$tmp[3]);
+                  $members = explode(",",$tmp[3]);
                   foreach($members as $member){
                     $member = base64_decode($member);
 
@@ -1050,6 +1050,9 @@ class Step_Migrate extends setup_step
         $this->checks['acls']['ERROR_MSG'].= "<input type='submit' name='create_acls' value='"._("Create")."'>";
       }
     }
+
+    // Reload base OC
+    $this->checkBaseOC();
     return($GOsa_26_found);
   }
 
@@ -1524,29 +1527,29 @@ class Step_Migrate extends setup_step
      *************/
   
     if(isset($_POST['root_add_objectclasses'])){
-               $this->rootOC_migrate_dialog = TRUE;
-       $this->dialog = TRUE;
-    }
-       if(isset($_POST['rootOC_dialog_cancel'])){
-               $this->rootOC_migrate_dialog = FALSE;
-       $this->dialog = FALSE;
-       }
-       if(isset($_POST['rootOC_migrate_start'])){
-               if($this->checkBaseOC(FALSE)){
-                       $this->checkBaseOC();
-                       $this->dialog = FALSE;
-                       $this->rootOC_migrate_dialog = FALSE;
-               }
-       }
-       
+      $this->rootOC_migrate_dialog = TRUE;
+      $this->dialog = TRUE;
+    }
+    if(isset($_POST['rootOC_dialog_cancel'])){
+      $this->rootOC_migrate_dialog = FALSE;
+      $this->dialog = FALSE;
+    }
+    if(isset($_POST['rootOC_migrate_start'])){
+      if($this->checkBaseOC(FALSE)){
+        $this->checkBaseOC(); // Update overview info
+        $this->dialog = FALSE;
+        $this->rootOC_migrate_dialog = FALSE;
+      }
+    }
+
+
+    if($this->rootOC_migrate_dialog){
+      $smarty = get_smarty();
+      $smarty->assign("details",$this->rootOC_details);
+      $smarty->assign("method","rootOC_migrate_dialog");
+      return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
+    }
 
-       if($this->rootOC_migrate_dialog){
-               $smarty = get_smarty();
-        $smarty->assign("details",$this->rootOC_details);
-        $smarty->assign("method","rootOC_migrate_dialog");
-               return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
-       }
     /*************
      * Administrative Account -- Migrate/Create 
      *************/
@@ -1592,6 +1595,8 @@ class Step_Migrate extends setup_step
       /* Update ldap and reload check infos 
        */
       $this->migrate_selected_admin_users();
+      $this->dialog = FALSE;
+      $this->acl_migrate_dialog = FALSE;
 
     }elseif($this->acl_migrate_dialog){
 
@@ -2033,116 +2038,122 @@ class Step_Migrate extends setup_step
       return;
     }
 
-       $attrs = $ldap->fetch();
-
-       /* Root object doesn't exists 
-        */
-       if(!in_array("gosaDepartment",$attrs['objectClass'])){
-               if($just_check){
-
-                       $this->rootOC_details = array();        
-                       $mods = array();
-
-                       /* Get list of possible container objects, to be able to detect naming 
-                        *  attributes and missing attribute types.
-                        */
-                       if(!class_available("departmentManagement")){
-                               $this->checks['rootOC']['STATUS']    = FALSE;
-                               $this->checks['rootOC']['STATUS_MSG']= _("Failed");
-                               $this->checks['rootOC']['ERROR_MSG'] = sprintf(_("Missing GOsa class %s."),"departmentManagement")."&nbsp;"._("Please check your installation.");
-                               return;
-                       }
-
-                       /* Try to detect base class type, e.g. is it a dcObject.
-                        */
-                       $dep_types = departmentManagement::get_support_departments();
-                       $dep_type ="";
-                       foreach($dep_types as $dep_name => $dep_class){
-                               if(in_array($dep_class['CLASS'], $attrs['objectClass'])){
-                                       $dep_type = $dep_name;
-                                       break;
-                               }
-                       }
-
-                       /* If no known base class was detect, abort with message
-                        */     
-                       if(empty($dep_type)){
-                               $this->checks['rootOC']['STATUS']    = FALSE;
-                               $this->checks['rootOC']['STATUS_MSG']= _("Failed");
-                               $this->checks['rootOC']['ERROR_MSG'] = 
-                                       sprintf(_("Could not detect the object type of your root object, please try to add the objectClass '%s' manually."),"gosaDepartment");
-                               return;
-                       }
-
-                       /* Create 'current' and 'target' object properties, to be able to display 
-                        *  a set of modifications required to create a valid GOsa department.
-                        */     
-                       $str = "dn: ".$cv['base']."\n";
-                       for($i = 0 ; $i<$attrs['objectClass']['count'];$i++){
-                               $str .= "objectClass: ".$attrs['objectClass'][$i]."\n";
-                       }
-                       $this->rootOC_details['current'] = $str;
-
-                       /* Create target infos 
-                        */
-                       $str = "dn: ".$cv['base']."\n";
-                       for($i = 0 ; $i<$attrs['objectClass']['count'];$i++){
-                               $str .= "objectClass: ".$attrs['objectClass'][$i]."\n";
-                               $mods['objectClass'][] = $attrs['objectClass'][$i];
-                       }
-                       $mods['objectClass'][] = "gosaDepartment";
-                       $str .= "<b>objectClass: gosaDepartment</b>\n";
-
-                       /* Append attribute 'ou', it is required by gosaDepartment
-                        */
-                       if(!isset($attrs['ou'])){
-                               $val = "GOsa";
-                               if(isset($attrs[$dep_types[$dep_type]['ATTR']][0])){
-                                       $val = $attrs[$dep_types[$dep_type]['ATTR']][0];
-                               }
-                               $str .= "<b>ou: ".$val."</b>\n";
-                               $mods['ou'] =$val;
-                       }
-
-                       /*Append description, it is required by gosaDepartment too.
-                        */
-                       if(!isset($attrs['description'])){
-                               $val = "GOsa";
-                               if(isset($attrs[$dep_types[$dep_type]['ATTR']][0])){
-                                       $val = $attrs[$dep_types[$dep_type]['ATTR']][0];
-                               }
-                               $str .= "<b>description: ".$val."</b>\n";
-                               $mods['description'] = $val;
-                       }
-                       $this->rootOC_details['target'] = $str;
-                       $this->rootOC_details['mods'] = $mods;
-
-                       $this->checks['rootOC']['STATUS']    = FALSE;
-                       $this->checks['rootOC']['STATUS_MSG']= _("Failed");
-                       $this->checks['rootOC']['ERROR_MSG'] = "&nbsp;<input type='submit' name='root_add_objectclasses' value='"._("Migrate")."'>";
-                       return(FALSE);
-               }else{
-
-                       /* Add root object */ 
-                       $ldap->cd($cv['base']);
-                       if(isset($this->rootOC_details['mods'])){
-                               $res  = $ldap->modify($this->rootOC_details['mods']);   
-                               if(!$res){
-                                       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $source, LDAP_MOD, get_class()));
-                               }
-                               return($res);
-                       }else{
-                               trigger_error("No modifications to make... ");
-                       }
-               }
-               return(TRUE);
-       }
+    $attrs = $ldap->fetch();
+
+    /* Root object doesn't exists 
+     */
+    if(!in_array("gosaDepartment",$attrs['objectClass'])){
+      if($just_check){
+
+        $this->rootOC_details = array();       
+        $mods = array();
+
+        /* Get list of possible container objects, to be able to detect naming 
+         *  attributes and missing attribute types.
+         */
+        if(!class_available("departmentManagement")){
+          $this->checks['rootOC']['STATUS']    = FALSE;
+          $this->checks['rootOC']['STATUS_MSG']= _("Failed");
+          $this->checks['rootOC']['ERROR_MSG'] = sprintf(_("Missing GOsa object class '%s'!"),"departmentManagement").
+            "&nbsp;"._("Please check your installation.");
+          return;
+        }
+
+        /* Try to detect base class type, e.g. is it a dcObject.
+         */
+        $dep_types = departmentManagement::get_support_departments();
+        $dep_type ="";
+        foreach($dep_types as $dep_name => $dep_class){
+          if(in_array($dep_class['CLASS'], $attrs['objectClass'])){
+            $dep_type = $dep_name;
+            break;
+          }
+        }
+
+        /* If no known base class was detect, abort with message
+         */    
+        if(empty($dep_type)){
+          $this->checks['rootOC']['STATUS']    = FALSE;
+          $this->checks['rootOC']['STATUS_MSG']= _("Failed");
+          $this->checks['rootOC']['ERROR_MSG'] = 
+            sprintf(_("Cannot handle the structural object type of your root object. Please try to add the object class '%s' manually."),"gosaDepartment");
+          return;
+        }
+
+        /* Create 'current' and 'target' object properties, to be able to display 
+         *  a set of modifications required to create a valid GOsa department.
+         */    
+        $str = "dn: ".$cv['base']."\n";
+        for($i = 0 ; $i<$attrs['objectClass']['count'];$i++){
+          $str .= "objectClass: ".$attrs['objectClass'][$i]."\n";
+        }
+        $this->rootOC_details['current'] = $str;
+
+        /* Create target infos 
+         */
+        $str = "dn: ".$cv['base']."\n";
+        for($i = 0 ; $i<$attrs['objectClass']['count'];$i++){
+          $str .= "objectClass: ".$attrs['objectClass'][$i]."\n";
+          $mods['objectClass'][] = $attrs['objectClass'][$i];
+        }
+        $mods['objectClass'][] = "gosaDepartment";
+        $str .= "<b>objectClass: gosaDepartment</b>\n";
+
+        /* Append attribute 'ou', it is required by gosaDepartment
+         */
+        if(!isset($attrs['ou'])){
+          $val = "GOsa";
+          if(isset($attrs[$dep_types[$dep_type]['ATTR']][0])){
+            $val = $attrs[$dep_types[$dep_type]['ATTR']][0];
+          }
+          $str .= "<b>ou: ".$val."</b>\n";
+          $mods['ou'] =$val;
+        }
+
+        /*Append description, it is required by gosaDepartment too.
+         */
+        if(!isset($attrs['description'])){
+          $val = "GOsa";
+          if(isset($attrs[$dep_types[$dep_type]['ATTR']][0])){
+            $val = $attrs[$dep_types[$dep_type]['ATTR']][0];
+          }
+          $str .= "<b>description: ".$val."</b>\n";
+          $mods['description'] = $val;
+        }
+        $this->rootOC_details['target'] = $str;
+        $this->rootOC_details['mods'] = $mods;
+
+        /*  Add button that allows to open the migration details
+         */
+        $this->checks['rootOC']['STATUS']    = FALSE;
+        $this->checks['rootOC']['STATUS_MSG']= _("Failed");
+        $this->checks['rootOC']['ERROR_MSG'] = "&nbsp;<input type='submit' 
+          name='root_add_objectclasses' value='"._("Migrate")."'>";
+
+        return(FALSE);
+      }else{
+
+        /* Add root object */ 
+        $ldap->cd($cv['base']);
+        if(isset($this->rootOC_details['mods'])){
+          $res  = $ldap->modify($this->rootOC_details['mods']);        
+          if(!$res){
+            msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $cv['base'], LDAP_MOD, get_class()));
+          }
+          $this->checkBaseOC();
+          $this->check_administrativeAccount();
+          return($res);
+        }else{
+          trigger_error("No modifications to make... ");
+        }
+      }
+      return(TRUE);
+    }
 
     /* Create & remove of dummy object was successful */
     $this->checks['rootOC']['STATUS']    = TRUE;
     $this->checks['rootOC']['STATUS_MSG']= _("Ok");
-       $this->checks['rootOC']['ERROR_MSG'] = "";
+    $this->checks['rootOC']['ERROR_MSG'] = "";
   }
 
 
@@ -2890,7 +2901,7 @@ class Step_Migrate extends setup_step
        */ 
       $release = "";
       $r = $info['FAIrelease'][0];
-      $z = split("/",$r);
+      $z = explode("/",$r);
       foreach($z as $part){
 
         if(!empty($part)){