Code

Added scalix and nagios accounts.
[gosa.git] / gosa-core / setup / class_setupStep_Migrate.inc
index 18526239a3b4339e26d3d156846fc9217d22716d..9f20ab6a24425da072d9f29020a91d6ded8081e6 100644 (file)
@@ -86,6 +86,14 @@ class Step_Migrate extends setup_step
   var $device_dialog         = FALSE;
   var $device                = array();
 
+  /* Service migration */
+  var $service_dialog         = FALSE;
+  var $service                = array();
+
+  /* Group menus */
+  var $menu_dialog           = FALSE;
+  var $menu                  = array();
+
   /* Win-Workstations outside to reserved ou */
   var $outside_winstations        = array();
   var $outside_winstations_dialog = FALSE;
@@ -149,7 +157,7 @@ class Step_Migrate extends setup_step
     $this->checks['outside_users']['STATUS_MSG']= "";
     $this->checks['outside_users']['ERROR_MSG'] = "";
     $this->search_outside_users();
-    
+
     $this->checks['outside_groups']['TITLE']     = _("Checking for groups outside the groups tree");
     $this->checks['outside_groups']['STATUS']    = FALSE;
     $this->checks['outside_groups']['STATUS_MSG']= "";
@@ -168,7 +176,7 @@ class Step_Migrate extends setup_step
     $this->checks['uidNumber_usage']['STATUS_MSG']= "";
     $this->checks['uidNumber_usage']['ERROR_MSG'] = "";
     $this->check_uidNumber();
-    
+
     $this->checks['gidNumber_usage']['TITLE']     = _("Checking for duplicate GID numbers");
     $this->checks['gidNumber_usage']['STATUS']    = FALSE;
     $this->checks['gidNumber_usage']['STATUS_MSG']= "";
@@ -180,6 +188,18 @@ class Step_Migrate extends setup_step
     $this->checks['old_style_devices']['STATUS_MSG']= "";
     $this->checks['old_style_devices']['ERROR_MSG'] = "";
     $this->check_usb_devices();
+
+    $this->checks['old_style_services']['TITLE']     = _("Checking for old services that have to be migrated");
+    $this->checks['old_style_services']['STATUS']    = FALSE;
+    $this->checks['old_style_services']['STATUS_MSG']= "";
+    $this->checks['old_style_services']['ERROR_MSG'] = "";
+    $this->check_services();
+
+    $this->checks['old_style_menus']['TITLE']     = _("Checking for old style application menus");
+    $this->checks['old_style_menus']['STATUS']    = FALSE;
+    $this->checks['old_style_menus']['STATUS_MSG']= "";
+    $this->checks['old_style_menus']['ERROR_MSG'] = "";
+    $this->check_menus();
   }
 
 
@@ -303,7 +323,7 @@ class Step_Migrate extends setup_step
 
     /* Get winstation ou */
     if($cv['generic_settings']['wws_ou_active']) {
-      $winstation_ou = $cv['generic_settings']['ws_ou'];
+      $winstation_ou = $cv['generic_settings']['wws_ou'];
     }else{
       $winstation_ou = "ou=winstations";
     }
@@ -999,6 +1019,16 @@ class Step_Migrate extends setup_step
   {
     $pw1 = $pw2 = "";
     $uid = "";
+
+    /* On first call check for rid/sid base */
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
+        $cv['password'],
+        $cv['connection'],
+        FALSE,
+        $cv['tls']);
+
+    $ldap = new ldapMultiplexer($ldap_l);
   
     if(isset($_POST['new_user_uid'])){
       $uid = $_POST['new_user_uid'];
@@ -1010,6 +1040,14 @@ class Step_Migrate extends setup_step
       $pw2 = $_POST['new_user_password2'];
     }
   
