Code

(libgroupware) worked on setMember Acls for folders. Correct call - server refuses...
authorhzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 23 Nov 2010 16:14:40 +0000 (16:14 +0000)
committerhzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 23 Nov 2010 16:14:40 +0000 (16:14 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20343 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 99a2f6e742b1b902728bca83c286f1d88daf27d9..72b6a64da3673e36bf143360b3dbb9422d43c59c 100644 (file)
@@ -331,7 +331,8 @@ class Groupware extends plugin
                                else{
                                        $this->mailFolderChanges = $this->FolderWidget->save();
                                }
-                               $this->folderSave();
+                               
+                               $this->folderSave($this->uid);
                 $this->FolderWidget = NULL;
             }
         }
@@ -899,9 +900,10 @@ class Groupware extends plugin
             }
         }
 
-        // Save account folders
+        // TODO: Check the following paragraph
+               // Save account folders
         if($this->mailFolder !== NULL && $this->isFeatureEnabled("mailFolder") && $this->hasFeaturebeenChanged("mailFolder")){
-            $res = $this->saveFoldersAndAcls($this->uid, $this->mailFolder);
+            //$res = $this->saveFoldersAndAcls($this->uid, $this->mailFolder);
             if($res === NULL){
                 $message = _("Saving mail folder failed!");
                 msg_dialog::display(_("Error"),$message."<br>".sprintf(_("Error was: '%s'."),$this->rpcErrorMessage),ERROR_DIALOG);
@@ -975,11 +977,11 @@ class Groupware extends plugin
                        }
                        
                        //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"]."<br>";
+                               echo "Status: ".$this->mailFolderChanges[$folder]["status"]."<br>";
+                               
                                if($this->mailFolderChanges[$folder]["status"] == "added"){
                                        $this->groupwareDao->save("mailFolder", $folder);
                                }
@@ -987,27 +989,41 @@ class Groupware extends plugin
                                        $this->groupwareDao->del("mailFolder", $folder);
                                }       
                                
+                               $memberListToBeSaved = array();
                                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."<br>";
                                                        
                                                        //set Default ACLs if not yet set by User
                                                        $defAcls = GroupwareDefinitions::getDefaultFolderACLs();
-                                                       $memberListToBeSaved = array_merge($defAcls, $memberlist["acls"] );
+                                                       $memberListToBeSaved = $defAcls;
+                                                       //append all mebers set in Gosa widget.
+                                                       foreach($memberlist["acls"] as $member){
+                                                               $memberListToBeSaved[$member["name"]] = $member["acl"];
+                                                       }
                                                }
                                        }
                                        else{
-                                               if(array_differs($memberlist["acls"], $this->mailFolderChanges[$folder]["acls"])){
-                                                       echo "DEBUG HAPE- Changing ACLs Folder".$folder."<br>";
-                                                       $memberListToBeSaved = array_merge($memberlist["acls"]);
+                                               echo "--- Hello1";
+                                               print_a($memberlist["acls"]);
+                                               echo "--- Hello2";
+                                               print_a($this->mailFolderChanges[$folder]["acls"]);
+                                               
+                                               if(array_differs($memberlist["acls"], $this->mailFolder[$folder]["acls"])){
+                                                       //append all mebers set in Gosa widget.
+                                                       echo "ACLs have changed.";
+                                                       foreach($memberlist["acls"] as $member){
+                                                               $memberListToBeSaved[$member["name"]] = $member["acl"];
+                                                       }
                                                }
                                        }
-                                       echo "<pre>";
-                                       print_r($memberListToBeSaved);
-                                       echo "</pre>";
-                                       $this->groupwareDao->save("folderACLs", $this->uid, array($memberListToBeSaved));
+                                       if(!empty($memberListToBeSaved)){
+                                               echo "List To save:<pre>";
+                                               print_r($memberListToBeSaved);
+                                               echo "</pre><br>";
+                                               $this->groupwareDao->save("folderACLs", $folder, array($memberListToBeSaved));
+                                       }
                                }
                        }
                }
@@ -1068,8 +1084,8 @@ class Groupware extends plugin
                         $messages[] = _("The primary address cannot be used as forwarding address!");
                     }
                 }
-            }  
-        }                      
+            }
+        }
 
         //checks for feature "mailLimit" - integer 
         if ($this->isFeatureEnabled("mailLimit")){
@@ -1131,7 +1147,6 @@ class Groupware extends plugin
 #       //checks for feature "alternateAddresses"        
 #       if ($this->isFeatureEnabled("alternateAddresses")){}
 
-
         return($messages);
     }
 
@@ -1155,6 +1170,7 @@ class Groupware extends plugin
                         "mailFolder"                    => _("Mail folder"),
                         "quotaUsage"                    => _("Quota usage"),
                         "mailFilter"                    => _("Mail filter"),
+                        "mailFilter"                    => _("Mail filter"),
                         "quotaSize"                     => _("Quota size"),
                         "alternateAddresses"            => _("Alternate mail addresses"),
                         "forwardingAddresses"           => _("Forwarding mail addresses"),
@@ -1216,9 +1232,7 @@ class Groupware extends plugin
 
 
     /*! \brief  This is a feature with many datasets inside which should be 
-     *                 cut in slices and saved separately.
-     */
-    //
+   
     function saveFoldersAndAcls($id, $mailFolder)
     {
         // In the tests with the exchange server groupware setting acls is very
@@ -1240,6 +1254,7 @@ class Groupware extends plugin
         }
         return($res);
     }
+       */
 }
 
 
index dfc0b07630508249ba1227386367a98c5035edf2..a5c5e6f4f6ecfaa36e0f31ef648f9cf00988b98d 100644 (file)
@@ -106,7 +106,6 @@ class GroupwareDao{
                                $valueArray = array($function, $uid, $valueArray);
                        }
                        else{
-
                                //omit otherwise
                                $valueArray = array($function, $uid);
                        }
@@ -203,8 +202,10 @@ class GroupwareDao{
                $resultArr["primaryMail"] = $comp["primaryMail"];
                $resultArr["alternateAddresses"] = $comp["alternateAddresses"];
                
-        $resultArr["forwardingAddresses"] = array(key($comp["forwardingAddresses"]));          
-               var_dump($resultArr["forwardingAddresses"]);
+               //This dao will only accept the first forwardingAddress.
+               $resultArr["forwardingAddresses"] = array(key($comp["forwardingAddresses"]));           
+           var_dump($resultArr["forwardingAddresses"]);
+                                       
                $resultArr["mailLocation"] = $comp["mailLocation"];
                //Quota things.
                $resultArr["quotaSize"] = $comp["quota"]["usage"];
@@ -337,7 +338,7 @@ class GroupwareDao{
                 $resultArr["mailBoxSendSizelimitEnabled"] = TRUE;
                 $resultArr["mailBoxSendSizelimitValue"] = $quota["send_limit"];
             }else{
-                $resultArr["mailBoxSendSizelimitEnabled"] = FALSE;
+                $resultArr["mailBoxSendSizelimitEnabled"] = FALSE; 
             }
             if($quota["hard_limit"] > 0){
                 $resultArr["mailBoxHardSizelimitEnabled"] = TRUE;
@@ -372,8 +373,8 @@ class GroupwareDao{
             $resultArr["vacationEnabled"] = !empty($resultArr["vacationMessage"]);    
         }
         return $resultArr;
-    }
        
+    }
        
        /* \brief   Translates Groupware folderAcls to Gosa widget Acls.
      * @return  Array   list of Groupware Members with rights to folders.