Code

You can't delete any entry, while goFonForwarding is Set ?
[gosa.git] / include / class_mail-methods-kolab.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2004  Cajus Pollmeier
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 require_once("class_mail-methods-cyrus.inc");
22 class mailMethodKolab extends mailMethodCyrus
23 {
24   var $mbox= "-";
25   var $config;
26   var $gosaMailServer= "";
27   var $uattrib= "mail";
29   var $attribute_map= array("gosaMailAlternateAddress"  =>  "alias",
30                             "gosaMailQuota"             =>  "cyrus-userquota",
31                             "gosaMailServer"            =>  "kolabHomeServer");
33   function mailMethodKolab($config)
34   {
35     $this->config= $config->data['SERVERS']['IMAP'];
36   }
38   function updateMailbox($folder)
39   {
40   }
42   function setQuota($folder, $gosaMailQuota)
43   {
44     return (TRUE);
45   }
48   function deleteMailbox($folder)
49   {
50     return (TRUE);
51   }
54   function fixAttributesOnLoad(&$mailObject)
55   {
56     /* Convert attributes and objectClasses */
57     foreach ($this->attribute_map as $dest => $source){
58       if (isset($mailObject->attrs[$source])){
59         $mailObject->attrs[$dest]= $mailObject->attrs[$source];
60         unset ($mailObject->attrs[$source]);
61       }
62     }
64     /* Adjust server name if needed */
65     foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
66       if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
67         $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
68         break;
69       }
70     }
71   }
74   function fixAttributesOnStore(&$mailObject)
75   {
76     /* Convert attributes and objectClasses */
77     foreach ($this->attribute_map as $source => $dest){
78       if (isset($mailObject->attrs[$source])){
79         $mailObject->attrs[$dest]= $mailObject->attrs[$source];
80         unset ($mailObject->attrs[$source]);
81       }
82     }
83     $objectclasses= array();
84     foreach ($mailObject->attrs['objectClass'] as $oc){
85       if ($oc !=  'kolabInetOrgPerson' && $oc !=  'kolabSharedFolder'){
86         $objectclasses[]= $oc;
87       }
88     }
89     $mailObject->attrs['objectClass']= $objectclasses;
90     if (in_array("posixGroup", $mailObject->attrs['objectClass'])){
91       $mailObject->attrs['objectClass'][]= 'kolabSharedFolder';
93       /* Work on acl attribute */
94       $new_acl= array();
95       foreach ($mailObject->attrs['acl'] as $uacl){
96         list($user, $acl) = split(" ", $uacl);
97         if ($user != "%members%"){
98           $new_acl[$user]= $uacl;
99         } else {
100           foreach ($mailObject->members as $member){
101             $new_acl[$member]= "$member $acl";
102           }
103         }
104       }
105       $mailObject->attrs['acl']= array();
106       foreach ($new_acl as $key => $value){
107         $mailObject->attrs['acl'][]= $value;
108       }
109     } else {
110       $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
111     }
113     /* Remove imap:// tagging */
114     $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
115     $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
116     $mailObject->attrs['kolabDeleteFlag']= array();
117   }
120   function fixAttributesOnRemove(&$mailObject)
121   {
122     /* Add attribute for object deletion and remove GOsa specific
123        values from entry. */
124     unset ($mailObject->attrs['mail']);
125     $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
126   }
130 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
131 ?>