+    
+    $ldap->cd($cv['base']);
+    $ldap->search("(uid=".$uid.")");
+    if($ldap->count()){
+      msg_dialog::display(_("Input error"),msgPool::duplicated(_("Uid")), ERROR_DIALOG);
+      return false;
+    }
+    
     if(empty($pw1) || empty($pw2) | ($pw1 != $pw2)){
       msg_dialog::display(_("Password error"), _("Provided passwords do not match!"), ERROR_DIALOG);
       return false;
@@ -1019,17 +1057,8 @@ class Step_Migrate extends setup_step
       msg_dialog::display(_("Input error"), _("Specify a valid user ID!"), ERROR_DIALOG);
       return false;
     }
-    
-    /* On first call check for rid/sid base */
-    $cv = $this->parent->captured_values;
-    $ldap_l = new LDAP($cv['admin'],
-        $cv['password'],
-        $cv['connection'],
-        FALSE,
-        $cv['tls']);
-
-    $ldap = new ldapMultiplexer($ldap_l);
-
     /* Get current base attributes */
     $ldap->cd($cv['base']);
   
@@ -1593,6 +1622,94 @@ class Step_Migrate extends setup_step
       return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
     }
 
+
+    /*************
+     * Service migration 
+     *************/
+   
+    if($this->service_dialog) {
+      $this->check_service_posts();
+    }
+    if(isset($_POST['service_dialog_cancel'])){
+      $this->service_dialog = FALSE;
+      $this->show_details = FALSE;
+      $this->dialog = FALSE;
+    }
+   
+    if(isset($_POST['service_dialog_whats_done'])){
+      $this->show_details= TRUE;
+    }
+    if(isset($_POST['service_dialog_refresh'])){
+      $this->show_details= FALSE;
+    }
+
+    if(isset($_POST['migrate_services'])){
+      $this->migrate_services();
+#      $this->dialog = FALSE;
+ #     $this->show_details = FALSE;
+  #    $this->service_dialog = FALSE;
+   #   $this->initialize_checks();
+    }
+
+    if(isset($_POST['service_dialog'])){
+      $this->service_dialog = TRUE;
+      $this->dialog = TRUE;
+    }
+    
+    if($this->service_dialog){
+      $smarty = get_smarty();
+      $smarty->assign("method","services");
+      $smarty->assign("services",$this->service);
+      $smarty->assign("service_details", $this->show_details);
+      return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
+    }
+
+
+    /*************
+     * Menu migration 
+     *************/
+   
+    if($this->menu_dialog) {
+      $this->check_menu_posts();
+    }
+    if(isset($_POST['menu_dialog_cancel'])){
+      $this->menu_dialog = FALSE;
+      $this->show_details = FALSE;
+      $this->dialog = FALSE;
+    }
+   
+    if(isset($_POST['menu_dialog_whats_done'])){
+      $this->show_details= TRUE;
+    }
+    if(isset($_POST['menu_dialog_refresh'])){
+      $this->show_details= FALSE;
+    }
+
+    if(isset($_POST['migrate_menus'])){
+      $this->migrate_menus();
+#      $this->dialog = FALSE;
+ #     $this->show_details = FALSE;
+  #    $this->menu_dialog = FALSE;
+   #   $this->initialize_checks();
+    }
+
+    if(isset($_POST['menu_dialog'])){
+      $this->menu_dialog = TRUE;
+      $this->dialog = TRUE;
+    }
+    
+    if($this->menu_dialog){
+      $smarty = get_smarty();
+      $smarty->assign("method","menus");
+      $smarty->assign("menus",$this->menu);
+      $smarty->assign("menu_details", $this->show_details);
+      return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
+    }
+
     $smarty = get_smarty();
     $smarty->assign("checks",$this->checks);
     $smarty->assign("method","default");
@@ -1852,7 +1969,7 @@ class Step_Migrate extends setup_step
 
     /* Get winstation ou */
     if($cv['generic_settings']['wws_ou_active']) {
-      $winstation_ou = $cv['generic_settings']['ws_ou'];
+      $winstation_ou = $cv['generic_settings']['wws_ou'];
     }else{
       $winstation_ou = "ou=winstations";
     }
