Code

Added auto field for H-v sync
[gosa.git] / plugins / admin / systems / class_workstationService.inc
index b4d1f3b0a8b67486b20529643fd5a4391a9299de..c80b799fba8e8fe22e1027895e2573d1265df4e1 100644 (file)
@@ -15,6 +15,7 @@ class workservice extends plugin
   var $gotoXColordepth= "";
   var $gotoXHsync= "";
   var $gotoXVsync= "";
+  var $AutoSync = false;
   var $gotoXKbModel= "";
   var $gotoXKbLayout= "";
   var $gotoXKbVariant= "";
@@ -51,7 +52,7 @@ class workservice extends plugin
 
 
   /* attribute list for save action */
-  var $attributes= array("cn","gotoXMonitor",
+  var $attributes= array("gotoXMonitor",
       "gotoXDriver", "gotoXResolution", "gotoXColordepth",
       "gotoXHsync", "gotoXVsync",
       "gotoScannerEnable", "gotoScannerClients",
@@ -104,12 +105,21 @@ class workservice extends plugin
       }
     }
 
+    if(preg_match("/\+/",$this->gotoXHsync)){
+      $this->AutoSync = true;
+      $this->gotoXHsync = preg_replace("/\+/","-",$this->gotoXHsync);
+      $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync);
+    }
+
     $this->hardware_list["automatic"]= _("automatic");
     ksort($this->hardware_list);
   }
 
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Do we need to flip is_account state? */
     if (isset($_POST['modify_state'])){
       $this->is_account= !$this->is_account;
@@ -183,6 +193,13 @@ class workservice extends plugin
     $hl.= "</select>\n";
     $smarty->assign ("hardware_list", $hl);
     $smarty->assign ("gotoXMonitor", $this->gotoXMonitor);
+    $smarty->assign("AutoSyncACL",chkacl($this->acl,"AutoSync"));
+
+    if($this->AutoSync){
+      $smarty->assign("AutoSyncCHK"," checked ");
+    }else{
+      $smarty->assign("AutoSyncCHK"," ");
+    }
 
     /* Show main page */
     return($smarty->fetch (get_template_path('workstationService.tpl',TRUE,dirname(__FILE__))));
@@ -190,21 +207,23 @@ class workservice extends plugin
 
   function remove_from_parent()
   {
-    $ldap= $this->config->get_ldap_link();
-    $ldap->rmdir($this->dn);
-    show_ldap_error($ldap->get_error());
-    $this->handle_post_events("remove");
+      $this->handle_post_events("remove");
   }
 
-
   /* Save data to object */
   function save_object()
   {
     plugin::save_object();
 
+    if(isset($_POST['gotoXHsync'])){
+      if(isset($_POST['AutoSync'])){
+        $this->AutoSync = true;
+      }else{
+        $this->AutoSync = false;
+      }
+    }
   }
 
-
   /* Check supplied data */
   function check()
   {
@@ -215,12 +234,12 @@ class workservice extends plugin
 
       /* Check vsync for correct usage */
       $val= preg_replace ("/\s/", "", $this->gotoXVsync);
-      if (!preg_match ("/^\d+(\.\d+)?(\-\d+(\.\d+)?)?$/", $val)
+      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);
+        list($v1,$v2)= preg_split ("/[-+]/", $val);
         if ($v2 != ""){
           if ($v1 > $v2){
             $message[]= _("Please specify a valid VSync range.");
@@ -230,12 +249,12 @@ class workservice extends plugin
 
       /* Check hsync for correct usage */
       $val= preg_replace ("/\s/", "", $this->gotoXHsync);
-      if (!preg_match ("/^\d+(\.\d+)?(\-\d+(\.\d+)?)?$/", $val)
+      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);
+        list($v1,$v2)= preg_split ("/[-+]/", $val);
         if ($v2 != ""){
           if ($v1 > $v2){
             $message[]= _("Please specify a valid HSync range.");
@@ -263,6 +282,11 @@ class workservice extends plugin
       }
     }
 
+    if($this->AutoSync){
+      $this->attrs['gotoXHsync'] = preg_replace("/-/","+",$this->attrs['gotoXHsync']) ;
+      $this->attrs['gotoXVsync'] = preg_replace("/-/","+",$this->attrs['gotoXVsync']) ;
+    }
+
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);