Code

Only copy apps and mimetypes while those are installed and available.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 24 Nov 2010 12:53:16 +0000 (12:53 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 24 Nov 2010 12:53:16 +0000 (12:53 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20352 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiManagement.inc

index 315f136c68f9f008621e9ab266de0498f8cd8040..5c7ba89014e910836b793af96e288c3384e39f23 100644 (file)
@@ -760,14 +760,28 @@ class faiManagement extends management
 
       $targetReleaseDN = "ou=".$name.",".$baseToUse;
 
-      $appsrc = preg_replace("/".preg_quote(get_ou("faiManagement", "faiBaseRDN"), '/')."/i",get_ou("application", "applicationRDN"),$baseToUse);
-      $appdst = preg_replace("/".preg_quote(get_ou("faiManagement", "faiBaseRDN"), '/')."/i",get_ou("application", "applicationRDN"),"ou=".$name.",".$baseToUse) ;
+      $appsEnabled = class_available("application");
+      $mimeEnabled = class_available("mimetype");
+      if($appsEnabled){
+          $appsrc = preg_replace("/".preg_quote(get_ou("faiManagement", "faiBaseRDN"), '/')."/i",
+                  get_ou("application", "applicationRDN"),$baseToUse);
+          $appdst = preg_replace("/".preg_quote(get_ou("faiManagement", "faiBaseRDN"), '/')."/i",
+                  get_ou("application", "applicationRDN"),"ou=".$name.",".$baseToUse) ;
+      }
+      if($mimeEnabled){
+          $mimesrc = preg_replace("/".preg_quote(get_ou("faiManagement", "faiBaseRDN"), '/')."/i",
+                  get_ou("mimetype", "mimetypeRDN"),$baseToUse);
+          $mimedst = preg_replace("/".preg_quote(get_ou("faiManagement", "faiBaseRDN"), '/')."/i",
+                  get_ou("mimetype", "mimetypeRDN"),"ou=".$name.",".$baseToUse) ;
+      }
 
-      $mimesrc = preg_replace("/".preg_quote(get_ou("faiManagement", "faiBaseRDN"), '/')."/i",get_ou("mimetype", "mimetypeRDN"),$baseToUse);
-      $mimedst = preg_replace("/".preg_quote(get_ou("faiManagement", "faiBaseRDN"), '/')."/i",get_ou("mimetype", "mimetypeRDN"),"ou=".$name.",".$baseToUse) ;
+      $useBases = array();
+      $useBases[] = $baseToUse;
+      if($appsEnabled) $useBases[] = $appsrc;
+      if($mimeEnabled) $useBases[] = $mimesrc;
 
       /* Check if source depeartments exist */
-      foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
+      foreach($useBases as $dep){
         $ldap->cd($this->config->current['BASE']);
         $ldap->cat($dep);
         if(!$ldap->count()){
@@ -794,20 +808,24 @@ class faiManagement extends management
 
       /* Duplicate applications
        */
-      $ldap->cat($appsrc,array("dn")) ;
-      if($ldap->count()){
-        $ldap->cd ($appdst);
-        $ldap->recursive_remove();
-        FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
+      if($appsEnabled){
+          $ldap->cat($appsrc,array("dn")) ;
+          if($ldap->count()){
+              $ldap->cd ($appdst);
+              $ldap->recursive_remove();
+              FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
+          }
       }
 
       /* Duplicate mime types
        */
-      $ldap->cat($mimesrc,array("dn")) ;
-      if($ldap->count()){
-        $ldap->cd ($mimedst);
-        $ldap->recursive_remove();
-        FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
+      if($mimeEnabled){
+          $ldap->cat($mimesrc,array("dn")) ;
+          if($ldap->count()){
+              $ldap->cd ($mimedst);
+              $ldap->recursive_remove();
+              FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
+          }
       }
 
       $attr = array();