@@ -2037,6 +2154,8 @@ class Step_Migrate extends setup_step
   }
 
 
+  /*! \brief  Act in posts from the device migration dialog 
+   */
   function check_device_posts()
   {
     foreach($this->device as $key => $device){
@@ -2049,6 +2168,10 @@ class Step_Migrate extends setup_step
   }
 
 
+  /*! \brief  Check for old style (gosa-2.5) devices.
+              Save readable informations and a list of migratable devices 
+               in $this->devices.
+   */
   function check_usb_devices ()
   {
     /* Establish ldap connection */
@@ -2133,7 +2256,7 @@ class Step_Migrate extends setup_step
       }
 
       $this->checks['old_style_devices']['STATUS']    = FALSE;
-      $this->checks['old_style_devices']['STATUS_MSG']= _("Failed");
+      $this->checks['old_style_devices']['STATUS_MSG']= "<font style='color:#F0A500'>"._("Warning")."</font>";
       $this->checks['old_style_devices']['ERROR_MSG'] = 
         sprintf(_("There are %s devices that need to be migrated."),count($this->device)).
           "<input type='submit' name='device_dialog' value='"._("Migrate")."'>";
@@ -2144,6 +2267,11 @@ class Step_Migrate extends setup_step
     }
   }
 
+
+  /*! \brief  Migrate all selected devices. 
+              Execute all required ldap actions to migrate the 
+               selected devices.
+   */
   function migrate_usb_devices ()
   {
     /* Establish ldap connection */
@@ -2185,12 +2313,18 @@ class Step_Migrate extends setup_step
           $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$newdn));
           $ldap->cd($newdn);
           $ldap->add($new_attr);
