Code

#2 added isFeatureEnabled an hasFeatureBeenChanged to plugin save MEthod.
authorhzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Oct 2010 12:05:11 +0000 (12:05 +0000)
committerhzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 13 Oct 2010 12:05:11 +0000 (12:05 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20028 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index b402619ef8bac0bfbff19738725ebf0a034ce86a..da8266864169cf9eeef1648354c145aeab79b2d4 100644 (file)
@@ -147,13 +147,19 @@ class Groupware extends plugin
     }
 
 
-    /*! \brief     TODO: comment
+    /*! \brief    Checks if feature is availavle on the server (a call to getCapabilities achieves this.)
      */
     public function isFeatureEnabled($featureName)
     {
         return(isset($this->enabledFeatures[$featureName]) && $this->enabledFeatures[$featureName]);
     }
-
+       /*! \brief     Checking if the feature has been changed since loading it from server (initial state)
+     */
+    public function hasFeaturebeenChanged($featureName)
+    {
+               //TODO: must be implemented.
+        return true;
+    }
 
     /*! \brief  Try initialize the groupware account.
      *          This method fetches all required information to manage the
@@ -785,38 +791,55 @@ class Groupware extends plugin
                 return;
             }
         }
-
-        $this->groupwareDao->saveFoldersAndAcls($this->uid, $this->mailFolder);
+               if($this->isFeatureEnabled("mailFolder") && $this->hasFeaturebeenChanged("mailFolder")){
+                       $this->groupwareDao->saveFoldersAndAcls($this->uid, $this->mailFolder);
+               }
 
         // Save the primary Email Address.
-        if(!empty($this->mailAddress)){
-            $this->groupwareDao->save("primaryMail", $this->uid, $this->mailAddress);
-        }
-
-        // Save alternateAddresses and forwarding. 
-        if(!empty($this->alternateAddresses) 
-                       && isset($this->alternateAddresses) 
-                       && is_array($this->alternateAddresses)){
-                       $this->groupwareDao->save("alternateAddresses", $this->uid, array($this->alternateAddresses));
-
-        }
-        if(!empty($this->forwardingAddresses) 
-                       && isset($this->forwardingAddresses) 
-                       && is_array($this->forwardingAddresses)){
-                               
-                               // Only the first Address will be set as forward Address.
-                               $fw = array();
-                               $fw[$this->forwardingAddresses[0]] = true;
-                               $this->groupwareDao->save("forwardingAddresses", $this->uid, array($fw));
-        }
+               if($this->isFeatureEnabled("primaryMail")&& $this->hasFeaturebeenChanged("primaryMail")){
+                       if(!empty($this->mailAddress )){
+                               $this->groupwareDao->save("primaryMail", $this->uid, $this->mailAddress);
+                       }
+               }
 
-        $quota = array(        "warn_limit" => $this->mailBoxWarnLimitValue,
-                "send_limit" => $this->mailBoxSendSizelimitValue,
-                "hard_limit" => $this->mailBoxHardSizelimitValue,
-                "hold" => $this->quotaSize);
+        // Save alternateAddresses 
+               if($this->isFeatureEnabled("alternateAddresses")&& $this->hasFeaturebeenChanged("alternateAddresses")){
+                       if(!empty($this->alternateAddresses) 
+                                       && isset($this->alternateAddresses) 
+                                       && is_array($this->alternateAddresses)){
+                               $this->groupwareDao->save("alternateAddresses", $this->uid, array($this->alternateAddresses));
 
-        $this->groupwareDao->save("quotaSize", $this->uid, $quota);
-        // TODO: save Mailbox location
+                       }
+               }
+               // Save forwardingAddresses
+               if($this->isFeatureEnabled("forwardingAddresses") && $this->hasFeaturebeenChanged("forwardingAddresses")){
+                       if(!empty($this->forwardingAddresses) 
+                                       && isset($this->forwardingAddresses) 
+                                       && is_array($this->forwardingAddresses)){
+                                       
+                                       // Only the first Address will be set as forward Address.
+                                       $fw = array();
+                                       $fw[$this->forwardingAddresses[0]] = true;
+                                       $this->groupwareDao->save("forwardingAddresses", $this->uid, array($fw));
+                       }
+               }
+               //Save quota
+               if( ($this->isFeatureEnabled("mailBoxWarnLimit") ||
+                       $this->isFeatureEnabled("mailBoxSendSizelimit") ||
+                       $this->isFeatureEnabled("mailBoxHardSizelimit") ||
+                       $this->isFeatureEnabled("mailBoxAutomaticRemoval"))
+               && ($this->hasFeaturebeenChanged("mailBoxWarnLimit") ||
+                       $this->hasFeaturebeenChanged("mailBoxSendSizelimit") ||
+                       $this->hasFeaturebeenChanged("mailBoxHardSizelimit") ||
+                       $this->hasFeaturebeenChanged("mailBoxAutomaticRemoval") )){
+                       $quota = array( "warn_limit" => $this->mailBoxWarnLimitValue,
+                                       "send_limit" => $this->mailBoxSendSizelimitValue,
+                                       "hard_limit" => $this->mailBoxHardSizelimitValue,
+                                       "hold" => $this->quotaSize);
+
+                       $this->groupwareDao->save("quotaSize", $this->uid, $quota);
+               }
+               // TODO: save Mailbox location
     }