Code

Added colon to avoid classes with release names beeing matched.
[gosa.git] / gosa-plugins / fai / admin / systems / services / repository / class_servRepository.inc
index 349f28ef38ad32772f10583374c7161a6616979e..9dd3e82563b96ced92cb93aa51e2212a22778c04 100644 (file)
@@ -126,21 +126,21 @@ class servrepository extends goService
           $ldap->cd ($this->config->current['BASE']);
 
           $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass"));
+          $found= false;
           if ($ldap->count() != 0){
             $obj= array();
-            $found= false;
             while($attrs = $ldap->fetch()){
               foreach($attrs['FAIclass'] as $class){
-                if(preg_match("/".str_replace("/","\/",$release)."$/i",$class)){
+                if(preg_match("/:".str_replace("/","\/",$release)."$/i",$class)){
                   $obj[$ldap->getDN()]= $attrs['cn'][0];
                   $found= true;
                 }
               }
             }
+          }
 
-            if ($found){
-              msg_dialog::display(_("Error"), msgPool::stillInUse(_("FAI release"), msgPool::buildList($obj)), ERROR_DIALOG);
-            }
+          if ($found){
+            msg_dialog::display(_("Error"), msgPool::stillInUse(_("FAI release"), msgPool::buildList($obj)), ERROR_DIALOG);
           }else{
             if(isset($this->repositories[$value])){
               unset($this->repositories[$value]);
@@ -320,7 +320,7 @@ class servrepository extends goService
         $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_server_db']; 
         $tmp = new $evt['CLASS_NAME']($this->config);
         $tmp->set_type(TRIGGERED_EVENT);
-        $tmp->add_targets(array("GOsa"));
+        $tmp->add_targets(array("GOSA"));
         $o_queue = new gosaSupportDaemon();
         if(!$o_queue->append($tmp)){
           msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
@@ -330,6 +330,33 @@ class servrepository extends goService
   }
 
 
+  function allow_remove()
+  {
+    /* Check if the service is still in use 
+     */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    foreach($this->repositories as $repository) {
+      $url = $repository['Url'];
+      $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass"));
+      if ($ldap->count() != 0){
+        $obj= array();
+        $found= false;
+        while($attrs = $ldap->fetch()){
+          foreach($attrs['FAIclass'] as $class){
+            $obj[$ldap->getDN()]= $attrs['cn'][0];
+            $found= true;
+          }
+        }
+        if ($found){
+          $message = msgPool::stillInUse(_("Repository service")) . msgPool::buildList($obj);
+          return $message;
+        }
+      }
+    }
+  }
+
+
   function remove_from_parent()
   {
     goService::remove_from_parent();
@@ -353,11 +380,11 @@ class servrepository extends goService
 #            "stop"          => _("Service stop"),   // Remove this to hide the stop button at all.
 #            "restart"       => _("Service restart"),// Remove this to hide the restart button at all.
 
-            "cn"            => _("Name"),
-            "Release"       => _("Releases"),
-            "Section"       => _("Sections"),
+#            "cn"            => _("Name"),
             "ParentServer"  => _("Parent server"),
-            "Url"           => _("Url"))
+            "Release"       => _("Releases"),
+            "Url"           => _("URL"),
+            "Section"       => _("Sections"))
           ));
   }
 }