+
+          /* Throw an error message if the action failed. 
+           */
           if(!$ldap->success()){
             msg_dialog::display(_("LDAP error"), 
-                sprintf(_("Ldap add failed for %s with error %s"),
+                sprintf(_("Adding '%s' to the LDAP failed: %s"),
                   "<b>".LDAP::fix($newdn)."</b>", 
                   "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
           }else{
+
+            /* Remove old style device definition from source object. 
+             */
             $update['gotoHotplugDevice'] = array();
             for($i = 0 ; $i < $attrs['gotoHotplugDevice']['count'] ; $i++){
               if($attrs['gotoHotplugDevice'][$i] == $device['OLD_DEVICE']){
@@ -2204,7 +2338,7 @@ class Step_Migrate extends setup_step
             $ldap->cat($device['DN'],array("gotoHotplugDevice"));
             if(!$ldap->success()){
               msg_dialog::display(_("LDAP error"), 
-                  sprintf(_("Ldap update failed for %s with error %s"),
+                  sprintf(_("Updating '%s' failed: %s"),
                     "<b>".LDAP::fix($device['DN'])."</b>", 
                     "<br><br><i>".$ldap->get_error()."</b>"), ERROR_DIALOG);
             }else{
@@ -2214,6 +2348,490 @@ class Step_Migrate extends setup_step
         }
       }
     }
+    $this->check_usb_devices();
+  }
+
+
+  /*! \brief  Check for old style (gosa-2.5) services that have to be migrated
+               to be useable in gosa-2.6.
+              All required changes are stored in $this->service, also some
+               readable informations describing the actions required 
+               to migrate the service
+   */
+  function check_services()
+  {
+    /* Establish ldap connection */
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
+        $cv['password'],
+        $cv['connection'],
+        FALSE,
+        $cv['tls']);
+
+    $ldap = new ldapMultiplexer($ldap_l);
+    $this->service = array();
+
+    /* Check for Ldap services that must be migrated 
+     */ 
+    $ldap->cd($cv['base']);
+    $res = $ldap->search("(objectClass=goLdapServer)", array("goLdapBase", "cn"));
+
+    /* Check if we were able to query the ldap server 
+     */
+    if(!$res){
+      $this->checks['old_style_services']['STATUS']    = FALSE;
+      $this->checks['old_style_services']['STATUS_MSG']= _("LDAP query failed");
+      $this->checks['old_style_services']['ERROR_MSG'] = _("Possibly the 'root object' is missing.");
+      return;
+    }
+
+    /* Walk through each configured ldap server 
+        and check if it is configured correctly.
+     */
+    while($attrs = $ldap->fetch()){
+      $dn= $attrs['dn'];
+      $uri= $attrs['goLdapBase'][0];
+      if (! preg_match("!^ldaps?://!", $uri)){
+        $this->service[] = array(
+            "TYPE"    => "modify" , 
+            "DN"      => $dn, 
+            "DETAILS" => FALSE, 
+            "ATTRS"   => array("goLdapBase" => "ldap://".$attrs['cn'][0]."/$uri"),
+            "CURRENT" => "goLdapBase: ".$uri,
+            "AFTER"   => "goLdapBase: "."ldap://".$attrs['cn'][0]."/$uri");
+      }
+    }
+
+    /* Other sevices following here later ...maybe
+     */
+
+    /*  Update status message
+     */
+    if(count($this->service)){
+      $this->checks['old_style_services']['STATUS']    = FALSE;
+      $this->checks['old_style_services']['STATUS_MSG']= "<font style='color:#F0A500'>"._("Warning")."</font>";
+      $this->checks['old_style_services']['ERROR_MSG'] =
+        sprintf(_("There are %s services that need to be migrated."),
+            count($this->service)).
+        "<input type='submit' name='service_dialog' value='"._("Migrate")."'>";
+    }else{
+      $this->checks['old_style_services']['STATUS']    = TRUE;
+      $this->checks['old_style_services']['STATUS_MSG']= _("Ok");
+      $this->checks['old_style_services']['ERROR_MSG'] = "";
+    }
+  }
+
+
+  
+  /*! \brief  Migrate selected services.
+              This function executes the commands collected by the 
+               service_check() function.
+   */
+  function migrate_services()
+  {
+    /* Establish ldap connection 
+     */
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
+        $cv['password'],
+        $cv['connection'],
+        FALSE,
+        $cv['tls']);
+
+    $ldap = new ldapMultiplexer($ldap_l);
+
+    /* Handle each service 
+     */
+    foreach($this->service as $key => $service){
+      if($service['DETAILS']){
+
+        /* Handle modify requests 
+         */
+        if($service['TYPE'] == "modify"){
+          $ldap->cd($service['DN']);
+          $ldap->modify($service['ATTRS']);
+
+          /* Check if everything done was successful 
+           */
+          if(!$ldap->success()){
+            msg_dialog::display(_("LDAP error"), 
+                sprintf(_("Updating '%s' failed: %s"),
+                  "<b>".LDAP::fix($service['DN'])."</b>", 
+                  "<br><br><i>".$ldap->get_error()."</b>"), ERROR_DIALOG);
+          }else{
+        
+            /* Remove action from list 
+             */
+            unset($this->service[$key]);
+          }
+        }
+      }
+    }
+
+    /* Update the service migration status 
+     */
+    $this->check_services();
+  }
+
+
+  /*! \brief  Ensure that posts made on the service migration dialog 
+               are processed.
+   */
+  function check_service_posts()
+  {
+    foreach($this->service as $key => $service){
+      if(isset($_POST["migrate_".$key])){
+        $this->service[$key]['DETAILS'] =TRUE;
+      }else{
+        $this->service[$key]['DETAILS'] =FALSE;
+      }
+    }
+  }
+
+
+  /*! \brief  This function checks the given ldap for old style (gosa-2.5) 
+               menu entries and will prepare a list of actions that are required
+               to migrate them to gosa-2.6.
+              All required actions and some readable informations are stored in 
+               $this->menu.
+   */
+  function check_menus()
+  {
+    /* Establish ldap connection
+     */
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
+        $cv['password'],
+        $cv['connection'],
+        FALSE,
+        $cv['tls']);
+
+    $ldap = new ldapMultiplexer($ldap_l);
+
+    /* First detect all release names 
+     */
+    $ldap->cd($cv['base']);
+    $res = $ldap->search("(&(objectClass=organizational)(objectClass=FAIbranch))",array("ou","objectClass"));
+
+    /* Check if we were able to query the ldap server
+     */
+    if(!$res){
+      $this->checks['old_style_menus']['STATUS']    = FALSE;
+      $this->checks['old_style_menus']['STATUS_MSG']= _("LDAP query failed");
+      $this->checks['old_style_menus']['ERROR_MSG'] = _("Possibly the 'root object' is missing.");
+      return;
+    }
+
+    /* Create application -> parameter mapping, used later to detect 
+        which configured parameter belongs to which application entry.
+     */
+    $amap= array();
+    $todo = array();
+    $ldap->cd($cv['base']);
+    $ldap->search("(objectClass=gosaApplication)", array("cn", "gosaApplicationParameter"));
+    while($info = $ldap->fetch()){
+      if (isset($info['gosaApplicationParameter']['count'])){
+        for ($j= 0; $j < $info['gosaApplicationParameter']['count']; $j++){
+          $p= preg_replace("/^([^:]+):.*$/", "$1", $info['gosaApplicationParameter'][$j]);
+
+          if(!isset($amap[$info['cn'][0]]) || !in_array($p, $amap[$info['cn'][0]])){
+            $amap[$info['cn'][0]][]= $p;
+          }
+        }
+      } else {
+        $amap[$info['cn'][0]]= array();
+      }
+    }
+
+    /* Search for all groups that have an old style application menu configured.
+     */  
+    $appgroups = array();
+    $ldap->cd($cv['base']);
+    $ldap->search("(&(objectClass=gosaApplicationGroup)(objectClass=posixGroup)(FAIrelease=*))",
+        array("gosaMemberApplication","gosaApplicationParameter","FAIrelease","objectClass","gosaUnitTag"));
+
+    /* Create readable prefix for "What will be done" infos 
+     */
+    $s_add = "<i>"._("Add")."</i>\t";
+    $s_del = "<i>"._("Remove")."</i>\t";
+
+    /* Walk through all found old-style menu configurations.
+        -Prepare ldap update list     $data   
+        -Prepare printable changes    $after/$current
+     */
+    while($info = $ldap->fetch()){
+
+      $data = array();
+      $current = "";
+      $after ="";
+
+      /* Get unit tag 
+       */
+      $tag ="";
+      if(isset($info['gosaUnitTag'])){
+        $tag = $info['gosaUnitTag'][0];
+      }
+
+      /* Collect application parameter for this group
+       */
+      $params= array();
+      if(isset($info['gosaApplicationParameter'])){
+        for ($i= 0; $i < $info['gosaApplicationParameter']['count']; $i++){
+          $name= preg_replace("/^([^:]+):.*$/", "$1", $info['gosaApplicationParameter'][$i]);
+          $params[$name]= $info['gosaApplicationParameter'][$i];
+        }
+      }
+
+      /* Create release container for each release/subrelease.
+         eg.   "sisa/1.0.0":
+         .       "ou=siga, ..."
+         .       "ou=1.0.0,ou=siga, .."
+       */ 
+      $release = "";
+      $r = $info['FAIrelease'][0];
+      $z = split("/",$r);
+      foreach($z as $part){
+
+        if(!empty($part)){
+          $release = "ou=".$part.",".$release;
+
+          /* Append release department information to "What will be done" info
+           */
+          $release_dn = $release.$info['dn'];
+          $after   .=  $s_add."dn: $release_dn\n";
+          $after   .=  $s_add."objectClass: top\n";
+          $after   .=  $s_add."objectClass: FAIbranch\n";
+          $after   .=  $s_add."objectClass: organizationalUnit\n";
+         
+          /* Append UnitTag 
+           */ 
+          if($tag != ""){ 
+            $after   .=  $s_add."objectClass: gosaAdministrativeUnitTag\n";
+            $after   .=  $s_add."gosaUnitTag: $tag\n";
+          }
+          $after   .=  $s_add."ou: $part\n";
+
+          /* Append release data to ldap actions 
+           */
+          $d = array();
+          $d['objectClass'] = array("top","FAIbranch","organizationalUnit");
+          if(!empty($tag)){
+            $d['objectClass'][] = "gosaAdministrativeUnitTag";
+            $d['gosaUnitTag']   = $tag;
+          }
+          $d['ou']          = $part;
+          $data['ADD'][$release_dn]= $d;
+        }
+      }
+
+      /* Add member applications to the array.
+       */ 
+      $current .= "dn: ".$info['dn']."\n";
+      $menu_structure = array();
+      for ($i= 0; $i < $info['gosaMemberApplication']['count']; $i++){
+        list($name, $location, $priority)= explode("|", $info['gosaMemberApplication'][$i]);
+
+        /* Create location dn 
+         */
+        $location_dn ="";
+        if(!empty($location)){
+          $location_dn ="cn=".$location.",";
+        }
+
+        /* Append old style element to current detail informations 
+         */      
+        $current .= $s_del."gosaMemberApplication: ".$info['gosaMemberApplication'][$i]."\n";
+
+        /* Append ldap update action to remove the old menu entry attributes 
+         */
+        unset($info['objectClass']['count']);
+        $d = array();
+        $d['gosaMemberApplication']      = array();
+        $d['gosaApplicationParameter']  = array();
+        if(isset($info['FAIrelease'])){
+          $d['FAIrelease'] = array();
+        }
+        $d['objectClass']               = array_remove_entries(array("gosaApplicationGroup","FAIreleaseTag"),$info['objectClass']);
+        $data['MODIFY'][$info['dn']]    = $d;
+
+        /* Create new application menu structure 
+         */
+        if (isset($amap[$name])){
+
+          /* Append missing menu structure to "What is done info"
+           */
+          if(!isset($menu_structure[$location]) && !empty($location)){
+            $menu_structure[$location] = TRUE;
+            $after .= "\n";
+            $after .= $s_add."dn: $location_dn$release_dn\n";
+            $after .= $s_add."objectClass: gotoSubmenuEntry\n";
+
+            /* Append UnitTag
+             */
+            if($tag != ""){
+              $after   .=  $s_add."objectClass: gosaAdministrativeUnitTag\n";
+              $after   .=  $s_add."gosaUnitTag: $tag\n";
+            }
+            $after .= $s_add."cn: $location\n";
+  
+            /* Create ldap entry to append 
+             */
+            $d = array();
+            $d['cn'] = $location;
+            $d['objectClass'] = array("gotoSubmenuEntry");
+            if(!empty($tag)){
+              $d['objectClass'][] = "gosaAdministrativeUnitTag";
+              $d['gosaUnitTag']   = $tag;
+            }
+            $data['ADD'][$location_dn.$release_dn] = $d;
+          }
+
+
+          /* Append missing menu entry for "What is done info".
+           */
+          if(!empty($name)){
+            $after .= "\n";
+            $after .= $s_add."dn: cn=$name,$location_dn$release_dn\n";
+            $after .= $s_add."objectClass: gotoMenuEntry\n";
+            if($tag != ""){
+              $after   .=  $s_add."objectClass: gosaAdministrativeUnitTag\n";
+              $after   .=  $s_add."gosaUnitTag: $tag\n";
+            }
+            $after .= $s_add."cn: $name\n";
+            $after .= $s_add."gosaApplicationPriority: $priority\n";
+
+            /* Create ldap entry 
+             */
+            $d= array();
+            $d['objectClass'] = array("gotoMenuEntry");
+            if(!empty($tag)){
+              $d['objectClass'][] = "gosaAdministrativeUnitTag";
+              $d['gosaUnitTag']   = $tag;
+            }
+            $d['cn']          = $name;
+            $d['gosaApplicationPriority'] = $priority;
+
+            foreach ($amap[$name] as $n){
+              if (isset($params[$n])){
+                $after .= $s_add."gosaApplicationParameter: ".$params[$n]."\n";
+                $d['gosaApplicationParameter'][] = $params[$n];
+              }
+            }
+            $data['ADD']["cn=$name,$location_dn$release_dn"] = $d;
+          }         
+        }
+      }
+
+      /* Updated todo list 
+       */ 
+      $todo[] = array(
+          "DETAILS" => FALSE,
+          "DN"      => $info['dn'],
+          "AFTER"   => $after,
+          "CURRENT" => $current,
+          "TODO"    => $data
+          );
+    }
+
+    /* Remember checks.
+     */
+    $this->menu = $todo;
+
+    /* Check if we were able to query the ldap server
+     */
+    if(count($this->menu)){
+      $this->checks['old_style_menus']['STATUS']    = FALSE;
+      $this->checks['old_style_menus']['STATUS_MSG']= "<font style='color:#F0A500'>"._("Warning")."</font>";
+      $this->checks['old_style_menus']['ERROR_MSG'] = sprintf(_("There are %s application menus which have to be migrated."),
+                                                      count($this->menu))."<input type='submit' name='menu_dialog' value='"._("Migrate")."'>";
+    }else{
+      $this->checks['old_style_menus']['STATUS']    = TRUE;
+      $this->checks['old_style_menus']['STATUS_MSG']= _("Ok");
+      $this->checks['old_style_menus']['ERROR_MSG'] = "";
+    }
+  }
+
+  
+  /*! \brief  Handle posts for the menu_dialog 
+              Ensure that checked checkboxes stay checked.
+   */
+  function check_menu_posts()
+  {
+    foreach($this->menu as $key => $menu){
+      if(isset($_POST["migrate_".$key])){
+        $this->menu[$key]['DETAILS'] =TRUE;
+      }else{
+        $this->menu[$key]['DETAILS'] =FALSE;
+      }
+    }
+  }
+
+
+  /*! \brief  This function updates old-style application menus to
+               valid 2.6 application menus.
+              All selected menus will be converted (DETAILS = TRUE). 
+              The ldap actions collected by check_menus() will be executed. 
+   */
+  function migrate_menus()
+  {
+
+    /* Establish ldap connection
+     */
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
+        $cv['password'],
+        $cv['connection'],
+        FALSE,
+        $cv['tls']);
+
+    $ldap = new ldapMultiplexer($ldap_l);
+    $ldap->cd($cv['base']);
+
+    /* Walk through menus and detect selected menu 
+     */
+    foreach($this->menu as $key => $menu){
+      if($menu['DETAILS']) {
+
+        /* Excute all LDAP-ADD actions 
+         */
+        $success = TRUE;
+        foreach($menu['TODO']['ADD'] as $dn => $data){
+          $ldap->cd($cv['base']);
+          if(!$ldap->dn_exists($dn)){
+            $ldap->cd($dn);
+            $ldap->add($data);
+            if (!$ldap->success()){
+              msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_ADD, get_class()));
+              $success = FALSE;
+            }
+          }
+        }
+
+        /* Execute all LDAP-MODIFY actions 
+         */
+        foreach($menu['TODO']['MODIFY'] as $dn => $data){
+          $ldap->cd($cv['base']);
+          if($ldap->dn_exists($dn)){
+            $ldap->cd($dn);
+            $ldap->modify($data);
+            if (!$ldap->success()){
+              msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
+              $success = FALSE;
+            }
+          }
+        }
+  
+        /* If every action was successful, remove this entry from the list 
+         */
+        if($success){
+          unset($this->menu[$key]);
+        }
+      }
+    }
+
+    /* Udpate migration status for application menus
+     */
+    $this->check_menus();
   }
 }