Code

Implemented gen_cd image into trunk
[gosa.git] / plugins / admin / systems / class_goShareServer.inc
index 5bfe63424829bfb9c29cbc9ed582b80543dbf893..5f580dde93e6d69bc6555e0bbb4f843506252a28 100644 (file)
@@ -55,7 +55,7 @@ class goShareServer extends goService{
     $smarty = get_smarty(); 
 
 
-    if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntryList']))){
+    if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntryList'])) && ($this->acl_is_writeable("name"))){
       if($this->allow_mounts){
         foreach($_POST['goExportEntryList'] as $entry){
           $this->deleteFromMountList($this->goExportEntryList[$entry]);
@@ -66,7 +66,7 @@ class goShareServer extends goService{
       }
     }
 
-    if(isset($_POST['NewNfsAdd'])){
+    if(isset($_POST['NewNfsAdd']) && ($this->acl_is_writeable("name"))){
       $this->oldone = NULL;
       $this->o_subWindow = new servnfs($this->config, $this);
       $this->o_subWindow->set_acl_category("server");
@@ -96,6 +96,7 @@ class goShareServer extends goService{
       }else{
         $this->o_subWindow->save_object();
         $newone = $this->o_subWindow->save();
+
         $this->addToList($newone);
         if($this->allow_mounts){
           if($this->oldone) {
@@ -128,11 +129,9 @@ class goShareServer extends goService{
 
     /* Set acls */
     $tmp = $this->plInfo();
-    $acl = ""; 
     foreach($tmp['plProvidedAcls'] as $name => $translated){
-      $acl .= $this->getacl($name);
+      $smarty->assign($name."ACL",$this->getacl($name));
     }
-    $smarty->assign("goExportEntryACL",$acl);
     $smarty->assign("createable",$this->acl_is_createable());
     $smarty->assign("removeable",$this->acl_is_removeable());
 
@@ -213,8 +212,26 @@ class goShareServer extends goService{
     $this->goExportEntryList[$key]=$entry[$key];
   }
 
-  function deleteFromList($id){
-    unset($this->goExportEntryList[$id]);
+  function deleteFromList($id)
+  {
+    /* Check if the share is used by someone */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(|(gotoProfileServer=*|$id)(gotoShare=*|$id|*))", array("cn"));
+    $cnt= $ldap->count();
+    if ($cnt){
+      $msg= sprintf(_("The share can't be removed since it is still used by %d users:"), $cnt);
+      $msg.= "<br><br><ul>";
+      while ($attrs= $ldap->fetch()){
+        $msg.= "<li>".$attrs["cn"][0]."</li>";
+      }
+      $msg.= "</ul>"._("Please correct the share-/profile settings of these users");
+      print_red($msg);
+
+    } else {
+      /* Finally remove it */
+      unset($this->goExportEntryList[$id]);
+    }
   }
 
    function process_mounts() {
@@ -268,20 +285,24 @@ class goShareServer extends goService{
 
   function addToMountList($entry) 
   {
-    $key =  key($entry);
-    $type = $this->get_share_type($entry[$key]);
-    if (($type == "netatalk") || ($type == "NFS")) {
-      $this->mounts_to_add[$entry[$key]] = $entry[$key];
-      unset($this->mounts_to_remove[$entry[$key]]);
+    if($this->acl_is_writeable("name")){
+      $key =  key($entry);
+      $type = $this->get_share_type($entry[$key]);
+      if (($type == "netatalk") || ($type == "NFS")) {
+        $this->mounts_to_add[$entry[$key]] = $entry[$key];
+        unset($this->mounts_to_remove[$entry[$key]]);
+      }
     }
   }
 
   function deleteFromMountList($entry) 
   {
-    $type = $this->get_share_type($entry);
-    if (($type == "netatalk") || ($type == "NFS")) {
-      $this->mounts_to_remove[$entry] = $entry;
-      unset($this->mounts_to_add[$entry]);
+    if($this->acl_is_writeable("name")){
+      $type = $this->get_share_type($entry);
+      if (($type == "netatalk") || ($type == "NFS")) {
+        $this->mounts_to_remove[$entry] = $entry;
+        unset($this->mounts_to_add[$entry]);
+      }
     }
   }
 
@@ -337,11 +358,11 @@ class goShareServer extends goService{
   function plInfo()
   {
     return (array(
-          "plShortName"   => _("Shares"),
-          "plDescription" => _("Share service"),
+          "plShortName"   => _("File service (Shares)"),
+          "plDescription" => _("File service - Shares")." ("._("Services").")",
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 90,
           "plSection"     => array("administration"),
           "plCategory"    => array("server"),