Code

Removed duplicated post call
[gosa.git] / plugins / admin / systems / class_terminalService.inc
index b5f15380a04e0b6d94f714d27a5d252f3df6a613..2be95df7957e78c00dc78fec861bde405badcf05 100644 (file)
@@ -30,6 +30,8 @@ class termservice extends plugin
   var $gotoScannerBackend= "";
   var $goFonHardware= "automatic";
 
+  var $AutoSync = false;
+
   /* Needed values and lists */
   var $ignore_account= TRUE;
   var $base= "";
@@ -62,9 +64,9 @@ class termservice extends plugin
   var $objectclasses= array("GOhard");
 
 
-  function termservice ($config, $dn= NULL)
+  function termservice ($config, $dn= NULL, $parent= NULL)
   {
-    plugin::plugin ($config, $dn);
+    plugin::plugin ($config, $dn, $parent);
     
     array_unshift($this->XDrivers, "["._("unknown")."]");
     
@@ -112,7 +114,7 @@ class termservice extends plugin
       $this->XKbModels[$type] = $type;
     }
 
-    /* Additional values will be extracted from /etc/gosa/keyboardLayouts */
+    /* Additional values will be extracted from CONFIG_DIR.keyboardLayouts */
     $this->XKbLayouts= array ("default"=>"["._("inherited")."]","de"=> "de","intl" =>"intl","us" =>"us");
     $this->XKbVariants= array ("default"=>"["._("inherited")."]", "nodeadkeys"=>"nodeadkeys", "basic"=>"basic");
 
@@ -194,8 +196,10 @@ class termservice extends plugin
     $this->hardware_list["automatic"]= _("automatic");
     ksort($this->hardware_list);
 
+    /* Convert gotoLpdEnable */
+    $this->gotoLpdEnable= preg_match("/yes/i",$this->gotoLpdEnable);
 
-      /* Load hardware list */
+    /* Load hardware list */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
     $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))");
@@ -234,6 +238,15 @@ class termservice extends plugin
         }
       }
     }
+    if(preg_match("/\+/",$this->gotoXHsync)){
+      $this->AutoSync = true;
+      $this->gotoXHsync = preg_replace("/\+/","-",$this->gotoXHsync);
+      $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync);
+    }
+
+    if($this->is_account){
+      @log::log("view","terminal/".get_class($this),$this->dn);
+    }
   }
 
   function execute()
@@ -256,6 +269,13 @@ class termservice extends plugin
     /* Show main page */
     $smarty= get_smarty();
 
+    /* Assign acls */
+    $tmp= $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+
     /* Arrays */ 
     foreach(array("XMethods", "XDrivers", "XResolutions", "XColordepths",
           "gotoScannerModels", "XKbModels","XKbVariants",
@@ -277,13 +297,11 @@ class termservice extends plugin
           "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){
 
       $smarty->assign($val."_select", $this->$val);
-      $smarty->assign($val."ACL", chkacl($this->acl, $val));
     }
 
     /* Variables */
     foreach(array("gotoXHsync", "gotoXVsync") as $val){
       $smarty->assign($val, $this->$val);
-      $smarty->assign($val."ACL", chkacl($this->acl, $val));
     }
     $smarty->assign("staticAddress", "");
 
@@ -294,14 +312,12 @@ class termservice extends plugin
       } else {
         $smarty->assign("$val", "");
       }
-      $smarty->assign($val."ACL", chkacl($this->acl, "gotoLpdEnable"));
     }
 
     /* Phone stuff */
     $smarty->assign ("goFonHardware", $this->goFonHardware);
     $hl= "<select size=\"1\" name=\"goFonHardware\" title=\"".
-         _("Choose the phone located at the current terminal")."\" ".
-         chkacl($this->acl, "goFonHardware").">\n";
+         _("Choose the phone located at the current terminal")."\" >\n";
     foreach ($this->hardware_list as $cn => $description){
       if ($cn == $this->goFonHardware){
         $selected= "selected";
@@ -319,12 +335,22 @@ class termservice extends plugin
     $smarty->assign ("hardware_list", $hl);
     $smarty->assign ("gotoXMonitor", $this->gotoXMonitor);
 
+    $smarty->assign("AutoSyncACL",$this->getacl("AutoSync"));
+
+    $smarty->assign("AutoSyncCHK"," ");
+    if($this->AutoSync){
+      $smarty->assign("AutoSyncCHK"," checked ");
+      $smarty->assign("gotoXVsyncACL", preg_replace("/w/","",$this->getacl("gotoXVsync")));
+      $smarty->assign("gotoXHsyncACL", preg_replace("/w/","",$this->getacl("gotoXHsync")));
+    }
+
     /* Show main page */
     return($smarty->fetch (get_template_path('terminalService.tpl', TRUE)));
   }
 
   function remove_from_parent()
   {
+    @log::log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs));
     $this->handle_post_events("remove");
   }
 
@@ -338,55 +364,67 @@ class termservice extends plugin
     if (isset ($_POST['gotoXMethod'])){
       foreach (array("gotoLpdEnable", "gotoScannerEnable") as $val){
 
-        if (!isset ($_POST["$val"]) && chkacl ($this->acl, "$val") == ""){
-          $this->$val= FALSE;
-        } else {
-          $this->$val= TRUE;
+        if($this->acl_is_writeable($val)){
+          if (!isset ($_POST["$val"])){
+            $this->$val= FALSE;
+          } else {
+            $this->$val= TRUE;
+          }
         }
       }
-    }
-  }
+    } 
 
