summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a99ef81)
raw | patch | inline | side by side (parent: a99ef81)
author | hzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 1 Oct 2010 14:00:22 +0000 (14:00 +0000) | ||
committer | hzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 1 Oct 2010 14:00:22 +0000 (14:00 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19887 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc | patch | blob | history |
diff --git a/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc b/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc
index 2bc4c2caed4766dd91d422c26383794077b0cab4..d3ce7550b3942a10f2c19dea68b5336b9f3ad411 100644 (file)
-<?php\r
- \r
-/*! \brief Data Access Object for groupwares \r
- */\r
-class GroupwareDao{\r
-\r
- private $availableMethods;\r
- private $availableProperties;\r
- private $accountLocations;\r
-\r
- private $groupwarePluginRef = False;\r
-\r
- private static $gwFeatures = array(\r
- "primaryMail" => array( "get"=>"gwAcctGetPrimaryMailAddress", \r
- "save"=>"gwAcctSetPrimaryMailAddress"),\r
- "mailLocations" => array("get"=>"gwGetMailboxLocations"),\r
- "quotaSize" =>array( "get"=>"gwAcctGetQuota", \r
- "save"=>"gwAcctSetQuota",\r
- "delete"=>"gwAcctSetQuota"),\r
- "mailFilter" =>array( "get"=>"gwAcctGetFilters", \r
- "save"=>"gwAcctSetFilters",\r
- "delete"=>"gwAcctDelFilter"),\r
- "alternateAddresses" =>array( "get"=>"gwAcctGetAlternateMailAddresses", \r
- "save"=>"gwAcctSetAlternateMailAddresses",\r
- "delete"=>"gwAcctDelAlternateMailAddress"),\r
- "forwardingAddresses" =>array( "get"=>"gwAcctGetMailForwardAddresses", \r
- "save"=>"gwAcctSetMailForwardAddresses",\r
- "delete"=>"gwAcctDelMailForwardAddress"),\r
- "vacationMessage" =>array( "get"=>"gwAcctGetOutOfOfficeReply", \r
- "save"=>"gwAcctSetOutOfOfficeReply",\r
- "delete"=>"gwAcctDelOutOfOfficeReply"),\r
- "mailBoxWarnLimit" =>array( "get"=>"", \r
- "save"=>"",\r
- "delete"=>""),\r
- "mailBoxSendSizelimit" =>array( "get"=>"gwAcctGetQuota", \r
- "save"=>"gwAcctSetQuota",\r
- "delete"=>"gwAcctDelQuota"),\r
- "mailBoxHardSizelimit" =>array( "get"=>"gwAcctGetMailLimit", \r
- "save"=>"gwAcctSetMailLimit",\r
- "delete"=>"gwAcctDelMailLimit"),\r
- "mailBoxAutomaticRemoval" =>array( "get"=>"", \r
- "save"=>"",\r
- "delete"=>""),\r
- "localDeliveryOnly" =>array( "get"=>"", \r
- "save"=>"",\r
- "delete"=>""),\r
- "dropOwnMails" =>array( "get"=>"",\r
- "save"=>"",\r
- "delete"=>""),\r
- "accountProperties" => array("get"=>"gwAcctGetProperties",\r
- "save"=>"gwAcctSetProperties",\r
- "delete"=>"gwAcctDelProperties"),\r
- "mailFolder" => array( "get"=>"gwAcctGetFolderList",\r
- "save"=>"gwAcctAddFolder",\r
- "delete"=>"gwAcctDelFolder") \r
- );\r
-\r
-\r
- /*! \brief Constructor sets the connection to the rpc service \r
- * initializes the class\r
- */\r
- function __construct(&$pluginRef)\r
- {\r
- $this->groupwarePluginRef = &$pluginRef;\r
- \r
- // TODO: Remove all echos \r
-\r
- $this->init();\r
- }\r
-\r
-\r
- /*! \brief Gets the capabilities of the server\r
- * builds an array with availbale features and knows how to call get, save, delete functions of \r
- * groupware rpc. \r
- */\r
- public function init()\r
- {\r
- $this->availableMethods = $this->groupwarePluginRef->rpcExec('gwGetCapabilities');\r
- //$this->availableProperties = $this->groupwarePluginRef->rpcExec('gwGetSupportedProperties');\r
- //$this->debug("availableProperties on init:", $this->availableProperties);\r
- }\r
-\r
-\r
- /*! \brief Generic saving method for all features defined in $gwFeatures\r
- * which are the available features.\r
- */\r
- public function save($feature, $uid, $valueArray)\r
- {\r
- $function = GroupwareDao::$gwFeatures[$feature]["save"];\r
- if(is_array($valueArray)){\r
- $valueArray = array_merge(array($function, $uid), $valueArray);\r
- }else{\r
- $valueArray = array($function, $uid, $valueArray);\r
- }\r
- \r
- $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray);\r
- return $result;\r
- }\r
-\r
-\r
- /*! \brief generic get method for all features defined in $gwFeatures\r
- * which are the available features.\r
- */\r
- public function get($feature, $valueArray)\r
- {\r
- // TODO: Check if feture available ? get and return the result.\r
- $function = GroupwareDao::$gwFeatures[$feature]["get"];\r
- if(is_array($valueArray)){\r
- $valueArray = array_merge(array($function), $valueArray);\r
- }else{\r
- $valueArray = array($function, $valueArray);\r
- }\r
-\r
- $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray);\r
- return $result;\r
- }\r
-\r
-\r
- /*! \brief generic delete function for all features defined in $gwFeatures\r
- * which are the available features.\r
- * \r
- * NOT YET IMPLEMENTED\r
- */\r
- public function del($feature, $valueArray)\r
- {\r
- // TODO: check if feture available del and return the result.\r
- \r
- echo "deletion of values is not implemented yet";\r
- /*\r
- $function = GroupwareDao::$gwFeatures[$feature]["delete"];\r
- $valueArray = array_merge(array($function), $valueArray);\r
- $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray);\r
- return $result;\r
- */\r
- }\r
-\r
-\r
- /*! \brief determine availability of features.\r
- * \r
- * @param methodName\r
- * @return boolean\r
- */\r
- public function gwFeatureAvailable($methodName)\r
- {\r
- return(isset($this->availableMethods[$methodName]) && ($this->availableMethods[$methodName]));\r
- }\r
-\r
-\r
- /*! \brief comprehensive user info will dessolve into one groupware call later\r
- * right now it will get all data of the features that are available in the plugin.\r
- * @param int $uid\r
- * @return assoc array "feature" => "gwValue"; \r
- */\r
- public function getComprehensiverUser( $uid)\r
- {\r
- //$hi = $this->groupwarePluginRef->rpcExec('gwGetCapabilities');\r
- $resultArr = array();\r
-\r
- if($this->groupwarePluginRef->isFeatureEnabled("primaryMail")){\r
- $resultArr["primaryMail"] = $this->get("primaryMail", array($uid));\r
- }\r
-\r
- if($this->groupwarePluginRef->isFeatureEnabled("alternateAddresses")){\r
- $resultArr["alternateAddresses"] = $this->get("alternateAddresses", array($uid));\r
- }\r
-\r
- if($this->groupwarePluginRef->isFeatureEnabled("forwardingAddresses")){\r
- $FWaddresses = $this->get("forwardingAddresses", array($uid)); \r
-// $FWaddresses = current($FWaddresses);\r
- $resultArr["forwardingAddresses"] = key($FWaddresses);\r
- }\r
-\r
- // Location dropdownlist - only readable\r
- if($this->groupwarePluginRef->isFeatureEnabled("mailLocations")){\r
- $resultArr["mailLocations"] = $this->groupwarePluginRef->rpcExec('gwGetMailboxLocations');\r
- $resultArr["mailLocation"] = $this->groupwarePluginRef->rpcExec('gwAcctGetLocation',$uid);\r
- }\r
-\r
- //TODO: getLocation muss ebenfalls geholt werden \r
- // Quota quotaUsage, quotaSize\r
- if($this->groupwarePluginRef->isFeatureEnabled("quotaSize") || \r
- $this->groupwarePluginRef->isFeatureEnabled("quotaUsage") || \r
- $this->groupwarePluginRef->isFeatureEnabled("mailBoxWarnLimit") || \r
- $this->groupwarePluginRef->isFeatureEnabled("mailBoxSendSizelimit") || \r
- $this->groupwarePluginRef->isFeatureEnabled("mailBoxHardSizelimit")){\r
-\r
- // Usage is a Mapi function which is not yet \r
- \r
- // TODO: Remove the following dummy and enable the qota fetch from groupware\r
- \r
- //echo "Quota function not yet implemented on server side!!";\r
- //$quota = $this->get("quotaSize", array($uid));\r
- $quota = array( "warn_limit" => 1008,\r
- "send_limit" => 108,\r
- "hard_limit" => 1108,\r
- "hold" => 508,\r
- "usage" => 1108);\r
- $resultArr["quotaSize"] = $quota["usage"];\r
- $resultArr["quotaSize"] = $quota["hold"];\r
- if($quota["warn_limit"] > 0){\r
- $resultArr["mailBoxWarnLimitEnabled"] = true;\r
- $resultArr["mailBoxWarnLimitValue"] = $quota["warn_limit"];\r
- }else{\r
- $resultArr["mailBoxWarnLimitEnabled"] = false;\r
- $resultArr["mailBoxWarnLimitValue"] = 0;\r
- }\r
- if($quota["send_limit"] > 0){\r
- $resultArr["mailBoxSendSizelimitEnabled"] = True;\r
- $resultArr["mailBoxSendSizelimitValue"] = $quota["send_limit"];\r
- }else{\r
- $resultArr["mailBoxSendSizelimitEnabled"] = FALSE;\r
- $resultArr["mailBoxSendSizelimitValue"] = 0; \r
- }\r
- if($quota["hard_limit"] > 0){\r
- $resultArr["mailBoxHardSizelimitEnabled"] = True;\r
- $resultArr["mailBoxHardSizelimitValue"] = $quota["hard_limit"]; \r
- }else{\r
- $resultArr["mailBoxHardSizelimitEnabled"] = FALSE;\r
- $resultArr["mailBoxHardSizelimitValue"] = 0;\r
- }\r
- }\r
-\r
- //this function seems to be broken on the server.\r
- //addding dummy\r
-\r
- if($this->groupwarePluginRef->isFeatureEnabled("vacationMessage")){\r
-\r
- $vacMessage = $this->get("vacationMessage", array($uid));\r
- //$resultArr["vacationMessage"] = "dummy Vacation message - (getOutOfOfficeReply currently throws errors )";\r
- } \r
- return $resultArr;\r
- }\r
-}\r
-?>\r
+<?php
+
+/*! \brief Data Access Object for groupwares
+ */
+class GroupwareDao{
+
+ private $availableMethods;
+ private $availableProperties;
+ private $accountLocations;
+
+ private $groupwarePluginRef = False;
+
+ private static $gwFeatures = array(
+ "primaryMail" => 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;
+ }
+}
+?>