From bc49423283b6b687e76ddb00e049b8adeeb5cb64 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 11 Oct 2010 15:52:51 +0000 Subject: [PATCH] Added feature checking to distribution list git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19984 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../class_DistributionList.inc | 89 +++++++++++-------- .../ogroups/DistributionList/generic.tpl | 68 +++++++------- 2 files changed, 90 insertions(+), 67 deletions(-) diff --git a/gosa-plugins/groupware/admin/ogroups/DistributionList/class_DistributionList.inc b/gosa-plugins/groupware/admin/ogroups/DistributionList/class_DistributionList.inc index 0d08fa500..d8a0997bc 100644 --- a/gosa-plugins/groupware/admin/ogroups/DistributionList/class_DistributionList.inc +++ b/gosa-plugins/groupware/admin/ogroups/DistributionList/class_DistributionList.inc @@ -43,6 +43,16 @@ class DistributionList extends plugin } + /*! \brief Check whether a feature is enabled or not. + * @param The feature name to check for + * @return TRUE on success else FALSE + */ + function featureEnabled($name) + { + return(isset($this->featuresEnabled[$name]) && $this->featuresEnabled[$name]); + } + + /*! \brief Try to initialize the plugin using a json-rpc connection * to the gosa-ng server. */ @@ -117,27 +127,31 @@ class DistributionList extends plugin } // Load alternate mail address - $alternateAddresses = $rpc->gwDistGetAlternateMailAddresses($this->orig_cn); - if(!$rpc->success()){ - $this->rpcError = TRUE; - $this->rpcErrorMessage = $rpc->get_error(); - $message = sprintf(_("Failed to load alternate mail addresses for distribution list '%s'! Error was: '%s'."), - $this->orig_cn, $rpc->get_error()); - msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); - return; + if($this->featureEnabled('alternateAddresses')){ + $alternateAddresses = $rpc->gwDistGetAlternateMailAddresses($this->orig_cn); + if(!$rpc->success()){ + $this->rpcError = TRUE; + $this->rpcErrorMessage = $rpc->get_error(); + $message = sprintf(_("Failed to load alternate mail addresses for distribution list '%s'! Error was: '%s'."), + $this->orig_cn, $rpc->get_error()); + msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); + return; + } } // Load mail size limitation settings - $mailSizeLimit = $rpc->gwDistGetMailLimit($this->orig_cn); - if(!$rpc->success()){ - $this->rpcError = TRUE; - $this->rpcErrorMessage = $rpc->get_error(); - $message = sprintf(_("Failed to load mail size limit for distribution list '%s'! Error was: '%s'."), - $this->orig_cn, $rpc->get_error()); - msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); - return; + if($this->featureEnabled('mailSizeLimit')){ + $mailSizeLimit = $rpc->gwDistGetMailLimit($this->orig_cn); + if(!$rpc->success()){ + $this->rpcError = TRUE; + $this->rpcErrorMessage = $rpc->get_error(); + $message = sprintf(_("Failed to load mail size limit for distribution list '%s'! Error was: '%s'."), + $this->orig_cn, $rpc->get_error()); + msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); + return; + } + $mailSizeLimit = $mailSizeLimit['receive']; } - $mailSizeLimit = $mailSizeLimit['receive']; } // Store values as current and initial values (saved_attributes) @@ -256,6 +270,10 @@ class DistributionList extends plugin $smarty->assign("{$attr}ACL", $this->getacl($attr)); $smarty->assign($attr, set_post($this->$attr)); } + foreach(array('mailSizeLimit','alternateAddresses') as $feature){ + $smarty->assign("{$feature}_isActive", $this->featureEnabled($feature)); + } + $smarty->assign("useMailSizeLimit", ($this->mailSizeLimit != NULL)); $smarty->assign("memberList", set_post($this->memberList)); @@ -399,33 +417,34 @@ class DistributionList extends plugin // Updated mail size limitations, if needed: // -> is a new distribution list or // -> the value for 'mailSizeLimit' has changed. - if(!$this->initially_was_account || $this->mailSizeLimit != $this->saved_attributes['mailSizeLimit']){ - $rpc->gwDistSetMailLimit($this->cn, $this->mailSizeLimit); - if(!$rpc->success()){ - $message = sprintf(_("Failed to update mail size limitations for distribution list '%s'! Error was: '%s'."), - $this->cn, $rpc->get_error()); - msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); + if($this->featureEnabled('mailSizeLimit')){ + if(!$this->initially_was_account || $this->mailSizeLimit != $this->saved_attributes['mailSizeLimit']){ + $rpc->gwDistSetMailLimit($this->cn, $this->mailSizeLimit); + if(!$rpc->success()){ + $message = sprintf(_("Failed to update mail size limitations for distribution list '%s'! Error was: '%s'."), + $this->cn, $rpc->get_error()); + msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); + } } } // Updated alternate mail addresses, if needed: // -> is a new distribution list or // -> the value for 'alternateAddresses' has changed. - sort($this->alternateAddresses); - sort($this->saved_attributes['alternateAddresses']); - $changed = array_differs($this->alternateAddresses,$this->saved_attributes['alternateAddresses']); - if(!$this->initially_was_account || $changed){ - $rpc->gwDistSetAlternateMailAddresses($this->cn, $this->alternateAddresses); - if(!$rpc->success()){ - $message = sprintf(_("Failed to update alternate addresses for distribution list '%s'! Error was: '%s'."), - $this->cn, $rpc->get_error()); - msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); + if($this->featureEnabled('alternateAddresses')){ + sort($this->alternateAddresses); + sort($this->saved_attributes['alternateAddresses']); + $changed = array_differs($this->alternateAddresses,$this->saved_attributes['alternateAddresses']); + if(!$this->initially_was_account || $changed){ + $rpc->gwDistSetAlternateMailAddresses($this->cn, $this->alternateAddresses); + if(!$rpc->success()){ + $message = sprintf(_("Failed to update alternate addresses for distribution list '%s'! Error was: '%s'."), + $this->cn, $rpc->get_error()); + msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); + } } } - // Update member list - $this->memberList = $this->getOgroupMemberList(); - // Check which accounts have valid groupware mail addresses. $uids = $this->getOgroupMemberList(); $rpc = $this->config->getRpcHandle(); diff --git a/gosa-plugins/groupware/admin/ogroups/DistributionList/generic.tpl b/gosa-plugins/groupware/admin/ogroups/DistributionList/generic.tpl index 1f4876835..085ed73c1 100644 --- a/gosa-plugins/groupware/admin/ogroups/DistributionList/generic.tpl +++ b/gosa-plugins/groupware/admin/ogroups/DistributionList/generic.tpl @@ -1,46 +1,50 @@ - - + {if $alternateAddresses_isActive} + + {/if}
+

{t}Groupware{/t}

{t}Mail address{/t}: {render acl=$primaryMailAddressACL} {/render} -
- {render acl=$mailSizeLimitACL} - - {/render} - {t}Use incoming mail size limitation{/t} - {render acl=$mailSizeLimitACL} - - {/render} -
-

- {render acl=$alternateAddressesACL} - -
- {/render} - {render acl=$alternateAddressesACL} - - {/render} - {render acl=$alternateAddressesACL} - - {/render} - {render acl=$alternateAddressesACL} - - {/render} + {if $mailSizeLimit_isActive} +
+ {render acl=$mailSizeLimitACL} + + {/render} + {t}Use incoming mail size limitation{/t} + {render acl=$mailSizeLimitACL} + + {/render} + {/if}
+

+ {render acl=$alternateAddressesACL} + +
+ {/render} + {render acl=$alternateAddressesACL} + + {/render} + {render acl=$alternateAddressesACL} + + {/render} + {render acl=$alternateAddressesACL} + + {/render} +
-- 2.30.2