Code

Added gray out to navigation icons in divlist
[gosa.git] / plugins / admin / systems / class_serverService.inc
index 57138cca822a692c1887f988ebdad9f2e9fb58f0..c6fe5415b98048d84e02d6bb63c32bd89dd97ce7 100644 (file)
@@ -37,19 +37,29 @@ class ServerService extends plugin
   {
     plugin::plugin($config);
     $this->dn= $dn;
-    $ui= get_userinfo();
-    $this->acl= get_permissions ($ui->dn, $ui->subtreeACL);
-
     foreach ($config->data['TABS']['SERVERSERVICE'] as $plug){
       $name= $plug['CLASS'];
       $this->plugin_names[]= $name;
       $this->plugins[$name]= new $name($config, $dn);
-      $this->plugins[$name]->acl= get_module_permission($this->acl, "$name", $ui->dn);
     }
-    
     $this->divList = new divListSystemService($config,$this);
        }
 
+  function set_acl_base($base)
+  {
+    plugin::set_acl_base($base);
+    foreach($this->plugins as $name => $obj){
+      $this->plugins[$name]->set_acl_base($base);
+    }
+  }
+
+  function set_acl_category($category)
+  {
+    plugin::set_acl_category($category);
+    foreach($this->plugins as $name => $obj){
+      $this->plugins[$name]->set_acl_category($category);
+    }
+  }
 
   function execute()
   {
@@ -87,11 +97,12 @@ class ServerService extends plugin
 
 
     /* Handle state changes for services */
-    $map =  array( "startServices"          => array("type" => START_SERVICE , "service" => ALL_SERVICES),
-                      "stopServices"          => array("type" => STOP_SERVICE  , "service" => ALL_SERVICES),
-                      "restartServices"         => array("type" => RESTART_SERVICE , "service" => ALL_SERVICES),                      "StartSingleService"    => array("type" => START_SERVICE , "service" => $s_entry),
-                      "StopSingleService"     => array("type" => STOP_SERVICE , "service" => $s_entry),
-                      "RestartSingleService"    => array("type" => RESTART_SERVICE , "service" => $s_entry));
+    $map =  array(    "startServices"         => array("type" => START_SERVICE ,   "service" => ALL_SERVICES),
+                      "stopServices"          => array("type" => STOP_SERVICE  ,   "service" => ALL_SERVICES),
+                      "restartServices"       => array("type" => RESTART_SERVICE , "service" => ALL_SERVICES),                 
+                      "StartSingleService"    => array("type" => START_SERVICE ,   "service" => $s_entry),
+                      "StopSingleService"     => array("type" => STOP_SERVICE ,    "service" => $s_entry),
+                      "RestartSingleService"  => array("type" => RESTART_SERVICE , "service" => $s_entry));
     if(isset($map[$s_action])){
       $type     = $map[$s_action]['type'];
       $service  = $map[$s_action]['service'];
@@ -107,11 +118,17 @@ class ServerService extends plugin
 
     /* Remove service */
     if($s_action == "RemoveSingleService"){
-      $this->plugins[$s_entry]->is_account= false;
-      $this->plugins[$s_entry] = NULL;
-      $this->plugins[$s_entry] = new $s_entry($this->config,$this->dn);
-      $this->plugins[$s_entry]->acl = $this->acl;
-      $this->plugins[$s_entry]->is_account = false;
+
+      /* Create resetted obj */
+      $new_obj = new $s_entry($this->config,$this->dn);
+      $new_obj -> set_acl_base($this->acl_base);
+      $new_obj -> set_acl_category(preg_replace("/\/$/","",$this->acl_category));
+      $tmp     = $new_obj->getListEntry();
+
+      if($tmp['AllowRemove']){
+        $this->plugins[$s_entry] = $new_obj;
+        $this->plugins[$s_entry]->is_account = false;
+      }
     }
 
 
@@ -137,6 +154,9 @@ class ServerService extends plugin
     if(isset($_POST['CancelService'])){
       if($this->backup == NULL){
         $this->plugins[$this->current] = new $this->current($this->config,$this->dn);
+        $this->plugins[$this->current]-> set_acl_base($this->acl_base);
+        $this->plugins[$this->current]-> set_acl_category(preg_replace("/\/$/","",$this->acl_category));
+
       }else{
         foreach($this->backup as $name => $value){
           $this->plugins[$this->current]->$name = $value;
@@ -241,6 +261,12 @@ class ServerService extends plugin
           }
         }
       }
+
+      /* Only show createable services */
+      if(!$obj->acl_is_createable()){
+        $skip = true;
+      }
+
       if(!$skip){
         if(isset($obj->DisplayName)){
           $ret[$name] = $obj->DisplayName;