Code

Use get_attribute for FAItemplateFile if it exists
[gosa.git] / trunk / gosa-plugins / fai / admin / fai / class_FAI.inc
index d8a993859b41c02335bfb2c80fdf81cb7ce51906..a1532602236526decbe6c3e7e2cf689103d885ac 100644 (file)
@@ -518,16 +518,17 @@ class FAI
           if(!empty($r)){
 
             foreach($r as $key ){
-              /* Only update the freeze tag if the entry actually exists. */
-              $ldap->cat($key);
-              if($ldap->count()){
-                /* Append FAIstate tag to ensure that freezed objects stay freezed
-                 */ 
-                $rTag = FAI::get_release_tag(FAI::get_release_dn($key));
-                $parent_attrs['FAIstate'] = $rTag;
-              }
+              /* Append FAIstate tag to ensure that freezed objects stay freezed
+               */ 
+              $rTag = FAI::get_release_tag(FAI::get_release_dn($key));
+              $parent_attrs['FAIstate'] = $rTag;
               /* Don't copy over subobjects in subreleases if their parent is in "removed" state */
               if(!FAI::parent_is_removed($key)){
+                /* FAItemplateFile can be binary, therefore it needs to be fetched with
+                 * $ldap->get_attribute */
+                if (isset($parent_attrs['FAItemplateFile'])) {
+                  $parent_attrs['FAItemplateFile'] = $ldap->get_attribute($parent_obj, 'FAItemplateFile');
+                }
                 if(DEBUG_FAI_FUNC) { 
                   echo "<b>Copy current objects original attributes to next release</b> ".$key;
                   print_a($parent_attrs);
@@ -573,8 +574,9 @@ class FAI
 
 
   /* this function will remove all unused (deleted) objects,
-     that have no parent object */
-  static function clean_up_releases($Current_DN)
+     that have no parent object. If $recursive is set to true,
+     also check sub releases. */
+  static function clean_up_releases($Current_DN, $recursive=true)
   {
     global $config;
     $ldap = $config->get_ldap_link();
@@ -590,11 +592,14 @@ class FAI
     /* We must also include the given release dn */
     $previous_releases[] = $base_release;
 
-    /* Merge parent, current and child releases into one big release to 
-       iterate over */
     $all_releases = $previous_releases;
-    foreach($sub_releases as $sub_release){
-      $all_releases[] = $sub_release;
+
+    if ($recursive) {
+      /* Merge parent, current and child releases into one big release to 
+         iterate over */
+      foreach($sub_releases as $sub_release){
+        $all_releases[] = $sub_release;
+      }
     }
 
     /* Walk through all releases */
@@ -1288,8 +1293,8 @@ class FAI
     global $config;
     $Current_DN = $dn;
 
-    /* special case partitions, as they don't start with cn= in their DN (schema bug?) */
-    if (preg_match('/^FAIpartitionNr=/', $Current_DN)){
+    /* special case partitions and debconf variables, as they don't start with cn= in their DN */
+    if (preg_match('/^(FAIpartitionNr|FAIvariable)=/', $Current_DN)){
       return false;
     }
 
@@ -1337,8 +1342,8 @@ class FAI
     $tmp_dn = $Current_DN;
     $parent_dn = array();
 
-    /* special case partitions, as they don't start with cn= in their DN (schema bug?) */
-    $tmp_dn = preg_replace('/^FAIpartitionNr=/', 'cn=', $tmp_dn);
+    /* special case partitions and debconf variables, as they don't start with cn= in their DN */
+    $tmp_dn = preg_replace('/^(FAIpartitionNr|FAIvariable)=/', 'cn=', $tmp_dn);
 
     $tmp_dn = gosa_ldap_explode_dn($tmp_dn);
     while(preg_match('/^cn=/', $tmp_dn[$i])) {