Code

Add a allow_remove function to the goShareServer class
[gosa.git] / trunk / gosa-plugins / goto / admin / systems / services / shares / class_goShareServer.inc
index 833239a230670617e8d20440761ec5dcfc6341c0..7d7b05d9a7b19bf7881c1178d6dbd2edab8586d1 100644 (file)
@@ -215,6 +215,29 @@ class goShareServer 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']);
+    $cn = $ldap->getCn($this->dn);
+    $ldap->search("(&(|(objectClass=posixGroup)(objectClass=posixAccount))(gotoShare=$cn|*))", array("dn"));
+
+    if($ldap->count()){
+      /* Number of entries shown in warning */
+      $i    = 3;
+      $str  = '<p>';
+      while(($attrs = $ldap->fetch()) && $i >= 0){
+        $i --;
+        if(isset($attrs['dn'])){
+          $str .= '<i>' . $attrs['dn']."</i><br/>";
+        }
+      }
+      $str .= '</p>';
+      return(sprintf(_("Cannot remove share - it is still in use by these objects: %s"), $str));
+      }
+  }
+
   function addToList($entry){
     $key =  key($entry);
     $this->goExportEntryList[$key]=$entry[$key];