Code

Added tooltip
[gosa.git] / plugins / personal / connectivity / class_proxyAccount.inc
index 06a6c0090a83161dbd24d9795ad46492399c0a4f..1c2596582ec66e285f201a3e98140bc11d387de0 100644 (file)
@@ -30,32 +30,36 @@ class proxyAccount extends plugin
 
   function execute()
   {
+       /* Call parent execute */
+//     plugin::execute();
+
     $display= "";
 
     /* Prepare templating */
     $smarty= get_smarty();
-    $smarty->assign("gosaProxyAcctFlagsACL", chkacl($this->acl, "gosaProxyAcctFlags"));
+    $smarty->assign("proxyAccountACL",          chkacl($this->acl, "proxyAccount"));
+    $smarty->assign("gosaProxyAcctFlagsACL",    chkacl($this->acl, "gosaProxyAcctFlags"));
     $smarty->assign("gosaProxyWorkingStartACL", chkacl($this->acl, "gosaProxyWorkingStart"));
-    $smarty->assign("gosaProxyWorkingStopACL", chkacl($this->acl, "gosaProxyWorkingStop"));
-    $smarty->assign("gosaProxyQuotaACL", chkacl($this->acl, "gosaProxyQuota"));
-
-    /* Show checkbox? */
-    if ($this->parent != NULL){
-      $smarty->assign("tabbed", "1");
-    }
+    $smarty->assign("gosaProxyWorkingStopACL",  chkacl($this->acl, "gosaProxyWorkingStop"));
+    $smarty->assign("gosaProxyQuotaACL",        chkacl($this->acl, "gosaProxyQuota"));
 
     /* Assign radio boxes */
     foreach (array("F", "T", "B", "N") as $val){
       if (is_integer(strpos($this->gosaProxyAcctFlags, "$val"))) {
         $smarty->assign("filter$val", "checked");
 
-        // Create state variable for checkbox (Used in proxy.tpl)
+        /* Add state variables for on-the-fly state-changing of checkboxes */
         $smarty->assign($val."state", "");
+        
       } else {
         $smarty->assign("filter$val", "");
-        
-        // Create state variable for checkbox (Used in proxy.tpl)
-        $smarty->assign($val."state", "disabled");
+
+        /* Same as above */
+        if($_SESSION['js']==1){
+          $smarty->assign($val."state", "disabled");
+        }else{
+          $smarty->assign($val."state", "");
+        }
       }
     }
 
@@ -90,6 +94,44 @@ class proxyAccount extends plugin
       $smarty->assign("pstate", "");
     }
 
+    $changeA = "";
+  
+    if(chkacl($this->acl,"gosaProxyAcctFlags")==""){
+      $changeA .="changeState('filterF');\n";
+    }
+    $smarty->assign("Working_allowedACL","disabled");
+    if((chkacl($this->acl,"gosaProxyWorkingStart")=="")||(chkacl($this->acl,"gosaProxyWorkingStop")=="")){
+      $smarty->assign("Working_allowedACL","");
+      $changeA .= "changeState('filterT');\n";
+    }
+
+    $ProxyWorkingStateChange ="";
+    if(chkacl($this->acl,"gosaProxyWorkingStart")==""){
+      $ProxyWorkingStateChange.=  "changeState('startHour');\n";
+      $ProxyWorkingStateChange.=  "changeState('startMinute');\n";
+    }
+
+    if(chkacl($this->acl,"gosaProxyWorkingStop")=="")  {
+      $ProxyWorkingStateChange.=  "changeState('stopHour');\n";
+      $ProxyWorkingStateChange.=  "changeState('stopMinute');\n";
+    }
+    
+    $changeA .= $ProxyWorkingStateChange;
+  
+    $smarty->assign("ProxyWorkingStateChange",$ProxyWorkingStateChange);
+
+    $changeB = "";
+    if(chkacl($this->acl,"gosaProxyQuota")==""){
+      $changeA .= "changeState('filterB');";
+      $changeB = 
+        "changeSubselectState('filterB', 'quota_size');
+         changeSubselectState('filterB', 'quota_unit');
+         changeSubselectState('filterB', 'gosaProxyQuotaPeriod');";
+    }
+
+    $smarty->assign("changeB",$changeB);
+    $smarty->assign("changeA",$changeA);
+
     /* Show main page */
     $display.= $smarty->fetch(get_template_path('proxy.tpl', TRUE, dirname(__FILE__)));
     return($display);
@@ -108,13 +150,34 @@ class proxyAccount extends plugin
     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
         $this->attributes, "Save");
     $ldap->cd($this->dn);
-    $ldap->modify($this->attrs);
+    $this->cleanup();
+$ldap->modify ($this->attrs); 
+
     show_ldap_error($ldap->get_error());
 
     /* Optionally execute a command after we're done */
     $this->handle_post_events("remove");
   }
 
+  /* Check values */
+  function check()
+  {
+    $message= array();
+    
+    /* We've got only one value to check for positive integer or emtpy field */
+    if ($this->is_account){
+      if (isset($_POST["quota_size"])){
+        if ($_POST["quota_size"] == ""){
+          $message[]= _("Numerical value for Quota Setting is empty.");
+        }
+        else if ($_POST["quota_size"] <= 0){
+          $message[]= _("Numerical value for Quota Setting is not valid.");
+        }
+      }
+    }
+
+    return $message;
+  }
 
   /* Save data to object */
   function save_object()
@@ -132,6 +195,12 @@ class proxyAccount extends plugin
       }
     }
 
+    if(isset($_POST['proxy'])){
+      $this->is_account = TRUE; 
+    }else{
+      $this->is_account = FALSE;
+    }
+
     /* Save flag value */
     if ($this->is_account){
       if (chkacl ($this->acl, "gosaProxyAcctFlags") == ""){
@@ -148,10 +217,13 @@ class proxyAccount extends plugin
       }
 
       /* Save time values */
-      if (chkacl ($this->acl, "gosaProxyWorkingTime") == "" && isset($_POST['startMinute'])){
+      if ((chkacl ($this->acl, "gosaProxyWorkingStart") == "")&&(isset($_POST['startMinute']))){
         $old= $this->gosaProxyWorkingStart;
         $this->gosaProxyWorkingStart= $_POST["startHour"] * 60 + $_POST["startMinute"];
         $this->is_modified= ($old != $this->gosaProxyWorkingStart)?TRUE:$this->is_modified;
+      }
+      
+      if ((chkacl ($this->acl, "gosaProxyWorkingStop") == "")&&(isset($_POST['stopMinute']))){
         $old= $this->gosaProxyWorkingStop;
         $this->gosaProxyWorkingStop = $_POST["stopHour"]  * 60 + $_POST["stopMinute"];
         $this->is_modified= ($old != $this->gosaProxyWorkingStop)?TRUE:$this->is_modified;
@@ -183,7 +255,9 @@ class proxyAccount extends plugin
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->modify($this->attrs);
+    $this->cleanup();
+$ldap->modify ($this->attrs); 
+
 
     show_ldap_error($ldap->get_error());