e459411fa417855cf392df5d105de53e3d61f4bd
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 }
47 function setSharedFolderPermissions($folder, $permissions)
48 {
49 }
51 function deleteMailbox($folder)
52 {
53 return (TRUE);
54 }
57 function fixAttributesOnLoad(&$mailObject)
58 {
59 /* Convert attributes and objectClasses */
60 foreach ($this->attribute_map as $dest => $source){
61 if (isset($mailObject->attrs[$source])){
62 $mailObject->attrs[$dest]= $mailObject->attrs[$source];
63 unset ($mailObject->attrs[$source]);
64 }
65 }
66 // without this line gosaMailQuota is in MB instead of KB
67 $mailObject->gosaMailQuota=$mailObject->attrs['gosaMailQuota'][0];
69 /* Adjust server name if needed */
70 foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
71 if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
72 $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
73 break;
74 }
75 }
76 }
79 function fixAttributesOnStore(&$mailObject)
80 {
81 /* Convert attributes and objectClasses */
82 foreach ($this->attribute_map as $source => $dest){
83 if (isset($mailObject->attrs[$source])){
84 $mailObject->attrs[$dest]= $mailObject->attrs[$source];
85 unset ($mailObject->attrs[$source]);
86 }
87 }
88 $objectclasses= array();
89 foreach ($mailObject->attrs['objectClass'] as $oc){
90 if ($oc != 'kolabInetOrgPerson'){
91 $objectclasses[]= $oc;
92 }
93 }
95 $mailObject->attrs['gosaMailQuota'] = ( $mailObject->gosaMailQuota/1024);
97 $mailObject->attrs['objectClass']= $objectclasses;
98 $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
100 /* Remove imap:// tagging */
101 $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
102 $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
103 $mailObject->attrs['kolabDeleteFlag']= array();
104 }
107 function fixAttributesOnRemove(&$mailObject)
108 {
109 /* Add attribute for object deletion and remove GOsa specific
110 values from entry. */
111 unset ($mailObject->attrs['mail']);
112 $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
113 }
115 }
117 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
118 ?>