-
-  /* Check supplied data */
-  function check()
-  {
-    /* Call common method to give check the hook */
-    $message= plugin::check();
+    if(isset($_POST['gotoXDriver'])){
+      if(isset($_POST['AutoSync'])){
+        $this->AutoSync = true;
+      }else{
+        $this->AutoSync = false;
+      }
+    }
 
     /* Default entries can use blank hsync/vsync entries */
-    if ($this->dn != "" && $this->cn != "default" && $this->cn != "wdefault"){
-
-      /* Check vsync for correct usage */
-      $val= preg_replace ("/\s/", "", $this->gotoXVsync);
-      if (!preg_match ("/^\d+(\.\d+)?(\-\d+(\.\d+)?)?$/", $val)
-          && chkacl ($this->acl, "gotoXVsync") == ""){
-
-        $message[]= _("Please specify a valid VSync range.");
-      } elseif (chkacl ($this->acl, "gotoXVsync") == ""){
-        list($v1,$v2)= split ("-", $val);
-        if ($v2 != ""){
-          if ($v1 > $v2){
-            $message[]= _("Please specify a valid VSync range.");
+    if ($this->dn != "" && $this->cn != "default" && $this->cn != "default"){
+
+      /* But only if no auto sync is enabled... */
+      if (!$this->AutoSync){
+
+        /* Check vsync for correct usage */
+        $val= preg_replace ("/\s/", "", $this->gotoXVsync);
+        if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val) && $this->acl_is_writeable("gotoXVsync")){
+
+          $message[]= _("Please specify a valid VSync range.");
+        } elseif ($this->acl_is_writeable("gotoXVsync")){
+          list($v1,$v2)= preg_split ("/[-+]/", $val);
+          if ($v2 != ""){
+            if ($v1 > $v2){
+              $message[]= _("Please specify a valid VSync range.");
+            }
           }
         }
-      }
 
-      /* Check hsync for correct usage */
-      $val= preg_replace ("/\s/", "", $this->gotoXHsync);
-      if (!preg_match ("/^\d+(\.\d+)?(\-\d+(\.\d+)?)?$/", $val)
-          && chkacl ($this->acl, "gotoXHsync") == ""){
-
-        $message[]= _("Please specify a valid HSync range.");
-      } elseif (chkacl ($this->acl, "gotoXHsync") == ""){
-        list($v1,$v2)= split ("-", $val);
-        if ($v2 != ""){
-          if ($v1 > $v2){
-            $message[]= _("Please specify a valid HSync range.");
+        /* Check hsync for correct usage */
+        $val= preg_replace ("/\s/", "", $this->gotoXHsync);
+        if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val) && $this->acl_is_writeable("gotoXHsync")){
+
+          $message[]= _("Please specify a valid HSync range.");
+        } elseif ($this->acl_is_writeable("gotoXHsync")){
+          list($v1,$v2)= preg_split ("/[-+]/", $val);
+          if ($v2 != ""){
+            if ($v1 > $v2){
+              $message[]= _("Please specify a valid HSync range.");
+            }
           }
         }
       }
     }
+  }
+
+
+  /* Check supplied data */
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
     return ($message);
   }
 
@@ -394,6 +432,9 @@ class termservice extends plugin
   /* Save to LDAP */
   function save()
   {
+    /* Convert to string */
+    $this->gotoLpdEnable= $this->gotoLpdEnable?"Yes":"No";
+
     plugin::save();
 
     /* Strip out 'default' values */
@@ -407,11 +448,17 @@ class termservice extends plugin
       }
     }
 
+    if($this->AutoSync){
+      $this->attrs['gotoXHsync'] = "30+55";
+      $this->attrs['gotoXVsync'] = "50+70";
+    }
+
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $this->cleanup();
     $ldap->modify ($this->attrs); 
+    @log::log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
 
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/service with dn '%s' failed."),$this->dn));
     $this->handle_post_events("modify");
@@ -426,7 +473,7 @@ class termservice extends plugin
           "plDescription" => _("Terminal service"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 3,
           "plSection"     => array("administration"),
           "plCategory"    => array("terminal"),
 
@@ -440,15 +487,16 @@ class termservice extends plugin
             "gotoXColordepth"         => _("Gfx color depth"),
             "gotoXHsync"              => _("Hsync"),
             "gotoXVsync"              => _("Vsync"),
+            "AutoSync"                => _("Auto-Sync"),
             "gotoLpdEnable"           => _("Printer service enabled"),
             "gotoLpdServer"           => _("Spool server"),
             "gotoScannerEnable"       => _("Scanner enabled"),
-            "gotoScannerModel"        => _("Scanner modell"),
-            "gotoScannerClients"      => _(""),
-            "gotoScannerBackend"      => _(""),
-            "gotoXKbModel"            => _("Keyboard modell"),
+            "gotoScannerModel"        => _("Scanner model"),
+            "gotoScannerClients"      => _("Haeh ? "),
+            "gotoScannerBackend"      => _("..."),
+            "gotoXKbModel"            => _("Keyboard model"),
             "gotoXKbLayout"           => _("Keyboard layout"),
-            "gotoXKbVariant"          => _("Keyborad variant"),
+            "gotoXKbVariant"          => _("Keyboard variant"),
             "gotoXMouseType"          => _("Mouse type"),
             "gotoXMouseport"          => _("Mouse port"),
             "goFonHardware"           => _("Telephone hardware"))