From 86c341612631bab88257d471f43ec05c4728367d Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 20 Dec 2007 14:49:53 +0000 Subject: [PATCH] Fixed grey out for proxy setting, when in multiple edit git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8161 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../connectivity/class_proxyAccount.inc | 149 ++++++++++++++---- .../plugins/personal/connectivity/proxy.tpl | 50 +++--- 2 files changed, 150 insertions(+), 49 deletions(-) diff --git a/gosa-core/plugins/personal/connectivity/class_proxyAccount.inc b/gosa-core/plugins/personal/connectivity/class_proxyAccount.inc index 455bb53e5..6e0ccf9a8 100644 --- a/gosa-core/plugins/personal/connectivity/class_proxyAccount.inc +++ b/gosa-core/plugins/personal/connectivity/class_proxyAccount.inc @@ -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: diff --git a/gosa-core/plugins/personal/connectivity/proxy.tpl b/gosa-core/plugins/personal/connectivity/proxy.tpl index 517823706..f0c0ea00e 100644 --- a/gosa-core/plugins/personal/connectivity/proxy.tpl +++ b/gosa-core/plugins/personal/connectivity/proxy.tpl @@ -1,25 +1,37 @@

- + + +{else} + + + {/if} - "> {t}Proxy account{/t}

@@ -28,7 +40,7 @@
-{render acl=$gosaProxyFlagFACL} +{render acl=$gosaProxyFlagFACL checkbox=$multiple_support checked=$use_filterF} {/render} {t}Filter unwanted content (i.e. pornographic or violence related){/t} @@ -36,7 +48,7 @@
-{render acl=$gosaProxyFlagTACL} +{render acl=$gosaProxyFlagTACL checkbox=$multiple_support checked=$use_filterT} {/render} @@ -48,25 +60,25 @@ {render acl=$gosaProxyFlagTACL} - {html_options values=$hours output=$hours selected=$starthour} {/render}  :  {render acl=$gosaProxyFlagTACL} - {html_options values=$minutes output=$minutes selected=$startminute} {/render}  -  {render acl=$gosaProxyFlagTACL} - {html_options values=$hours output=$hours selected=$stophour} {/render}  :  {render acl=$gosaProxyFlagTACL} - {html_options values=$minutes output=$minutes selected=$stopminute} {/render} @@ -78,7 +90,7 @@   -{render acl=$gosaProxyFlagBACL} +{render acl=$gosaProxyFlagBACL checkbox=$multiple_support checked=$use_filterB} {/render} @@ -87,18 +99,18 @@
{render acl=$gosaProxyFlagBACL} - + {/render}   {render acl=$gosaProxyFlagBACL} - {html_options options=$quota_unit selected=$quota_u} {/render} {render acl=$gosaProxyFlagBACL} - {html_options options=$quota_time selected=$gosaProxyQuotaPeriod} {/render} -- 2.30.2