Code

(groupware) folderAdd and folderDel running
authorhzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 22 Nov 2010 12:59:09 +0000 (12:59 +0000)
committerhzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 22 Nov 2010 12:59:09 +0000 (12:59 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20319 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index b6e78e6849d0ee2fe377ee816ab6d305d058a85f..bf74a5bc0e8b76e179d62f2857f4e844ed140dbf 100644 (file)
@@ -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"]."<br>";
+                               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."<br>";
+                                                       
+                                                       //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."<br>";
+                                                       $memberListToBeSaved = array_merge($memberlist["acls"]);
+                                               }
+                                       }
+                                       echo "<pre>";
+                                       print_r($memberListToBeSaved);
+                                       echo "</pre>";
+                                       $this->groupwareDao->save("folderACLs", $this->uid, array($memberListToBeSaved));
+                               }
+                       }
+               }
+               //reset the changes.. we have persisted them.
+               $this->mailFolderChanges = null;
+       }
+       
     /*! \brief  Check given values 
      */
     function check()
index b53a7bcbdae9ee7384ec7684ef664bf01102a09a..6564396745ef3289f935035c5abdd3a91b99d1d6 100644 (file)
@@ -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
index 8eb913d3214dc419f3bb0fb2bb43a3e2b57d35c6..4cfd0225f04d632106e91dd5ed10a71ebe90bbbb 100644 (file)
@@ -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;
+       }
 }