Code

Fix repository deleting
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 30 Oct 2009 10:52:59 +0000 (10:52 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 30 Oct 2009 10:52:59 +0000 (10:52 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14714 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/systems/services/repository/class_servRepository.inc

index 9dd3e82563b96ced92cb93aa51e2212a22778c04..ecf2d923a21e99cd43fa98763f6b249c672c1777 100644 (file)
@@ -125,20 +125,56 @@ class servrepository extends goService
           $ldap = $this->config->get_ldap_link();
           $ldap->cd ($this->config->current['BASE']);
 
-          $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass"));
           $found= false;
+          $auto= false;
+          $obj= array();
+          $aobj= array();
+
+          $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(|(FAIdebianMirror=".$url.")(FAIdebianMirror=auto)))",array("cn","FAIclass", "FAIdebianMirror"));
           if ($ldap->count() != 0){
-            $obj= array();
             while($attrs = $ldap->fetch()){
+              if (!isset($attrs['FAIclass'])){
+                continue;
+              }
               foreach($attrs['FAIclass'] as $class){
                 if(preg_match("/:".str_replace("/","\/",$release)."$/i",$class)){
-                  $obj[$ldap->getDN()]= $attrs['cn'][0];
-                  $found= true;
+                  if (isset($attrs['FAIdebianMirror'][0]) && $attrs['FAIdebianMirror'][0] == "auto") {
+                    $aobj[$ldap->getDN()]= $attrs['cn'][0];
+                    $auto= true;
+                  } else {
+                    $obj[$ldap->getDN()]= $attrs['cn'][0];
+                    $found= true;
+                  }
                 }
               }
             }
           }
 
+          // Look for automatic releases
+          if ($auto) {
+            $usage= 0;
+            $ldap->search("(&(objectClass=FAIrepositoryServer))",array("FAIrepository"));
+            if ($ldap->count() != 0){
+              while($sattrs = $ldap->fetch()){
+                if (!isset($sattrs['FAIrepository'])){
+                  continue;
+                }
+                for ($i= 0; $i < $sattrs['FAIrepository']['count']; $i++){
+                  $t= split('\|', $sattrs['FAIrepository'][$i]);
+                  if($release == $t[2]){
+                    $usage++;
+                  }
+                }
+              }
+
+              // Are we the last one to provide this release?
+              if ($usage < 2) {
+                $obj= array_merge($obj, $aobj);
+                $found= true;
+              }
+            } 
+          }
+
           if ($found){
             msg_dialog::display(_("Error"), msgPool::stillInUse(_("FAI release"), msgPool::buildList($obj)), ERROR_DIALOG);
           }else{