Code

Fixed broken tags
[gosa.git] / plugins / admin / systems / class_workstationStartup.inc
index 5c1bb1d1ca0c7004e861086bfffc037033a08577..abc7ca682b5328764ebb7f5f22b0984f745ea2c0 100644 (file)
@@ -9,9 +9,9 @@ class workstartup extends plugin
   /* Generic terminal attributes */
   var $bootmode             = "G";
   var $goLdapServerList     = array();
-  var $gotoBootKernel       = "default";
+  var $gotoBootKernel       = "default-inherited";
   var $gotoKernelParameters = "";
-  var $gotoLdapServer       = "default";
+  var $gotoLdapServer       = "default-inherited";
   var $gotoModules          = array();
   var $gotoAutoFs           = array();
   var $gotoFilesystem       = array();
@@ -50,9 +50,9 @@ class workstartup extends plugin
   /* Contains all possible server/release/class settings */
   var $FAIServRepConfig   = array();
 
-  function workstartup ($config, $dn= NULL)
+  function workstartup ($config, $dn= NULL, $parent= NULL)
   {
-    plugin::plugin ($config, $dn);
+    plugin::plugin ($config, $dn, $parent);
 
     /* Creating a list of valid Mirrors 
      * none will not be saved to ldap.
@@ -263,7 +263,7 @@ class workstartup extends plugin
     $this->orig_dn= $this->dn;
 
     /* Handle inheritance value "default" */
-    $this->gotoBootKernels= array("%default%" => '['._("inherited").']');
+    $this->gotoBootKernels= array("default-inherited" => '['._("inherited").']');
 
 
     /* Load hardware list */
@@ -281,11 +281,11 @@ class workstartup extends plugin
 
         switch ($name){
           case 'gotoLdapServer':
-            $this->goLdapServerList= array_merge(array('default' => _("inherited").' ['.$attrs[$name][0].']' ), $this->goLdapServerList);
+            $this->goLdapServerList= array_merge(array('default-inherited' => _("inherited").' ['.$attrs[$name][0].']' ), $this->goLdapServerList);
             break;
 
           case 'gotoBootKernel':
-            $this->gotoBootKernels['%default%']=  _("inherited").' ['.$attrs[$name][0].']' ;
+            $this->gotoBootKernels['default-inherited']=  _("inherited").' ['.$attrs[$name][0].']' ;
             break;
 
           case 'FAIclass':
@@ -309,13 +309,23 @@ class workstartup extends plugin
         $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command,
             get_class($this));
       } else {
-        
         $fh= popen($command, "r");
         while (!feof($fh)) {
           $buffer= trim(fgets($fh, 256));
-          if ($buffer != ""){
-            $this->gotoBootKernels[preg_replace('/:.*$/', '', $buffer)]= $buffer;
+          
+          if(!empty($buffer)){
+          
+            $name=$value = $buffer;
+
+            if(preg_match("/:/",$buffer)){
+              $name = preg_replace("/:.*$/","",$buffer);
+              $value= preg_replace("/^.*:/","",$buffer);
+              $this->gotoBootKernels[$name]= $name.":".$value;
+            }else{
+              $this->gotoBootKernels[$name]= $value;
+            }
           }
+
         }
         pclose($fh);
       }
@@ -446,8 +456,12 @@ class workstartup extends plugin
        plugin::execute();
 
     /* Do we need to flip is_account state? */
-    if (isset($_POST['modify_state'])){
-      $this->is_account= !$this->is_account;
+    if(isset($_POST['modify_state'])){
+      if($this->is_account && $this->acl_is_removeable()){
+        $this->is_account= FALSE;
+      }elseif(!$this->is_account && $this->acl_is_createable()){
+        $this->is_account= TRUE;
+      }
     }
 
     /* Do we represent a valid terminal? */
@@ -459,20 +473,20 @@ class workstartup extends plugin
 
     /* Add module */
     if (isset ($_POST['add_module'])){
-      if ($_POST['module'] != "" && chkacl ($this->acl, "gotoModule") == ""){
+      if ($_POST['module'] != "" && $this->acl_is_writeable("gotoModule")){
         $this->add_list ($this->gotoModules, $_POST['module']);
       }
     }
 
     /* Delete module */
     if (isset ($_POST['delete_module'])){
-      if (count($_POST['modules_list']) && chkacl ($this->acl, "gotoModule") == ""){
+      if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoModule")){
         $this->del_list ($this->gotoModules, $_POST['modules_list']);
       }
     }
 
     /* FAI class management */
-    if((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))){
+    if(((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))) && ($this->acl_is_writeable("FAIclass"))){
       $found = 0 ; 
 
       /* If this new class/profile will attach a second partition table
@@ -498,78 +512,91 @@ class workstartup extends plugin
     }
 
     $sort = false;
-    foreach($_POST as $name => $val){
-      
-      $sort_type = false;
-      if((preg_match("/sort_up/",$name))&&(!$sort)){
-        $sort_type = "sort_up_";
-      }
-      if((preg_match("/sort_down/",$name))&&(!$sort)){
-        $sort_type = "sort_down_";
-      }
-    
-      if(($sort_type)&&(!$sort)){
-        $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name)));
-        $sort = true;
-        
-        $last = -1;
-        $change_down  = -1;
-        /* Create array with numeric index */ 
-        $tmp = array();
-        foreach($this->FAIclass as $class){
-          $tmp [] = $class;
+
+    /* Move one used class class one position up or down */
+    if($this->acl_is_writeable("FAIclass")){
+      foreach($_POST as $name => $val){
+
+        $sort_type = false;
+        if((preg_match("/sort_up/",$name))&&(!$sort)){
+          $sort_type = "sort_up_";
+        }
+        if((preg_match("/sort_down/",$name))&&(!$sort)){
+          $sort_type = "sort_down_";
         }
 
-        /* Walk trough array */
-        foreach($tmp as $key => $faiName){
-          if($faiName == $value){
-            if($sort_type == "sort_up_"){
-              if($last != -1){
-                 $change_down= $last;
-              }
-            }else{
-              if(isset($tmp[$key+1])){
-                $change_down = $key;
+        if(($sort_type)&&(!$sort)){
+          $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name)));
+          $sort = true;
+
+          $last = -1;
+          $change_down  = -1;
+
+          /* Create array with numeric index */ 
+          $tmp = array();
+          foreach($this->FAIclass as $class){
+            $tmp [] = $class;
+          }
+
+          /* Walk trough array */
+          foreach($tmp as $key => $faiName){
+            if($faiName == $value){
+              if($sort_type == "sort_up_"){
+                if($last != -1){
+                  $change_down= $last;
+                }
+              }else{
+                if(isset($tmp[$key+1])){
+                  $change_down = $key;
+                }
               }
             }
+            $last = $key;
           }
-          $last = $key;
+
+          $tmp2 = array();
+          $skip = false;    
+
+          foreach($tmp as $ky => $vl){
+
+            if($ky == $change_down){
+              $skip = $vl;
+            }else{
+              $tmp2[$vl] = $vl;
+            }
+            if(($skip != false)&&($ky != $change_down)){
+              $tmp2[$skip]  = $skip;
+              $skip =false;
+            }
+          }   
+          $this->FAIclass = $tmp2; 
         }
-        $tmp2 = array();
-        $skip = false;    
-  
-        foreach($tmp as $ky => $vl){
 
-          if($ky == $change_down){
-            $skip = $vl;
-          }else{
-            $tmp2[$vl] = $vl;
-          }
-          if(($skip != false)&&($ky != $change_down)){
-            $tmp2[$skip]  = $skip;
-            $skip =false;
-          }
-        }   
-        $this->FAIclass = $tmp2; 
-      }
-  
-      if(preg_match("/fai_remove/i",$name)){
-        $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/fai_remove_/i","",$name)));
-        unset($this->FAIclass[$value]);
+        if(preg_match("/fai_remove/i",$name)){
+          $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/fai_remove_/i","",$name)));
+          unset($this->FAIclass[$value]);
+        }
       }
     }
 
     /* Delete selected class from our list */
-    if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){
-      if(isset($this->FAIclass[$_POST['FAIclassSel']])){
-        unset($this->FAIclass[$_POST['FAIclassSel']]);
+    if($this->acl_is_writeable("FAIclass")){
+      if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){
+        if(isset($this->FAIclass[$_POST['FAIclassSel']])){
+          unset($this->FAIclass[$_POST['FAIclassSel']]);
+        }
       }
     }
 
     /* Show main page */
     $smarty= get_smarty();
+
+    /* Assign ACLs to smarty */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    } 
+
     $smarty->assign("SelectBoxLdapServer","");
 
     /* In this section server shares will be defined
@@ -582,7 +609,7 @@ class workstartup extends plugin
     /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry
      * This entry will be, a combination of mountPoint and sharedefinitions
      */
-    if(isset($_POST['gotoShareAdd'])){
+    if((isset($_POST['gotoShareAdd'])) && ($this->acl_is_writeable("gotoShare"))) {
       /* We assign a share to this user, if we don't know where to mount the share */
       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
         print_red(_("You must specify a valid mount point."));
@@ -600,7 +627,7 @@ class workstartup extends plugin
     /* if the Post  gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected)
      * If there is no defined share selected, we will abort the deletion without any message
      */
-    if((isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){
+    if(($this->acl_is_writeable("gotoShare"))&& (isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){
       unset($this->gotoShares[$_POST['gotoShare']]);
     }
 
@@ -648,7 +675,6 @@ class workstartup extends plugin
 
     $smarty->assign("SelectBoxLdapServer",$SelectBoxLdapServer->DrawList());
 
-    $smarty->assign("gotoLdapServerACL", chkacl($this->acl, "gotoLdapServer"));
     foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
       $smarty->assign("$val", $this->$val);
     }
@@ -656,7 +682,6 @@ class workstartup extends plugin
     /* Values */
     foreach(array("gotoBootKernel", "customParameters", "gotoShare","FAIclasses","FAIclass","FAIdebianMirror","FAIrelease") as $val){
       $smarty->assign($val, $this->$val);
-      $smarty->assign($val."ACL", chkacl($this->acl, $val));
     }
 
     $smarty->assign("FAIdebianMirrors",$this->getFAIdebianMirrors());
@@ -665,8 +690,13 @@ class workstartup extends plugin
     $smarty->assign("FAIclasses",$this->selectFriendlyClasses());
     $smarty->assign("FAIclassesKeys",array_flip($this->selectFriendlyClasses()));
     $smarty->assign("FAIclassKeys",$this->FAIclass);
-    $smarty->assign("InheritedFAIrelease",$this->InheritedFAIrelease);
-    
+  
+    $inheritedRelease = array();
+    if(!empty($this->InheritedFAIrelease)){
+      $inheritedRelease[$this->InheritedFAIrelease]= $this->InheritedFAIrelease;
+    } 
+    $smarty->assign("InheritedFAIrelease",$inheritedRelease);
     $div = new divSelectBox("WSFAIscriptClasses");
     $div -> SetHeight("110");
     $str_up     = " &nbsp;<input type='image' src='images/sort_up.png'    name='sort_up_%s'    value='%s'>";
@@ -722,11 +752,6 @@ class workstartup extends plugin
       $smarty->assign("debugbootup", "");
     }
 
-    /* ACL's */
-    foreach (array("gotoKernelParameters", "gotoModules", "gotoFilesystem","FAIclass") as $value){
-      $smarty->assign($value."ACL", chkacl($this->acl, "$value"));
-    }
-
     /* Show main page */
     return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE,dirname(__FILE__))));
   }
@@ -854,12 +879,12 @@ class workstartup extends plugin
     plugin::save_object();
 
     /* Save group radio buttons */
-    if (chkacl ($this->acl, "bootmode") == "" && isset($_POST["bootmode"])){
+    if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){
       $this->bootmode= $_POST["bootmode"];
     }
 
     /* Save kernel parameters */
-    if (chkacl ($this->acl, "gotoKernelParameters") == "" && isset($_POST["customParameters"])){
+    if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){
       $this->customParameters= $_POST["customParameters"];
     }
 
@@ -966,11 +991,11 @@ class workstartup extends plugin
     }
 
     /* Strip out 'default' values */
-    if ($this->attrs['gotoLdapServer'] == "default"){
+    if ($this->attrs['gotoLdapServer'] == "default-inherited"){
       $this->attrs['gotoLdapServer']= array();
     }
 
-    if (($this->attrs['gotoBootKernel'] == "default") || ($this->attrs['gotoBootKernel'] == "%default%")){
+    if (($this->attrs['gotoBootKernel'] == "default-inherited") || ($this->attrs['gotoBootKernel'] == "%default%")){
       $this->attrs['gotoBootKernel']= array();
     }
 
@@ -987,13 +1012,6 @@ class workstartup extends plugin
 
     /* Remove FAI objects if no FAI class is selected */ 
     if((count($this->FAIclass)==0) && (!isset($checkFAIstate['FAIstate']))){
-      $tmp = array();
-      foreach($this->attrs['objectClass'] as $class){
-        if($class != "FAIobject"){
-          $tmp[] = $class;
-        }
-      }
-      $this->attrs['objectClass']     = $tmp;
       $this->attrs['FAIclass']        = array();
       $this->attrs['FAIdebianMirror'] = array();
     }
@@ -1085,17 +1103,21 @@ class workstartup extends plugin
           "plDepends"     => array(),
           "plPriority"    => 0,
           "plSection"     => array("administration"),           
-          "plCategory"    => array("workstation","server"),
+          "plCategory"    => array("workstation","server","ogroups"),
 
           "plProvidedAcls"=> array(
             "gotoLdapServer"        => _("Ldap server"),
             "gotoBootKernel"        => _("Boot kernel"),
             "gotoKernelParameters"  => _("Kernel parameter"),
-            "FAIclass"              => _("FAI classes"),
-            "FAIstatus"             => _("FAI status flag"),
+
+            "gotoModules"           => _("Kernel modules"),
             "gotoShare"             => _("Shares"),
+
+            "FAIclass"              => _("FAI classes"),
             "FAIdebianMirror"       => _("Debian mirror"),
-            "FAIrelease"            => _("Debian release"))
+            "FAIrelease"            => _("Debian release"),
+
+            "FAIstatus"             => _("FAI status flag")) // #FIXME is this acl realy necessary ?
           ));
   }
 }