Code

Revert 13752 because it might cause data loss
authorpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 22 Jun 2009 10:30:15 +0000 (10:30 +0000)
committerpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 22 Jun 2009 10:30:15 +0000 (10:30 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13754 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index ead485cb1b98790720e45c0f6a5ab9e0bb6ed4df..7cfb966cc671c30d73154f39b713594989842182 100644 (file)
@@ -185,12 +185,10 @@ class FAI
     if(!$removed){
       $ldap = $config->get_ldap_link();
       $ldap->cd($config->current['BASE']);
-      $parent_dn = FAI::get_parent_object($Current_DN);
 
       /* Get some basic informations */
       $parent_obj   = FAI::get_parent_release_object($Current_DN);
-      /* Check whether parent object is removed, do not create object in this case */
-      if(!empty($parent_obj) && !FAI::parent_is_removed($Current_DN)){
+      if(!empty($parent_obj)){
         $ldap->cat($parent_obj,array("*"));
         $attrs = FAI::                           prepare_ldap_fetch_to_be_saved($ldap->fetch());
 
@@ -505,10 +503,7 @@ class FAI
                 echo "<b>Create an empty placeholder in follwing release</b> ".$key; 
                 print_a($objectAttrs);
               }
-              /* Only save removed parent objects, not their children */
-              if (FAI::is_parent_object($Current_DN)){
-                FAI::save_FAI_object($key,$objectAttrs);
-              }
+              FAI::save_FAI_object($key,$objectAttrs);
             }
           }
         }else{
@@ -522,15 +517,11 @@ class FAI
                 print_a($parent_attrs);
               }
              
-              /* 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;
-                FAI::save_FAI_object($key,$parent_attrs);
-              }
+              /* Append FAIstate tag to ensure that freezed objects stay freezed
+               */ 
+              $rTag = FAI::get_release_tag(FAI::get_release_dn($key));
+              $parent_attrs['FAIstate'] = $rTag;
+              FAI::save_FAI_object($key,$parent_attrs);
             }
           }
 
@@ -1279,101 +1270,7 @@ class FAI
     }                                                         
   }                                                           
 
-  /* Returns true if this is a parent object, e.g. FAIpartitionTable, not FAIpartitionDisk */
-  static function is_parent_object($dn)
-  {
-    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)){
-      return false;
-    }
-
-    $parent_dn = preg_replace('/^cn=[^,.]*,/', '', $Current_DN);
-    if (preg_match('/^cn=/', $parent_dn)) {
-      $ldap = $config->get_ldap_link();
-      $ldap->cd($config->current['BASE']);
-      $ldap->cat($parent_dn);
-      if($ldap->count()){
-        return false;
-      }
-    }else{
-      return true;
-    }
-  }
-
-  /* Return a child objects, if there are any */
-  static function get_child_objects($dn)
-  {
-    global $config;
-    $Current_DN = $dn;
-
-    if (FAI::is_parent_object($Current_DN)){
-      $ldap = $config->get_ldap_link();
-      $ldap->cd($config->current['BASE']);
-      $ldap->search("(objectClass=FAIclass)",array("dn"));
-      while($attrs = $ldap->fetch()){
-        $newdn=$attrs['dn'];
-        if(preg_match("/".preg_quote($Current_DN, '/')."/",$attrs['dn']) && $attrs['dn'] != $Current_DN){
-          $children[] = $attrs['dn'];
-        }
-      }
-    }else{
-      $children[] = array();
-    }
-    return $children;
-  }
-
-  /* Get the DN of the parent object; e.g. the FAIpartitionTable of a FAIpartitionDisk */
-  static function get_parent_object($dn)
-  {
-    global $config;
-    $Current_DN = $dn;
-
-    $tmp_dn = $Current_DN;
-    $parent_dn = $tmp_dn;
-
-    /* special case partitions, as they don't start with cn= in their DN (schema bug?) */
-    $tmp_dn = preg_replace('/^FAIpartitionNr=/', 'cn=', $tmp_dn);
 
-    while (preg_match('/^cn=/', $tmp_dn)){
-      $parent_dn = $tmp_dn;
-      $tmp_dn = preg_replace('/^cn=[^,.]*,/', '', $parent_dn);
-    }
-    if ($parent_dn != $Current_DN){
-      $ldap = $config->get_ldap_link();
-      $ldap->cd($config->current['BASE']);
-      $ldap->cat($parent_dn);
-
-      /* Check objectClasses and name to check if this is a release department */
-      if($ldap->count()){
-        return $parent_dn;
-      }
-    }
-    return "";
-  }
-
-  /* Check whether parent object is removed */
-  static function parent_is_removed($dn)
-  {
-    global $config;
-    $Current_DN = $dn;
-
-    $ldap = $config->get_ldap_link();
-    $parent_dn = FAI::get_parent_object($Current_DN);
-    if ($parent_dn) { 
-      $ldap->cd($config->current['BASE']);
-      $ldap->cat($parent_dn);
-      $parentObjectAttrs = FAI::prepare_ldap_fetch_to_be_saved($ldap->fetch());
-      if(isset($parentObjectAttrs['FAIstate'][0])){
-        if(preg_match("/removed$/",$parentObjectAttrs['FAIstate'][0])){
-          return true;
-        }
-      }
-    } 
-    return false;
-  }
 }
 
 
index 1ff814304be43717f18eb8ad0750e5f33e45ae62..4a20ab0e7ab7eede35916161b873cf317123e6eb 100644 (file)
@@ -328,8 +328,6 @@ class faiManagement extends plugin
           $this->dialog= FALSE;
           FAI::save_release_changes_now();
           $to_del = FAI::clean_up_releases($dn);
-          /* Remove sub-objects (e.g. the variable key/value of a FAIvariable) from LDAP entirely */
-          $to_del += FAI::get_child_objects($dn);
           foreach($to_del as $dn){
             $ldap->rmdir_recursive($dn);
           }