From 76c8bda0508bbe7f5350018fe3108c6028e4ec4b Mon Sep 17 00:00:00 2001 From: hzerres Date: Mon, 22 Nov 2010 12:59:09 +0000 Subject: [PATCH] (groupware) folderAdd and folderDel running git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20319 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../personal/groupware/class_Groupware.inc | 80 +++++++++++++++++-- .../personal/groupware/class_GroupwareDao.inc | 32 ++++---- .../groupware/class_GroupwareDefinitions.inc | 8 ++ 3 files changed, 98 insertions(+), 22 deletions(-) diff --git a/gosa-plugins/groupware/personal/groupware/class_Groupware.inc b/gosa-plugins/groupware/personal/groupware/class_Groupware.inc index b6e78e684..bf74a5bc0 100644 --- a/gosa-plugins/groupware/personal/groupware/class_Groupware.inc +++ b/gosa-plugins/groupware/personal/groupware/class_Groupware.inc @@ -62,6 +62,8 @@ class Groupware extends plugin var $mailAddress = ""; var $mailLocation = ""; var $mailFolder = NULL; + var $mailFolderChanged = NULL; + var $quotaUsage = 0; var $quotaSize = 0; var $alternateAddresses = array(); @@ -199,8 +201,10 @@ class Groupware extends plugin "mailLimit" => array( 'acctGetMailLimit', 'acctSetMailLimit'), //Just for speedup - "folderListWithMembers" => array( + "folderListWithMembers" => array( 'acctGetComprehensiveUser'), + "folderACLs" => array( + 'folderGetMembers', 'folderSetMembers'), "comprehensiveUser" => array( 'acctGetComprehensiveUser') ); @@ -320,8 +324,17 @@ class Groupware extends plugin if(count($msgs)){ msg_dialog::displayChecks($msgs); }else{ - $this->mailFolder = $this->FolderWidget->save(); + + if(!empty($this->mailFolderChanges)){ + $this->mailFolderChanges = array_merge($this->mailFolderChanges, $this->FolderWidget->save()); + } + else{ + $this->mailFolderChanges = $this->FolderWidget->save(); + } + $this->folderSaverLaterObsolete(); + $this->FolderWidget = NULL; + } } @@ -864,8 +877,6 @@ class Groupware extends plugin $this->mailBoxSendSizelimitValue = null; } - - $quota = array( "warn_limit" => $this->mailBoxWarnLimitValue, "send_limit" => $this->mailBoxSendSizelimitValue, "hard_limit" => $this->quotaSize); @@ -926,7 +937,9 @@ class Groupware extends plugin } } - + $this->folderSaverLaterObsolete($this->uid); + + } //checks for feature "quotaUsage" //not to be saved @@ -941,9 +954,60 @@ class Groupware extends plugin # # //checks for feature "dropOwnMails" # if($this->isFeatureEnabled("dropOwnMails") && $this->hasFeaturebeenChanged("dropOwnMails")){} - } - - + + + /*! \brief TODO remove this function later + */ + function folderSaverLaterObsolete($id){ + if($this->isFeatureEnabled("mailFolder")&& $this->hasFeaturebeenChanged("mailFolder")){ + //is sorting necessary? + //Find folders to add + if(empty($this->mailFolderChanges)){ + return; + } + + //Remove the root folder - the widget adds it as new + echo "Removing: user/".$this->uid; + unset($this->mailFolderChanges["user/".$this->uid]); + + foreach($this->mailFolderChanges as $folder => $memberlist){ + echo "Status".$this->mailFolderChanges[$folder]["status"]."
"; + if($this->mailFolderChanges[$folder]["status"] == "added"){ + $this->groupwareDao->save("mailFolder", $folder); + } + if($this->mailFolderChanges[$folder]["status"] == "removed"){ + $this->groupwareDao->del("mailFolder", $folder); + } + + if($this->isFeatureEnabled("folderACLs")){ + //checking if ACL has been changed. + if($this->mailFolderChanges[$folder]["status"] == "added"){ + if(isset($memberlist["acls"])){ + echo "DEBUG HAPE- Changing ACLs Folder".$folder."
"; + + //set Default ACLs if not yet set by User + $defAcls = GroupwareDefinitions::getDefaultFolderACLs(); + $memberListToBeSaved = array_merge($defAcls, $memberlist["acls"] ); + } + + } + else{ + if(array_differs($memberlist["acls"], $this->mailFolderChanges[$folder]["acls"])){ + echo "DEBUG HAPE- Changing ACLs Folder".$folder."
"; + $memberListToBeSaved = array_merge($memberlist["acls"]); + } + } + echo "
";
+					print_r($memberListToBeSaved);
+					echo "
"; + $this->groupwareDao->save("folderACLs", $this->uid, array($memberListToBeSaved)); + } + } + } + //reset the changes.. we have persisted them. + $this->mailFolderChanges = null; + } + /*! \brief Check given values */ function check() diff --git a/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc b/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc index b53a7bcbd..656439674 100644 --- a/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc +++ b/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc @@ -11,6 +11,7 @@ class GroupwareDao{ private $groupwarePluginRef = FALSE; + private static $gwFeatures = array( "primaryMail" => array( "get"=>"gwAcctGetPrimaryMailAddress", @@ -66,7 +67,10 @@ class GroupwareDao{ "folderListWithMembers" => array( "get"=>"gwFolderListWithMembers"), "comprehensiveUser" => array( - "get"=>'gwAcctGetComprehensiveUser') + "get"=>'gwAcctGetComprehensiveUser'), + "folderACLs" => array( + "get"=>'gwFolderGetMember', + "save"=>'gwFolderSetMembers') ); @@ -93,15 +97,15 @@ class GroupwareDao{ /*! \brief Generic saving method for all features defined in $gwFeatures * which are the available features. */ - public function save($feature, $uid, $valueArray) + public function save($feature, $uid, $valueArray = null) { $function = GroupwareDao::$gwFeatures[$feature]["save"]; if(is_array($valueArray)){ $valueArray = array_merge(array($function, $uid), $valueArray); }else{ - $valueArray = array($function, $uid, $valueArray); + $valueArray = array($function, $uid); } - + $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray); return $result; } @@ -129,19 +133,19 @@ class GroupwareDao{ * * NOT YET IMPLEMENTED */ - public function del($feature, $valueArray) + public function del($feature, $uid, $valueArray = null) { - - 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; - */ + $function = GroupwareDao::$gwFeatures[$feature]["delete"]; + if(is_array($valueArray)){ + $valueArray = array_merge(array($function, $uid), $valueArray); + }else{ + $valueArray = array($function, $uid); + } + + $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray); + return $result; } - /*! \brief determine availability of features. * * @param methodName diff --git a/gosa-plugins/groupware/personal/groupware/class_GroupwareDefinitions.inc b/gosa-plugins/groupware/personal/groupware/class_GroupwareDefinitions.inc index 8eb913d32..4cfd0225f 100644 --- a/gosa-plugins/groupware/personal/groupware/class_GroupwareDefinitions.inc +++ b/gosa-plugins/groupware/personal/groupware/class_GroupwareDefinitions.inc @@ -33,6 +33,14 @@ class GroupwareDefinitions $ret[GROUPWARE_RIGHTS_ALL] = _("All"); return($ret); } + + public static function getDefaultFolderACLs() + { + $r["Anonym"] = GROUPWARE_RIGHTS_NONE; + $r["Standard"] = GROUPWARE_RIGHTS_NONE; + + return $r; + } } -- 2.30.2