Code

Fixed grey out for proxy setting, when in multiple edit
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Dec 2007 14:49:53 +0000 (14:49 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Dec 2007 14:49:53 +0000 (14:49 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8161 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/personal/connectivity/class_proxyAccount.inc
gosa-core/plugins/personal/connectivity/proxy.tpl

index 455bb53e58bed88edf4bf85a170981a7c460ca52..6e0ccf9a86da1cc4ec655c6e92da84477aee00a2 100644 (file)
@@ -23,6 +23,8 @@ class proxyAccount extends plugin
   var $uid = "";
   var $view_logged = FALSE;
 
+  var $multiple_support = TRUE;
+
   function proxyAccount (&$config, $dn= NULL)
   {
     plugin::plugin ($config, $dn);
@@ -106,44 +108,63 @@ class proxyAccount extends plugin
       $smarty->assign("proxyState", "");
     }
 
-    /* Prepare correct state */
-    if (!$this->is_account){
-      $smarty->assign("pstate", "disabled");
-    } else {
-      $smarty->assign("pstate", "");
-    }
 
-    $changeA = "";
-  
-    $ProxyWorkingStateChange ="\n";
-    if($this->acl_is_writeable("gosaProxyFlagT")){
-      $changeA .= "changeState('filterT');\n";
-
-      $ProxyWorkingStateChange.=  "changeState('startHour'); \n";
-      $ProxyWorkingStateChange.=  "changeState('startMinute'); \n";
-      $ProxyWorkingStateChange.=  "changeState('stopHour'); \n";
-      $ProxyWorkingStateChange.=  "changeState('stopMinute'); \n";
-    }
+    if($this->multiple_support_active){
 
-    if(preg_match("/F/",$this->gosaProxyAcctFlags)){
-      $changeA .= $ProxyWorkingStateChange;
-    }
+      $changeA = $changeB = "";
+      $smarty->assign("pstate", "");
+      $smarty->assign("ProxyWorkingStateChange","");
   
-    $smarty->assign("ProxyWorkingStateChange",$ProxyWorkingStateChange);
-
-    $changeB = "";
-    if($this->acl_is_writeable("gosaProxyFlagB")){
-      $changeA .= "changeState('filterB');";
-      $changeB = 
-        "changeSubselectState('filterB', 'quota_size');
-         changeSubselectState('filterB', 'quota_unit');
-         changeSubselectState('filterB', 'gosaProxyQuotaPeriod');";
+    }else{
+
+      /* Prepare correct state */
+      if (!$this->is_account){
+        $smarty->assign("pstate", "disabled");
+      } else {
+        $smarty->assign("pstate", "");
+      }
+
+      $changeA = "";
+
+      $ProxyWorkingStateChange ="\n";
+      if($this->acl_is_writeable("gosaProxyFlagT")){
+        $changeA .= "changeState('filterT');\n";
+
+        $ProxyWorkingStateChange.=  "changeState('startHour'); \n";
+        $ProxyWorkingStateChange.=  "changeState('startMinute'); \n";
+        $ProxyWorkingStateChange.=  "changeState('stopHour'); \n";
+        $ProxyWorkingStateChange.=  "changeState('stopMinute'); \n";
+      }
+
+      if(preg_match("/F/",$this->gosaProxyAcctFlags)){
+        $changeA .= $ProxyWorkingStateChange;
+      }
+
+      $smarty->assign("ProxyWorkingStateChange",$ProxyWorkingStateChange);
+
+      $changeB = "";
+      if($this->acl_is_writeable("gosaProxyFlagB")){
+        $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 */
+    foreach(array("T","B","F") as $attr){
+      if(in_array("filter".$attr,$this->multi_boxes)){
+        $smarty->assign("use_filter".$attr,TRUE);
+      }else{
+        $smarty->assign("use_filter".$attr,FALSE);
+      }
+    }
+    $smarty->assign("use_proxy",in_array("proxy",$this->multi_boxes));
+    $smarty->assign("multiple_support",$this->multiple_support_active);
     $display.= $smarty->fetch(get_template_path('proxy.tpl', TRUE, dirname(__FILE__)));
     return($display);
   }
@@ -212,7 +233,7 @@ class proxyAccount extends plugin
     }
 
     /* Save flag value */
-    if ($this->is_account){
+    if ($this->is_account || $this->multiple_support_active){
 
       $flags= "";
       $acl= "";
@@ -319,6 +340,74 @@ class proxyAccount extends plugin
             "gosaProxyFlagB"       => _("Restrict proxy usage by quota"))
           ));
   }
+
+  function multiple_save_object()
+  {
+    if (isset($_POST['connectivityTab'])){
+      plugin::multiple_save_object();
+      if(isset($_POST['use_proxy'])){
+        $this->multi_boxes[] = "proxy";
+      }
+      foreach(array("T","B","F") as $attr){
+        if(isset($_POST["use_filter".$attr])){
+          $this->multi_boxes[] = "filter".$attr;
+        }
+      }
+      $this->save_object();
+    }
+  }
+
+  function get_multi_edit_values()
+  {
+    $ret = plugin::get_multi_edit_values();
+    if(in_array("proxy",$this->multi_boxes)){
+      $ret['is_account'] = $this->is_account;
+    }
+
+    if(in_array("filterT",$this->multi_boxes)){
+      $ret['gosaProxyWorkingStart']  = $this->gosaProxyWorkingStart;
+      $ret['gosaProxyWorkingStop']   = $this->gosaProxyWorkingStop;
+    }
+    if(in_array("filterB",$this->multi_boxes)){
+      $ret['gosaProxyQuota']        = $this->gosaProxyQuota;
+      $ret['gosaProxyQuotaPeriod']  = $this->gosaProxyQuotaPeriod;
+    }
+
+    foreach(array("B","T","F") as $attr){
+      $name = "filter".$attr;
+      if(in_array($name,$this->multi_boxes)){
+        $ret[$name] = preg_match("/".$attr."/",$this->gosaProxyAcctFlags);
+      }
+    }
+
+    return($ret);
+  }
+
+  function set_multi_edit_values($values)
+  {
+    plugin::set_multi_edit_values($values);
+    if(isset($values['is_account'])){
+      $this->is_account = $values['is_account'];
+    }
+    foreach(array("B","T","F") as $attr){
+      $name = "filter".$attr;
+      if(isset($values[$name])){
+        if($values[$name] && !preg_match("/".$attr."/",$this->gosaProxyAcctFlags)){
+          $this->gosaProxyAcctFlags = preg_replace("/\]/",$attr."]",$this->gosaProxyAcctFlags);
+        }elseif(!$values[$name] && preg_match("/".$attr."/",$this->gosaProxyAcctFlags)){
+          $this->gosaProxyAcctFlags = preg_replace("/".$attr."/","",$this->gosaProxyAcctFlags);
+        }
+      }
+    }
+  }
+
+  function init_multiple_support($attrs,$all)
+  {
+    plugin::init_multiple_support($attrs,$all);
+    if(isset($attrs['objectClass']) && in_array("gosaProxyAccount",$attrs['objectClass'])){
+      $this->is_account = TRUE;
+    }
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 517823706372f584ced03d84bd8df2eb0cb60c96..f0c0ea00e4e7b0de90653a4a55db619125fb3de6 100644 (file)
@@ -1,25 +1,37 @@
 <h2>
- <input type="checkbox" id="proxy" name="proxy" value="B" {$proxyState} {$proxyAccountACL} 
-   onClick="
 
-{if $gosaProxyFlagF_W}
-    changeState('filterF');
-{/if}
+{if $multiple_support}
+       
+ <input type="checkbox" name="use_proxy" value="1" onClick="changeState('proxy')" 
+       {if $use_proxy} checked {/if}>  
+ <input type="checkbox" id="proxy" name="proxy" value="B" {$proxyState}
+       {if !$use_proxy} disabled {/if}>
+
+{else}
+
+       <input type="checkbox" id="proxy" name="proxy" value="B" {$proxyState} {$proxyAccountACL} 
+       onClick="
+
+       {if $gosaProxyFlagF_W}
+       changeState('filterF');
+       {/if}
 
-{if $gosaProxyFlagT_W}
+       {if $gosaProxyFlagT_W}
        changeState('filterT'); 
        changeTripleSelectState('proxy', 'filterT', 'startHour'); 
        changeTripleSelectState('proxy', 'filterT', 'startMinute'); 
        changeTripleSelectState('proxy', 'filterT', 'stopMinute'); 
        changeTripleSelectState('proxy', 'filterT', 'stopHour'); 
-{/if}
-{if $gosaProxyFlagB_W}
+       {/if}
+       {if $gosaProxyFlagB_W}
        changeState('filterB'); 
        changeTripleSelectState('proxy', 'filterB', 'quota_unit'); 
        changeTripleSelectState('proxy', 'filterB', 'quota_size');
        changeTripleSelectState('proxy', 'filterB', 'gosaProxyQuotaPeriod');
+       {/if}
+       ">
+
 {/if}
-   ">
  {t}Proxy account{/t}</h2>
 
 <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=0 border=0>
@@ -28,7 +40,7 @@
     <table summary="" border=0 width="100%" cellpadding=0>
     <tr><td colspan=2>
 
-{render acl=$gosaProxyFlagFACL}
+{render acl=$gosaProxyFlagFACL checkbox=$multiple_support checked=$use_filterF}
     <input type="checkbox" name="filterF" id="filterF" value="F" {$filterF} {$pstate} >
 {/render}
     {t}Filter unwanted content (i.e. pornographic or violence related){/t}
@@ -36,7 +48,7 @@
      <tr>
       <td width="50%">
 
-{render acl=$gosaProxyFlagTACL}
+{render acl=$gosaProxyFlagTACL checkbox=$multiple_support checked=$use_filterT}
     <input type="checkbox" name="filterT" id="filterT" value="T" {$filterT} {$pstate}  onClick="javascript:
  {$ProxyWorkingStateChange}">
 {/render}
       <td>
 
 {render acl=$gosaProxyFlagTACL}
-        <select size="1" id="startHour" name="startHour" {if $Tstate!="" || $pstate!=""} disabled {/if}  >
+        <select size="1" id="startHour" name="startHour" {if $Tstate!=""} disabled {/if}  >
          {html_options values=$hours output=$hours selected=$starthour}
         </select>
 {/render}
         &nbsp;:&nbsp;
 {render acl=$gosaProxyFlagTACL}
-        <select size="1" id="startMinute" name="startMinute" {if $Tstate!="" || $pstate!=""} disabled {/if}  >
+        <select size="1" id="startMinute" name="startMinute" {if $Tstate!=""} disabled {/if}  >
          {html_options values=$minutes output=$minutes selected=$startminute}
         </select>
 {/render}
         &nbsp;-&nbsp;
 {render acl=$gosaProxyFlagTACL}
-        <select size="1" id="stopHour" name="stopHour" {if $Tstate!="" || $pstate!=""} disabled {/if} >
+        <select size="1" id="stopHour" name="stopHour" {if $Tstate!=""} disabled {/if} >
    {html_options values=$hours output=$hours selected=$stophour}
         </select>
 {/render}
         &nbsp;:&nbsp;
 {render acl=$gosaProxyFlagTACL}
-        <select size="1" id="stopMinute" name="stopMinute" {if $Tstate!="" || $pstate!=""} disabled {/if}>
+        <select size="1" id="stopMinute" name="stopMinute" {if $Tstate!=""} disabled {/if}>
          {html_options values=$minutes output=$minutes selected=$stopminute}
         </select>
 {/render}
@@ -78,7 +90,7 @@
      &nbsp;
    </td>
       <td>
-{render acl=$gosaProxyFlagBACL}
+{render acl=$gosaProxyFlagBACL checkbox=$multiple_support checked=$use_filterB}
     <input type="checkbox" id="filterB" name="filterB" value="B" {$filterB} {if $pstate=="disabled"} disabled {/if} onClick="{$changeB}">
 {/render}
     <LABEL for="quota_size">{t}Restrict proxy usage by quota{/t}</LABEL>
      <tr>
       <td>
 {render acl=$gosaProxyFlagBACL}
-       <input name="quota_size" id="quota_size" size=7 maxlength=10 value="{$quota_size}" {if $Tstate!="" || $pstate!=""} disabled {/if} >
+       <input name="quota_size" id="quota_size" size=7 maxlength=10 value="{$quota_size}" {if $Bstate!=""} disabled {/if} >
 {/render}
        &nbsp;
 {render acl=$gosaProxyFlagBACL}
-       <select size="1" name="quota_unit" id="quota_unit" {if $Tstate!="" || $pstate!=""} disabled {/if} >
+       <select size="1" name="quota_unit" id="quota_unit" {if $Bstate!=""} disabled {/if} >
        {html_options options=$quota_unit selected=$quota_u}
        </select>
 {/render}
     
        <LABEL for="gosaProxyQuotaPeriod">{t}per{/t}</LABEL>
 {render acl=$gosaProxyFlagBACL}
-       <select size="1" name="gosaProxyQuotaPeriod" id="gosaProxyQuotaPeriod" {if $Tstate!="" || $pstate!=""} disabled {/if} >
+       <select size="1" name="gosaProxyQuotaPeriod" id="gosaProxyQuotaPeriod" {if $Bstate!=""} disabled {/if} >
         {html_options options=$quota_time selected=$gosaProxyQuotaPeriod}
        </select>
 {/render}