Code

(libgroupware) implemented Backend rpc method to get comprehensive user data. Left...
authorhzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 15 Nov 2010 10:57:18 +0000 (10:57 +0000)
committerhzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 15 Nov 2010 10:57:18 +0000 (10:57 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20232 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/groupware/personal/groupware/class_Groupware.inc
gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc

index 674bf23dd15a25fc23fc585532ab668bde871337..f61a6b4b5898a8cf6546b2ce2aed50a9b42d0466 100644 (file)
@@ -197,7 +197,12 @@ class Groupware extends plugin
                 "mailFolder"                           => array(
                         'folderList','folderDel','folderAdd'),
                 "mailLimit"                    => array(
-                        'acctGetMailLimit', 'acctSetMailLimit')
+                        'acctGetMailLimit', 'acctSetMailLimit'),
+                               //Just for speedup              
+                               "folderListWithMembers"                 => array(
+                        'acctGetComprehensiveUser'),
+                               "comprehensiveUser"                     => array(
+                        'acctGetComprehensiveUser')
                     );
 
         // Check if all required methods can be called! 
@@ -840,7 +845,7 @@ class Groupware extends plugin
                     $this->hasFeaturebeenChanged("mailBoxAutomaticRemoval") )){
             $quota = array(    "warn_limit" => $this->mailBoxWarnLimitValue,
                     "send_limit" => $this->mailBoxSendSizelimitValue,
-                    "hard_limit" => $this->quotaSize,
+                    "hard_limit" => null,
                     "hold" => $this->quotaSize);
 
             $res = $this->groupwareDao->save("quotaSize", $this->uid, $quota);
index 80940ba5b62f16679cceda99ad85b5f1c4b3d023..9aeeca23d31e3258247117d388efa66488ae7456 100644 (file)
@@ -10,6 +10,7 @@ class GroupwareDao{
     private $accountLocations;
 
     private $groupwarePluginRef = FALSE;
+       
 
     private static $gwFeatures  = array(
             "primaryMail" => array(    "get"=>"gwAcctGetPrimaryMailAddress", 
@@ -59,7 +60,13 @@ class GroupwareDao{
                     "save"=>"gwFolderSetMembers",
                     "delete"=>"gwFolderDelMember"),
             "mailLimit" => array("get"=>"gwAcctGetMailLimit",
-                    "save"=>"gwAcctSetMailLimit")
+                    "save"=>"gwAcctSetMailLimit"),
+                                       
+                       //function for speedup
+                       "folderListWithMembers" => array(
+                                               "get"=>"gwFolderListWithMembers"),
+                       "comprehensiveUser" => array(
+                        "get"=>'gwAcctGetComprehensiveUser')
                 );
 
 
@@ -153,8 +160,58 @@ class GroupwareDao{
      */
     public function getComprehensiverUser( $uid)
     {
-        $resultArr = array();
-
+               if($this->groupwarePluginRef->isFeatureEnabled("comprehensiveUser")){
+                       return $this->getComprehensiverUserCompact($uid);
+               }
+               else{
+                       return $this->getComprehensiverUserSeparate($uid);
+               }
+       }
+       private function getComprehensiverUserCompact($uid){
+               
+               $resultArr = array();
+               
+               if($this->groupwarePluginRef->isFeatureEnabled("mailLocations")){
+            $resultArr["mailLocations"] = $this->groupwarePluginRef->rpcExec('gwGetMailboxLocations');
+         
+        }
+               $comp = $this->get("comprehensiveUser", array($uid));
+               $resultArr["primaryMail"] = $comp["primaryMail"];
+               $resultArr["alternateAddresses"] = $comp["alternateAddresses"];
+        $resultArr["forwardingAddresses"] = $comp["forwardingAddresses"];              
+               $resultArr["mailLocation"] = $comp["mailLocation"];
+               //Quota things.
+               $resultArr["quotaSize"] = $comp["quota"]["usage"];
+
+               $resultArr["mailBoxWarnLimitEnabled"] = TRUE;
+               $resultArr["mailBoxWarnLimitValue"] = $comp["quota"]["usage"];
+
+               $resultArr["mailBoxSendSizelimitEnabled"] = TRUE;
+               $resultArr["mailBoxSendSizelimitValue"] = $comp["quota"]["send_limit"];
+
+               $resultArr["mailBoxHardSizelimitEnabled"] = TRUE;
+               $resultArr["mailBoxHardSizelimitValue"] = $comp["quota"]["hard_limit"]; 
+
+               //Mail Limits
+               $resultArr["mailLimitReceiveEnabled"] = TRUE;
+               $resultArr["mailLimitReceiveValue"] = $comp["mailLimits"]["receive"];
+
+               $resultArr["mailLimitSendEnabled"] = TRUE;
+               $resultArr["mailLimitSendValue"] = $comp["mailLimits"]["send"];
+
+               $resultArr["vacationMessage"] = $comp["vacation"]["message"];
+               
+               //Folder Stuff
+        $prefix = $this->groupwarePluginRef->folderPrefix;
+               $compFolders = $this->get("folderListWithMembers", array($prefix));
+               //ausgelagerte Funktion..
+               $resultArr["mailFolder"] = $this->translateGwAclsToGosaAcls($compFolders);
+       
+               return $resultArr;
+               
+       }
+       
+       private function getComprehensiverUserSeparate($uid){
         if($this->groupwarePluginRef->isFeatureEnabled("primaryMail")){
             $resultArr["primaryMail"] = $this->get("primaryMail", array($uid));
         }
@@ -178,6 +235,16 @@ class GroupwareDao{
 
             // Get groupware folders for the current user.
             $prefix = $this->groupwarePluginRef->folderPrefix;
+                       
+                       $mFolder = $this->get("mailFolder", array($prefix));
+                       
+                       $newFolder = array();
+                       foreach($mFolder as $key =>$val){
+                               $newFolder[$val] = $this->get("private_folderACLS", array($val));
+                       }
+                       $resultArr["mailFolder"] = $this->translateGwAclsToGosaAcls($newFolder);
+                       /*
+                       old Stuff
             $resultArr["mailFolder"] = $this->get("mailFolder", array($prefix));
 
             // Walk through results an fill in missing values, like name, status and acls.
@@ -199,6 +266,7 @@ class GroupwareDao{
                     }
                 }
             }
+                       */
 
             // Add the required status field for each folder.
             foreach($resultArr["mailFolder"] as $id => $folder){
@@ -264,5 +332,26 @@ class GroupwareDao{
         }   
         return $resultArr;
     }
+       private function translateGwAclsToGosaAcls($compFolders){
+               $resultArr = array();
+               $folderAclDef = GroupwareDefinitions::getPermissions();
+               foreach ($compFolders as $fName => $fMembers) {
+                       $resultArr[$fName]["name"] = preg_replace("/^.*\//","",$fName);
+                       foreach($fMembers as $fMember => $fAcl){
+                                $aclLine = array(
+                                       "name" => $fMember, 
+                    "type"=>"user"
+                                       );
+                               if(empty($fAcl)){
+                                       $resultArr[$fName]["acls"]["acl"] = GROUPWARE_RIGHTS_NONE;
+                               }
+                               else{
+                                       $resultArr[$fName]["acls"]["acl"] = $folderAclDef[$fAcl];
+                               }
+                               $resultArr[$fName]["acls"][] = $aclLine;
+                       }
+               }
+               return $resultArr;
+       }
 }
 ?>