Code

Added checks to distribution list plugin
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 12 Oct 2010 08:33:37 +0000 (08:33 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 12 Oct 2010 08:33:37 +0000 (08:33 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19995 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/groupware/admin/ogroups/GroupwareDistributionList/class_GroupwareDistributionList.inc

index 6e499e35420b6c8818df21ea7eddb80bf8d692d0..89a55acf58fd32c526dba7f5bcba83b73634db88 100644 (file)
@@ -381,6 +381,10 @@ class GroupwareDistributionList extends plugin
      */  
     function save()
     {
+        // Cast mailSizeLimit to integer
+        if($this->mailSizeLimit!=NULL){
+           $this->mailSizeLimit += 0;
+        }
 
         // If this is a new account then add it.
         $rpc = $this->config->getRpcHandle();
@@ -498,20 +502,40 @@ class GroupwareDistributionList extends plugin
     {
         $messages = plugin::check();
 
+        // Get current object-group name maybe it is invalid for us.
+        if(isset($this->parent->by_object['ogroup']->cn)){
+            $this->cn = &$this->parent->by_object['ogroup']->cn;
+        }
+        // Validate name later...  #FIXME
+
+        // Validate email address
+        if(!tests::is_email($this->primaryMailAddress)) {
+            $messages[] = msgPool::invalid(_("Mail address"), $this->primaryMailAddress, '', 'example@gonicus.de');
+        }
+
+        // Validate email address
+        if($this->featureEnabled('mailSizeLimit')){
+            if($this->mailSizeLimit != NULL && !is_numeric($this->mailSizeLimit)){
+                $messages[] = msgPool::invalid(_("Incoming mail size limitation"), $this->mailSizeLimit, '/[0-9]/' );
+            }
+        }
+
         // Check which accounts have valid groupware mail addresses.
-        $uids = $this->getOgroupMemberList();
-        $rpc = $this->config->getRpcHandle(); 
-        $verified = $rpc->gwVerifyAcct($uids);
-        if(!$rpc->success()){
-            $messages[] = sprintf(_("Failed to verify account ids! Error was: '%s'."),$rpc->get_error());
-        }else{
-            $noExt = array();
-            foreach($verified as $uid => $mail){
-                if(empty($mail)) $noExt[] = $uid;
-            }   
-            if(count($noExt)){
-                $message = sprintf(_("The following object group members do not have a valid groupware extension and will be ignored as distribution list members: %s"),msgPool::buildList($noExt));
-                msg_dialog::display(_("Info"),$message, INFO_DIALOG);
+        if(!count($messages)){
+            $uids = $this->getOgroupMemberList();
+            $rpc = $this->config->getRpcHandle(); 
+            $verified = $rpc->gwVerifyAcct($uids);
+            if(!$rpc->success()){
+                $messages[] = sprintf(_("Failed to verify account ids! Error was: '%s'."),$rpc->get_error());
+            }else{
+                $noExt = array();
+                foreach($verified as $uid => $mail){
+                    if(empty($mail)) $noExt[] = $uid;
+                }   
+                if(count($noExt)){
+                    $message = sprintf(_("The following object group members do not have a valid groupware extension and will be ignored as distribution list members: %s"),msgPool::buildList($noExt));
+                    msg_dialog::display(_("Info"),$message, INFO_DIALOG);
+                }
             }
         }