X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servService.inc;h=1233484180d1b477faa62b5abf16a864dea77bcf;hb=ccaa264984e691fb1371b7e93e22e4fd9a2a6ba9;hp=15432a67467fc6245a471dfe3cb852973f896706;hpb=9661305ec872b58877cee3ac6b772134dcf7282c;p=gosa.git diff --git a/plugins/admin/systems/class_servService.inc b/plugins/admin/systems/class_servService.inc index 15432a674..123348418 100644 --- a/plugins/admin/systems/class_servService.inc +++ b/plugins/admin/systems/class_servService.inc @@ -8,6 +8,7 @@ class servservice extends plugin var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); var $goExportEntry = array(); + var $goExportEntryList= array(); var $goTimeSource = array(); var $goLdapBase = ""; var $goXdmcpIsEnabled = ""; @@ -40,10 +41,10 @@ class servservice extends plugin var $mounts_to_remove = array(); var $oldone = NULL; //temp dave for old mount entry - function servservice ($config, $dn= NULL) + function servservice ($config, $dn= NULL, $parent= NULL) { - plugin::plugin ($config, $dn); + plugin::plugin ($config, $dn, $parent); $ldap = $this->config->get_ldap_link(); $avl_objectclasses = $ldap->get_objectclasses(); @@ -69,19 +70,17 @@ class servservice extends plugin $this->$name= $tmp; } - $tmp =array(); $tmp2=array(); if(isset($this->attrs['goExportEntry'])){ - unset($this->attrs['goExportEntry']['count']); - if((isset($this->attrs['goExportEntry']))&&(isset($this->attrs['goExportEntry']))){ - foreach($this->attrs['goExportEntry'] as $entry){ - $tmp2= split("\|",$entry); - $tmp[$tmp2[0]]= $entry; + if(isset($this->attrs['goExportEntry']['count'])){ + for($i= 0; $i<$this->attrs['goExportEntry']['count']; $i++){ + $entry= $this->attrs['goExportEntry'][$i]; + $tmp[preg_replace('/\|.*$/', '', $entry)]= $entry; } } } - $this->goExportEntry = $tmp; + $this->goExportEntryList = $tmp; /* Always is account... */ $this->is_account= TRUE; @@ -96,11 +95,28 @@ class servservice extends plugin function addToList($entry){ $key = key($entry); - $this->goExportEntry[$key]=$entry[$key]; + $this->goExportEntryList[$key]=$entry[$key]; } function deleteFromList($id){ - unset($this->goExportEntry[$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.= "

"._("Please correct the share-/profile settings of these users"); + print_red($msg); + + } else { + /* Finally remove it */ + unset($this->goExportEntryList[$id]); + } } function addToMountList($entry) { @@ -122,19 +138,22 @@ class servservice extends plugin function execute() { - /* Call parent execute */ - plugin::execute(); + /* Call parent execute */ + plugin::execute(); /* Fill templating stuff */ $smarty= get_smarty(); - $smarty->assign("staticAddress", ""); - - if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntry']))){ + + if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntryList']))){ if($this->allow_mounts){ - $this->deleteFromMountList($this->goExportEntry[$_POST['goExportEntry']]); + foreach($_POST['goExportEntryList'] as $entry){ + $this->deleteFromMountList($this->goExportEntryList[$entry]); + } + } + foreach($_POST['goExportEntryList'] as $entry){ + $this->deleteFromList($entry); } - $this->deleteFromList($_POST['goExportEntry']); } if(isset($_POST['NewNfsAdd'])){ @@ -143,8 +162,8 @@ class servservice extends plugin $this->dialog = true; } - if((isset($_POST['NewNfsEdit']))&&(isset($_POST['goExportEntry']))){ - $entry = $this->goExportEntry[$_POST['goExportEntry']]; + if((isset($_POST['NewNfsEdit']))&&(isset($_POST['goExportEntryList']))){ + $entry = $this->goExportEntryList[$_POST['goExportEntryList'][0]]; $add_mount=isset($this->mounts_to_add[$entry]); $this->oldone=$entry; $this->o_subWindow = new servnfs($this->config,$this->acl,$this->allow_mounts,$this->dn,$entry,$add_mount); @@ -213,8 +232,8 @@ class servservice extends plugin } $tellSmarty=array(); - ksort($this->goExportEntry); - foreach($this->goExportEntry as $name=>$values){ + ksort($this->goExportEntryList); + foreach($this->goExportEntryList as $name=>$values){ $tmp = split("\|",$values); $tellSmarty[$name] = $tmp[0]." ".$tmp[4]." (".$tmp[2].")"; } @@ -347,10 +366,10 @@ class servservice extends plugin $this->attrs['objectClass']= $tmp; /* Arrays */ - foreach (array("goTimeSource", "goExportEntry") as $name){ - $this->attrs[$name]= array(); - foreach ($this->$name as $element){ - $this->attrs[$name][]= $element; + foreach (array("goTimeSource"=>"goTimeSource", "goExportEntryList"=>"goExportEntry") as $source => $destination){ + $this->attrs[$destination]= array(); + foreach ($this->$source as $element){ + $this->attrs[$destination][]= $element; } } @@ -374,12 +393,12 @@ class servservice extends plugin $this->cleanup(); $ldap->modify ($this->attrs); - show_ldap_error($ldap->get_error()); + show_ldap_error($ldap->get_error(), _("Saving server service object failed")); /* Optionally execute a command after we're done */ if ($this->initially_was_account == $this->is_account){ if ($this->is_modified){ - $this->handle_post_events("mofify"); + $this->handle_post_events("modify"); } } else { $this->handle_post_events("add"); @@ -405,7 +424,7 @@ class servservice extends plugin if (count($attrs) == 0) { $ldap->cd($mountsdn); $ldap->add($mounts); - show_ldap_error($ldap->get_error()); + show_ldap_error($ldap->get_error(), _("Creating mount container failed")); gosa_log("Mount container '$mountsdn' has been created"); } @@ -419,7 +438,7 @@ class servservice extends plugin if (count($attrs) != 0) { $ldap->rmdir($mountdn); - show_ldap_error($ldap->get_error()); + show_ldap_error($ldap->get_error(), _("Removing mount container failed")); gosa_log("Mount object '".$mountdn."' has been removed"); } } @@ -431,7 +450,7 @@ class servservice extends plugin $mountdn = "cn=".$mount["cn"].","."$mountsdn"; $ldap->cd($mountdn); $ldap->add($mount); - show_ldap_error($ldap->get_error()); + show_ldap_error($ldap->get_error(), _("Saving mount container failed")); gosa_log("Mount object '".$mountdn."' has been added"); } }