Code

9031196e98ad2535883807e3f5f869e0e482f226
[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       /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again.
59       if (isset($mailObject->attrs[$source])){
60         $mailObject->attrs[$dest]= $mailObject->attrs[$source];
61         unset ($mailObject->attrs[$source]);
62       */
64       if (isset($mailObject->attrs[$source])){
65         unset($mailObject->attrs[$source]['count']);
66         $mailObject->attrs[$dest]= $mailObject->attrs[$source];
67         $mailObject->$dest=        $mailObject->attrs[$source];
69         unset ($mailObject->$dest['count']);
70         unset ($mailObject->attrs[$source]);
71       }
72     }
74     /* Adjust server name if needed */
75     foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
76       if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
77         $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
78         break;
79       }
80     }
81   }
84   function fixAttributesOnStore(&$mailObject)
85   {
86     /* Convert attributes and objectClasses */
87     foreach ($this->attribute_map as $source => $dest){
88       if (isset($mailObject->attrs[$source])){
89         $mailObject->attrs[$dest]= $mailObject->attrs[$source];
90         unset ($mailObject->attrs[$source]);
91       }
92     }
93     $objectclasses= array();
94     foreach ($mailObject->attrs['objectClass'] as $oc){
95       if ($oc !=  'kolabInetOrgPerson' && $oc !=  'kolabSharedFolder'){
96         $objectclasses[]= $oc;
97       }
98     }
99     $mailObject->attrs['objectClass']= $objectclasses;
100     if (in_array("posixGroup", $mailObject->attrs['objectClass'])){
101       $mailObject->attrs['objectClass'][]= 'kolabSharedFolder';
103       /* Work on acl attribute */
104       $new_acl= array();
105       foreach ($mailObject->attrs['acl'] as $uacl){
106         list($user, $acl) = split(" ", $uacl);
107         if ($user != "%members%"){
108           $new_acl[$user]= $uacl;
109         } else {
110           foreach ($mailObject->members as $member){
111             $new_acl[$member]= "$member $acl";
112           }
113         }
114       }
115       $mailObject->attrs['acl']= array();
116       foreach ($new_acl as $key => $value){
117         $mailObject->attrs['acl'][]= $value;
118       }
119     } else {
120       $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
121     }
123     /* Remove imap:// tagging */
124     $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
125     $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
126     $mailObject->attrs['kolabDeleteFlag']= array();
127   }
130   function fixAttributesOnRemove(&$mailObject)
131   {
132     /* Add attribute for object deletion and remove GOsa specific
133        values from entry. */
134     unset ($mailObject->attrs['mail']);
135     $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
136   }
140 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
141 ?>