Code

Added allow_remove function for sub services.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Jan 2007 08:47:11 +0000 (08:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Jan 2007 08:47:11 +0000 (08:47 +0000)
Added allow_remove for goFon service, if still in use abort remove

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5509 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_goFonServer.inc
plugins/admin/systems/class_serverService.inc

index d4cdf76b5b7724216733c8df3650d8a8b45e3c79..5f23e21620d7e01286038543cca892bf9d67b2fa 100644 (file)
@@ -85,7 +85,39 @@ class goFonServer extends goService{
       plugin::save_object();
     }
   } 
-  
+
+
+  function allow_remove()
+  {
+    /* Check if we are able to remove the asterisk database. If the database is still in use skip */
+    if($this->is_account){
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->search("(&(goFonHomeServer=".$this->dn.")(|(uid=*)(cn=*)))",array("dn","uid","cn","goFonHomeServer"));
+      if($ldap->count()){
+
+        /* Number of entries shown in warning */
+        $i    = 3;
+        $str  = "";
+        while(($attrs = $ldap->fetch()) && $i >= 0){
+          $i --;
+          if(isset($attrs['uid'][0])){
+            $str .= $attrs['uid'][0]." ";
+          }else{
+            $str .= $attrs['cn'][0]." ";
+          }
+        }
+
+        /* Some entries found */
+        if($i != 3){
+          return(sprintf(_("You can't remove the asterisk database extension, it is still in use by these objects '%s'."),trim($str)));
+        }
+      }
+    }
+    return("fa");
+  }
+
   /* Return plugin informations for acl handling */
   function plInfo()
   {
index c6fe5415b98048d84e02d6bb63c32bd89dd97ce7..c74c8489b1b0602f98e92c537dd89435b44b8719 100644 (file)
@@ -126,8 +126,17 @@ class ServerService extends plugin
       $tmp     = $new_obj->getListEntry();
 
       if($tmp['AllowRemove']){
-        $this->plugins[$s_entry] = $new_obj;
-        $this->plugins[$s_entry]->is_account = false;
+
+        /* Check if we are allowed to remove this service
+         */
+        $str = $this->plugins[$s_entry]->allow_remove();
+
+        if(empty($str)){
+          $this->plugins[$s_entry] = $new_obj;
+          $this->plugins[$s_entry]->is_account = false;
+        }else{
+          print_red($str);
+        }
       }
     }
 
@@ -391,6 +400,18 @@ class ServerService extends plugin
       }
     }
   }
+
+
+  /* Check if all plugins allow a remove ..  */
+  function allow_remove()
+  {
+    foreach($this->plugins as $name => $obj){
+      $str = $obj->allow_remove();
+      if(!empty($str)){
+        return($str);
+      }
+    }
+  }
   
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: