Code

Updated locales. Fixed small typos
[gosa.git] / plugins / admin / groups / class_groupMail.inc
index 32ae8a21dde9d536b81a00172b9da46d6a323425..cf71b3b6629fbd132ca492cdaf64d0022e329efe 100644 (file)
@@ -47,7 +47,7 @@ class mailgroup extends plugin
   var $indexed_user= array();
 
   /* attribute list for save action */
-  var $attributes= array(   "mail",   "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize",
+  var $attributes= array( "mail",   "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize",
       "gosaMailAlternateAddress", "gosaMailForwardingAddress",
       "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox",
       "acl","gosaSharedFolderTarget", "gosaVacationMessage");
@@ -112,10 +112,7 @@ class mailgroup extends plugin
         $method= new $this->method($this->config);
 
         if ($method->connect($this->attrs["gosaMailServer"][0])){
-
-          /*  get Quota
-           */
-          $quota= $method->getQuota($this->uid);
+        
 
           /* Maybe the entry is not saved in new style, get
              permissions from IMAP and convert them to acl attributes */
@@ -154,21 +151,30 @@ class mailgroup extends plugin
             }
 
           } // ENDE ! isset ($this->attrs['acl'])
+          
+          /* Adapt attributes if needed */
+          $method->fixAttributesOnLoad($this);
+          
+          /*  get Quota */
+          $quota= $method->getQuota($this->uid);
 
           /* Update quota values */
-          if ($quota['gosaMailQuota'] == 2147483647){
-            $this->quotaUsage= "";
-            $this->gosaMailQuota= "";
-          } else {
-            $this->quotaUsage= $quota['quotaUsage'];
-            $this->gosaMailQuota= $quota['gosaMailQuota'];
+          if(is_array($quota)){
+            if ($quota['gosaMailQuota'] == 2147483647){
+              $this->quotaUsage= "";
+              $this->gosaMailQuota= "";
+            } else {
+              $this->quotaUsage= $quota['quotaUsage'];
+              $this->gosaMailQuota= $quota['gosaMailQuota'];
+            }
+          }else{
+            $this->quotaUsage     = "";
+            $this->gosaMailQuota  = "";
+            print_red(sprintf(_("Can't get quota information for '%s'."),$this->uid));
           }
           $method->disconnect();
         }   // ENDE $method->connect($this->attrs["gosaMailServer"][0])){
 
-        /* Adapt attributes if needed */
-        $method->fixAttributesOnLoad($this);
-
       }   // ENDE gosaMailServer
 
     }   // ENDE dn != "new"
@@ -269,6 +275,11 @@ class mailgroup extends plugin
       }
     }
 
+    /* Load Mailserver  
+     */
+    if(isset($this->attrs['gosaMailServer'][0])){
+      $this->gosaMailServer =  $this->attrs['gosaMailServer'][0];
+    }
     /* Fill translations */
     $this->perms["lrs"]= _("read");
     $this->perms["lrsp"]= _("post");
@@ -460,7 +471,8 @@ class mailgroup extends plugin
       }
 
       $acl= array($this->config->current['BASE'] => ":all");
-      $res= get_list($acl, "(&(objectClass=gosaMailAccount)$filter)", TRUE, $gmailfilter['depselect'], array("sn", "mail", "givenName"), TRUE);
+      $res= get_list("(&(objectClass=gosaMailAccount)$filter)", $acl, $gmailfilter['depselect'],
+                     array("sn", "mail", "givenName"), GL_SUBSEARCH | GL_SIZELIMIT);
       $ldap->cd($gmailfilter['depselect']);
       $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName"));
       error_reporting (0);
@@ -569,7 +581,6 @@ class mailgroup extends plugin
      */
     if(isset($this->config->current['MAILMETHOD'])&&preg_match("/kolab/i",$this->config->current['MAILMETHOD'])){
       $this->attributes[]="acl";
-      $this->attributes[]="kolabHomeServer";
       $this->objectclasses[] = "kolabSharedFolder";
     }
     /* include global link_info */
@@ -583,24 +594,23 @@ class mailgroup extends plugin
     $this->attrs['gosaMailForwardingAddress']= array();
     $this->attrs['gosaSharedFolderTarget']= array();
 
-    /* Keep uid */
-    unset ($this->attrs['uid']);
-    $ldap->cd($this->dn);
-    $this->cleanup();
-    $ldap->modify ($this->attrs); 
-
-    show_ldap_error($ldap->get_error());
-
     /* Connect to IMAP server for account deletion */
-    if ($this->is_account){
+    if ($this->initially_was_account){
       $method= new $this->method($this->config);
-      if ($method->connect($this->attrs["gosaMailServer"][0])){
+      if ($method->connect($this->gosaMailServer)){
         /* Remove account from IMAP server */
         $method->deleteMailbox($this->uid);
         $method->disconnect();
       }
       $method->fixAttributesOnRemove($this);
     }
+    /* Keep uid */
+    unset ($this->attrs['uid']);
+
+
+    $ldap->cd($this->dn);
+    $ldap->modify ($this->attrs); 
+    show_ldap_error($ldap->get_error(), _("Removing group mail settings failed"));
 
     /* Optionally execute a command after we're done */
     $this->handle_post_events("remove");
@@ -686,9 +696,7 @@ I: Only insider delivery */
     /* Save arrays */
     $this->attrs['gosaMailAlternateAddress']  = $this->gosaMailAlternateAddress;
     $this->attrs['gosaMailForwardingAddress'] = $this->gosaMailForwardingAddress;
-
-    /* Save shared folder target */
-    $this->attrs['gosaSharedFolderTarget']= "share+".$this->uid;
+    $this->attrs['gosaSharedFolderTarget']    = "share+".$this->uid;
 
     if(preg_match("/kolab/i",$this->mmethod)){
       /* Save acl's */
@@ -742,11 +750,6 @@ I: Only insider delivery */
     /* Exchange '%member%' pseudo entry */
     $memberacl= $this->imapacl['%members%'];
 
-    if(empty($memberacl)){
-      print_a($this);
-      exit();
-    }
-
     foreach ($this->members as $user){
       if(preg_match("/kolab/i",$this->mmethod)){
         $ldap->cd($this->config->current['BASE']);
@@ -771,8 +774,7 @@ I: Only insider delivery */
     $ldap->cd($this->dn);
     $this->cleanup();
     $ldap->modify ($this->attrs); 
-
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), _("Saving group mail settings failed"));
 
     /* Optionally execute a command after we're done */
     if ($this->initially_was_account == $this->is_account){
@@ -789,7 +791,12 @@ I: Only insider delivery */
   {
     $ldap= $this->config->get_ldap_link();
 
-    $message= array();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
+    if(!$this->is_account) return array();
+    
+    //$message[] = $str;      
 
     /* must: mail */
     if ($this->mail == ""){
@@ -804,7 +811,7 @@ I: Only insider delivery */
     if ($ldap->count() != 0){
       $message[]= _("The primary address you've entered is already in use.");
     }
-
+  
     /* Check quota */
     if ($this->gosaMailQuota != '' && chkacl ($this->acl, "gosaMailQuota") == ""){
       if (!is_numeric($this->gosaMailQuota)) {
@@ -938,6 +945,34 @@ I: Only insider delivery */
     return ($name);
   }
 
+  function getCopyDialog()
+  {
+    if(!$this->is_account) return("");
+
+    $smarty = get_smarty();
+    $smarty->assign("gosaMailAlternateAddress",$this->gosaMailAlternateAddress);
+    $smarty->assign("gosaMailForwardingAddress",$this->gosaMailForwardingAddress);
+    $smarty->assign("mail",$this->mail);
+    $display= $smarty->fetch (get_template_path('paste_mail.tpl', TRUE));
+    $ret = array();
+    $ret['string'] = $display;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+  function saveCopyDialog()
+  {
+    if(!$this->is_account) return;
+
+    /* Perform ADD / REMOVE ... for mail alternate / mail forwarding addresses 
+    */
+    $this->execute();
+    if(isset($_POST['mail'])){
+      $this->mail = $_POST['mail'];
+    }
+  }
+
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: