From: hzerres Date: Fri, 1 Oct 2010 13:58:50 +0000 (+0000) Subject: (groupware plugin) added mailFolder feature to Dao, smarty and feturelist of class. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a99ef8137148eb2efb55060ed7a3b1b650b03f8b;p=gosa.git (groupware plugin) added mailFolder feature to Dao, smarty and feturelist of class. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19886 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/groupware/personal/groupware/class_Groupware.inc b/gosa-plugins/groupware/personal/groupware/class_Groupware.inc index ec5973d7d..f60e1f43c 100644 --- a/gosa-plugins/groupware/personal/groupware/class_Groupware.inc +++ b/gosa-plugins/groupware/personal/groupware/class_Groupware.inc @@ -35,7 +35,7 @@ class Groupware extends plugin "vacationMessage", "mailBoxWarnLimitEnabled", "mailBoxWarnLimitValue", "mailBoxSendSizelimitEnabled", "mailBoxSendSizelimitValue", "mailBoxHardSizelimitEnabled", "mailBoxHardSizelimitValue", "mailBoxAutomaticRemovalEnabled", "mailBoxAutomaticRemovalValue", - "localDeliveryOnly", "dropOwnMails"); + "localDeliveryOnly", "dropOwnMails", "mailFolder"); var $enabledFeatures = array(); @@ -99,6 +99,7 @@ class Groupware extends plugin * @param Mixed args[0-n] The parameter to use. * @return Mixed The result of the function call on success else NULL. */ + function rpcExec($function) { $params = func_get_args(); @@ -116,7 +117,6 @@ class Groupware extends plugin return($res); } - /*! \brief TODO: comment */ public function isFeatureEnabled($featureName) @@ -127,7 +127,6 @@ class Groupware extends plugin return FALSE; } - /*! \brief Try initialize the groupware account. * This method fetches all required information to manage the * account using the GOsa gui. @@ -170,17 +169,26 @@ class Groupware extends plugin "localDeliveryOnly" => array( "_off", 'acctDelFilter','acctGetFilters','acctSetFilters','acctSetFilters'), "dropOwnMails" => array( "_off", - 'acctDelFilter','acctGetFilters','acctSetFilters','acctSetFilters')); - + 'acctDelFilter','acctGetFilters','acctSetFilters','acctSetFilters'), + "mailFolder" => array( + 'folderList','folderDel','folderAdd') + ); + + if($this->dn == "new"){ + // empty features if the user is brand new + $this->enabledFeatures = array(); + return; + } + // Check if all required methods cann be called! - foreach($featureReq as $name => $requires){ - $active = TRUE; - foreach($requires as $methodName){ - $active &= $this->groupwareDao->gwFeatureAvailable($methodName); - } - $this->enabledFeatures[$name] = $active; - } - + foreach($featureReq as $name => $requires){ + $active = TRUE; + foreach($requires as $methodName){ + $active &= $this->groupwareDao->gwFeatureAvailable($methodName); + } + $this->enabledFeatures[$name] = $active; + } + // Get rpc handle to fetch account info and feature availability. $status = $this->rpcExec('gwAcctExists', $this->uid); // mailboxlocations for the dropdownBox @@ -421,7 +429,6 @@ class Groupware extends plugin $smarty = get_smarty(); foreach($this->attributes as $attr){ - $smarty->assign($attr, $this->$attr); } @@ -429,7 +436,9 @@ class Groupware extends plugin foreach($plInfo['plProvidedAcls'] as $acl => $name){ $smarty->assign($acl."ACL", $this->getacl($acl)); } + foreach($this->enabledFeatures as $feature => $state){ + $smarty->assign($feature."_isActive", $state); } @@ -499,7 +508,6 @@ class Groupware extends plugin } } - /*! \brief Parse vacation templates and build up an array * containing 'filename' => 'description'. * Used to fill vacation dropdown box. @@ -716,9 +724,7 @@ class Groupware extends plugin $fw = array(); //only the first Address will be set as forward Address. $fw[$this->forwardingAddresses[0]] = true; - - $this->groupwareDao->save("forwardingAddresses", $this->uid, array($fw)); - + $this->groupwareDao->save("forwardingAddresses", $this->uid, array($fw)); } // Save the quota if(true){ @@ -740,11 +746,10 @@ class Groupware extends plugin */ function check() { - // TODO: Remove all echo Messages + //add some checks $messages = plugin::check(); //Check the dates - // TODO: check only if features are enabled. //required vacationEnabled @@ -762,14 +767,14 @@ class Groupware extends plugin } } if(!tests::is_email ($this->mailAddress)){ - $messages[] = msgPool::invalid(_("Mail address"),$this->mailAddress , "", "user@excom.intranet.gonicus.de"); + $messages[] = msgPool::invalid(_("Mail address"),$this->mailAddress , "", "user@exdom.intranet.gonicus.de knibbel"); } if(isset($this->forwardingAddresses) && is_array($this->forwardingAddresses)){ foreach($this->forwardingAddresses as $fAddress){ if(!tests::is_email ($fAddress)){ $messages[] = msgPool::invalid(_("Alternate address"),$fAddress, "", - "user@excom.intranet.gonicus.de"); + "user@exdom.intranet.gonicus.de"); } if($fAddress == $this->mailAddress){ $messages[] = _("The primary address cannot be used as alternative address!"); diff --git a/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc b/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc index 2d6eb0a42..2bc4c2cae 100644 --- a/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc +++ b/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc @@ -1,231 +1,234 @@ - array( "get"=>"gwAcctGetPrimaryMailAddress", - "save"=>"gwAcctSetPrimaryMailAddress"), - "mailLocations" => array("get"=>"gwGetMailboxLocations"), - "quotaSize" =>array( "get"=>"gwAcctGetQuota", - "save"=>"gwAcctSetQuota", - "delete"=>"gwAcctSetQuota"), - "mailFilter" =>array( "get"=>"gwAcctGetFilters", - "save"=>"gwAcctSetFilters", - "delete"=>"gwAcctDelFilter"), - "alternateAddresses" =>array( "get"=>"gwAcctGetAlternateMailAddresses", - "save"=>"gwAcctSetAlternateMailAddresses", - "delete"=>"gwAcctDelAlternateMailAddress"), - "forwardingAddresses" =>array( "get"=>"gwAcctGetMailForwardAddresses", - "save"=>"gwAcctSetMailForwardAddresses", - "delete"=>"gwAcctDelMailForwardAddress"), - "vacationMessage" =>array( "get"=>"gwAcctGetOutOfOfficeReply", - "save"=>"gwAcctSetOutOfOfficeReply", - "delete"=>"gwAcctDelOutOfOfficeReply"), - "mailBoxWarnLimit" =>array( "get"=>"", - "save"=>"", - "delete"=>""), - "mailBoxSendSizelimit" =>array( "get"=>"gwAcctGetQuota", - "save"=>"gwAcctSetQuota", - "delete"=>"gwAcctDelQuota"), - "mailBoxHardSizelimit" =>array( "get"=>"gwAcctGetMailLimit", - "save"=>"gwAcctSetMailLimit", - "delete"=>"gwAcctDelMailLimit"), - "mailBoxAutomaticRemoval" =>array( "get"=>"", - "save"=>"", - "delete"=>""), - "localDeliveryOnly" =>array( "get"=>"", - "save"=>"", - "delete"=>""), - "dropOwnMails" =>array( "get"=>"", - "save"=>"", - "delete"=>""), - "accountProperties" => array("get"=>"gwAcctGetProperties", - "save"=>"gwAcctSetProperties", - "delete"=>"gwAcctDelProperties") - - ); - - - /*! \brief Constructor sets the connection to the rpc service - * initializes the class - */ - function __construct(&$pluginRef) - { - $this->groupwarePluginRef = &$pluginRef; - - // TODO: Remove all echos - - $this->init(); - } - - - /*! \brief Gets the capabilities of the server - * builds an array with availbale features and knows how to call get, save, delete functions of - * groupware rpc. - */ - public function init() - { - $this->availableMethods = $this->groupwarePluginRef->rpcExec('gwGetCapabilities'); - //$this->availableProperties = $this->groupwarePluginRef->rpcExec('gwGetSupportedProperties'); - //$this->debug("availableProperties on init:", $this->availableProperties); - } - - - /*! \brief Generic saving method for all features defined in $gwFeatures - * which are the available features. - */ - public function save($feature, $uid, $valueArray) - { - $function = GroupwareDao::$gwFeatures[$feature]["save"]; - if(is_array($valueArray)){ - $valueArray = array_merge(array($function, $uid), $valueArray); - }else{ - $valueArray = array($function, $uid, $valueArray); - } - - $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray); - return $result; - } - - - /*! \brief generic get method for all features defined in $gwFeatures - * which are the available features. - */ - public function get($feature, $valueArray) - { - // TODO: Check if feture available ? get and return the result. - $function = GroupwareDao::$gwFeatures[$feature]["get"]; - if(is_array($valueArray)){ - $valueArray = array_merge(array($function), $valueArray); - }else{ - $valueArray = array($function, $valueArray); - } - - $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray); - return $result; - } - - - /*! \brief generic delete function for all features defined in $gwFeatures - * which are the available features. - * - * NOT YET IMPLEMENTED - */ - public function del($feature, $valueArray) - { - // TODO: check if feture available del and return the result. - - echo "deletion of values is not implemented yet"; - /* - $function = GroupwareDao::$gwFeatures[$feature]["delete"]; - $valueArray = array_merge(array($function), $valueArray); - $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray); - return $result; - */ - } - - - /*! \brief determine availability of features. - * - * @param methodName - * @return boolean - */ - public function gwFeatureAvailable($methodName) - { - return(isset($this->availableMethods[$methodName]) && ($this->availableMethods[$methodName])); - } - - - /*! \brief comprehensive user info will dessolve into one groupware call later - * right now it will get all data of the features that are available in the plugin. - * @param int $uid - * @return assoc array "feature" => "gwValue"; - */ - public function getComprehensiverUser( $uid) - { - //$hi = $this->groupwarePluginRef->rpcExec('gwGetCapabilities'); - $resultArr = array(); - - if($this->groupwarePluginRef->isFeatureEnabled("primaryMail")){ - $resultArr["primaryMail"] = $this->get("primaryMail", array($uid)); - } - - if($this->groupwarePluginRef->isFeatureEnabled("alternateAddresses")){ - $resultArr["alternateAddresses"] = $this->get("alternateAddresses", array($uid)); - } - - if($this->groupwarePluginRef->isFeatureEnabled("forwardingAddresses")){ - $resultArr["forwardingAddresses"] = $this->get("forwardingAddresses", array($uid)); - } - - - // Location dropdownlist - only readable - if($this->groupwarePluginRef->isFeatureEnabled("mailLocations")){ - $resultArr["mailLocations"] = $this->groupwarePluginRef->rpcExec('gwGetMailboxLocations'); - $resultArr["mailLocation"] = $this->groupwarePluginRef->rpcExec('gwAcctGetLocation',$uid); - } - - //TODO: getLocation muss ebenfalls geholt werden - // Quota quotaUsage, quotaSize - if($this->groupwarePluginRef->isFeatureEnabled("quotaSize") || - $this->groupwarePluginRef->isFeatureEnabled("quotaUsage") || - $this->groupwarePluginRef->isFeatureEnabled("mailBoxWarnLimit") || - $this->groupwarePluginRef->isFeatureEnabled("mailBoxSendSizelimit") || - $this->groupwarePluginRef->isFeatureEnabled("mailBoxHardSizelimit")){ - - // Usage is a Mapi function which is not yet - - // TODO: Remove the following dummy and enable the qota fetch from groupware - - echo "Quota function not yet implemented on server side!!"; - //$quota = $this->get("quotaSize", array($uid)); - $quota = array( "warn_limit" => 1008, - "send_limit" => 108, - "hard_limit" => 1108, - "hold" => 508, - "usage" => 1108); - $resultArr["quotaSize"] = $quota["usage"]; - $resultArr["quotaSize"] = $quota["hold"]; - if($quota["warn_limit"] > 0){ - $resultArr["mailBoxWarnLimitEnabled"] = true; - $resultArr["mailBoxWarnLimitValue"] = $quota["warn_limit"]; - }else{ - $resultArr["mailBoxWarnLimitEnabled"] = false; - $resultArr["mailBoxWarnLimitValue"] = 0; - } - if($quota["send_limit"] > 0){ - $resultArr["mailBoxSendSizelimitEnabled"] = True; - $resultArr["mailBoxSendSizelimitValue"] = $quota["send_limit"]; - }else{ - $resultArr["mailBoxSendSizelimitEnabled"] = FALSE; - $resultArr["mailBoxSendSizelimitValue"] = 0; - } - if($quota["hard_limit"] > 0){ - $resultArr["mailBoxHardSizelimitEnabled"] = True; - $resultArr["mailBoxHardSizelimitValue"] = $quota["hard_limit"]; - }else{ - $resultArr["mailBoxHardSizelimitEnabled"] = FALSE; - $resultArr["mailBoxHardSizelimitValue"] = 0; - } - } - - //this function seems to be broken on the server. - //addding dummy - - if($this->groupwarePluginRef->isFeatureEnabled("vacationMessage")){ - - $vacMessage = $this->get("vacationMessage", array($uid)); - //$resultArr["vacationMessage"] = "dummy Vacation message - (getOutOfOfficeReply currently throws errors )"; - } - return $resultArr; - } -} -?> \ No newline at end of file + array( "get"=>"gwAcctGetPrimaryMailAddress", + "save"=>"gwAcctSetPrimaryMailAddress"), + "mailLocations" => array("get"=>"gwGetMailboxLocations"), + "quotaSize" =>array( "get"=>"gwAcctGetQuota", + "save"=>"gwAcctSetQuota", + "delete"=>"gwAcctSetQuota"), + "mailFilter" =>array( "get"=>"gwAcctGetFilters", + "save"=>"gwAcctSetFilters", + "delete"=>"gwAcctDelFilter"), + "alternateAddresses" =>array( "get"=>"gwAcctGetAlternateMailAddresses", + "save"=>"gwAcctSetAlternateMailAddresses", + "delete"=>"gwAcctDelAlternateMailAddress"), + "forwardingAddresses" =>array( "get"=>"gwAcctGetMailForwardAddresses", + "save"=>"gwAcctSetMailForwardAddresses", + "delete"=>"gwAcctDelMailForwardAddress"), + "vacationMessage" =>array( "get"=>"gwAcctGetOutOfOfficeReply", + "save"=>"gwAcctSetOutOfOfficeReply", + "delete"=>"gwAcctDelOutOfOfficeReply"), + "mailBoxWarnLimit" =>array( "get"=>"", + "save"=>"", + "delete"=>""), + "mailBoxSendSizelimit" =>array( "get"=>"gwAcctGetQuota", + "save"=>"gwAcctSetQuota", + "delete"=>"gwAcctDelQuota"), + "mailBoxHardSizelimit" =>array( "get"=>"gwAcctGetMailLimit", + "save"=>"gwAcctSetMailLimit", + "delete"=>"gwAcctDelMailLimit"), + "mailBoxAutomaticRemoval" =>array( "get"=>"", + "save"=>"", + "delete"=>""), + "localDeliveryOnly" =>array( "get"=>"", + "save"=>"", + "delete"=>""), + "dropOwnMails" =>array( "get"=>"", + "save"=>"", + "delete"=>""), + "accountProperties" => array("get"=>"gwAcctGetProperties", + "save"=>"gwAcctSetProperties", + "delete"=>"gwAcctDelProperties"), + "mailFolder" => array( "get"=>"gwAcctGetFolderList", + "save"=>"gwAcctAddFolder", + "delete"=>"gwAcctDelFolder") + ); + + + /*! \brief Constructor sets the connection to the rpc service + * initializes the class + */ + function __construct(&$pluginRef) + { + $this->groupwarePluginRef = &$pluginRef; + + // TODO: Remove all echos + + $this->init(); + } + + + /*! \brief Gets the capabilities of the server + * builds an array with availbale features and knows how to call get, save, delete functions of + * groupware rpc. + */ + public function init() + { + $this->availableMethods = $this->groupwarePluginRef->rpcExec('gwGetCapabilities'); + //$this->availableProperties = $this->groupwarePluginRef->rpcExec('gwGetSupportedProperties'); + //$this->debug("availableProperties on init:", $this->availableProperties); + } + + + /*! \brief Generic saving method for all features defined in $gwFeatures + * which are the available features. + */ + public function save($feature, $uid, $valueArray) + { + $function = GroupwareDao::$gwFeatures[$feature]["save"]; + if(is_array($valueArray)){ + $valueArray = array_merge(array($function, $uid), $valueArray); + }else{ + $valueArray = array($function, $uid, $valueArray); + } + + $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray); + return $result; + } + + + /*! \brief generic get method for all features defined in $gwFeatures + * which are the available features. + */ + public function get($feature, $valueArray) + { + // TODO: Check if feture available ? get and return the result. + $function = GroupwareDao::$gwFeatures[$feature]["get"]; + if(is_array($valueArray)){ + $valueArray = array_merge(array($function), $valueArray); + }else{ + $valueArray = array($function, $valueArray); + } + + $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray); + return $result; + } + + + /*! \brief generic delete function for all features defined in $gwFeatures + * which are the available features. + * + * NOT YET IMPLEMENTED + */ + public function del($feature, $valueArray) + { + // TODO: check if feture available del and return the result. + + echo "deletion of values is not implemented yet"; + /* + $function = GroupwareDao::$gwFeatures[$feature]["delete"]; + $valueArray = array_merge(array($function), $valueArray); + $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray); + return $result; + */ + } + + + /*! \brief determine availability of features. + * + * @param methodName + * @return boolean + */ + public function gwFeatureAvailable($methodName) + { + return(isset($this->availableMethods[$methodName]) && ($this->availableMethods[$methodName])); + } + + + /*! \brief comprehensive user info will dessolve into one groupware call later + * right now it will get all data of the features that are available in the plugin. + * @param int $uid + * @return assoc array "feature" => "gwValue"; + */ + public function getComprehensiverUser( $uid) + { + //$hi = $this->groupwarePluginRef->rpcExec('gwGetCapabilities'); + $resultArr = array(); + + if($this->groupwarePluginRef->isFeatureEnabled("primaryMail")){ + $resultArr["primaryMail"] = $this->get("primaryMail", array($uid)); + } + + if($this->groupwarePluginRef->isFeatureEnabled("alternateAddresses")){ + $resultArr["alternateAddresses"] = $this->get("alternateAddresses", array($uid)); + } + + if($this->groupwarePluginRef->isFeatureEnabled("forwardingAddresses")){ + $FWaddresses = $this->get("forwardingAddresses", array($uid)); +// $FWaddresses = current($FWaddresses); + $resultArr["forwardingAddresses"] = key($FWaddresses); + } + + // Location dropdownlist - only readable + if($this->groupwarePluginRef->isFeatureEnabled("mailLocations")){ + $resultArr["mailLocations"] = $this->groupwarePluginRef->rpcExec('gwGetMailboxLocations'); + $resultArr["mailLocation"] = $this->groupwarePluginRef->rpcExec('gwAcctGetLocation',$uid); + } + + //TODO: getLocation muss ebenfalls geholt werden + // Quota quotaUsage, quotaSize + if($this->groupwarePluginRef->isFeatureEnabled("quotaSize") || + $this->groupwarePluginRef->isFeatureEnabled("quotaUsage") || + $this->groupwarePluginRef->isFeatureEnabled("mailBoxWarnLimit") || + $this->groupwarePluginRef->isFeatureEnabled("mailBoxSendSizelimit") || + $this->groupwarePluginRef->isFeatureEnabled("mailBoxHardSizelimit")){ + + // Usage is a Mapi function which is not yet + + // TODO: Remove the following dummy and enable the qota fetch from groupware + + //echo "Quota function not yet implemented on server side!!"; + //$quota = $this->get("quotaSize", array($uid)); + $quota = array( "warn_limit" => 1008, + "send_limit" => 108, + "hard_limit" => 1108, + "hold" => 508, + "usage" => 1108); + $resultArr["quotaSize"] = $quota["usage"]; + $resultArr["quotaSize"] = $quota["hold"]; + if($quota["warn_limit"] > 0){ + $resultArr["mailBoxWarnLimitEnabled"] = true; + $resultArr["mailBoxWarnLimitValue"] = $quota["warn_limit"]; + }else{ + $resultArr["mailBoxWarnLimitEnabled"] = false; + $resultArr["mailBoxWarnLimitValue"] = 0; + } + if($quota["send_limit"] > 0){ + $resultArr["mailBoxSendSizelimitEnabled"] = True; + $resultArr["mailBoxSendSizelimitValue"] = $quota["send_limit"]; + }else{ + $resultArr["mailBoxSendSizelimitEnabled"] = FALSE; + $resultArr["mailBoxSendSizelimitValue"] = 0; + } + if($quota["hard_limit"] > 0){ + $resultArr["mailBoxHardSizelimitEnabled"] = True; + $resultArr["mailBoxHardSizelimitValue"] = $quota["hard_limit"]; + }else{ + $resultArr["mailBoxHardSizelimitEnabled"] = FALSE; + $resultArr["mailBoxHardSizelimitValue"] = 0; + } + } + + //this function seems to be broken on the server. + //addding dummy + + if($this->groupwarePluginRef->isFeatureEnabled("vacationMessage")){ + + $vacMessage = $this->get("vacationMessage", array($uid)); + //$resultArr["vacationMessage"] = "dummy Vacation message - (getOutOfOfficeReply currently throws errors )"; + } + return $resultArr; + } +} +?> diff --git a/gosa-plugins/groupware/personal/groupware/generic.tpl b/gosa-plugins/groupware/personal/groupware/generic.tpl index 9f7973cfa..ca32d3b1c 100644 --- a/gosa-plugins/groupware/personal/groupware/generic.tpl +++ b/gosa-plugins/groupware/personal/groupware/generic.tpl @@ -319,4 +319,7 @@ {/if} {/if} + {if $mailFolder_isActive} +
Hape, die Folder sind enabled
+ {/if}