Code

Macro setting will be saved in Extension_table for asterisk
[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   }
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     if(isset($mailObject->attrs['gosaMailQuota'][0])){
68       $mailObject->gosaMailQuota=$mailObject->attrs['gosaMailQuota'][0];
69     }  
70     
71     
73     /* Adjust server name if needed */
74     foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
75       if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
76         $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
77         break;
78       }
79     }
80   }
83   function fixAttributesOnStore(&$mailObject)
84   {
85     /* Convert attributes and objectClasses */
86     foreach ($this->attribute_map as $source => $dest){
87       if (isset($mailObject->attrs[$source])){
88         $mailObject->attrs[$dest]= $mailObject->attrs[$source];
89         unset ($mailObject->attrs[$source]);
90       }
91     }
92     $objectclasses= array();
93     foreach ($mailObject->attrs['objectClass'] as $oc){
94       if ($oc !=  'kolabInetOrgPerson'){
95         $objectclasses[]= $oc;
96       }
97     }
99     $mailObject->attrs['gosaMailQuota'] = ( $mailObject->gosaMailQuota/1024);
101     $mailObject->attrs['objectClass']= $objectclasses;
102     $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
104     /* Remove imap:// tagging */
105     $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
106     $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
107     $mailObject->attrs['kolabDeleteFlag']= array();
108   }
111   function fixAttributesOnRemove(&$mailObject)
112   {
113     /* Add attribute for object deletion and remove GOsa specific
114        values from entry. */
115     unset ($mailObject->attrs['mail']);
116     $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
117   }
121 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
122 ?>