4
class mailMethodKolab extends mailMethodCyrus
6
/* Allow modification of account_ids for existing mail accounts */
7
protected $modifyableMail = FALSE;
9
/* Allow modification of the mail server attribute existing mail accounts */
10
protected $modifyableServer = TRUE;
12
/* Enforces same value for 'mail' as used for 'cn' */
13
protected $mailEqualsCN = TRUE;
15
/* Enabled mail domain selection. If enabled getMailDomains must the domain parts */
16
protected $enableDomainSelection= FALSE;
17
protected $enableQuota = TRUE;
18
protected $enableSieveManager = TRUE;
19
protected $enableVacationRange = TRUE;
20
protected $enableFolderTypes = TRUE;
22
protected $attributes = array(
23
"kolabDeleteflag" => "kolabDeleteflag",
24
"kolabFolderType" => "kolabFolderType",
25
"alias" => "gosaMailAlternateAddress",
26
"cyrus-userquota" => "gosaMailQuota",
27
"kolabHomeServer" => "gosaMailServer");
29
protected $user_prefix = 'user.';
30
protected $share_prefix = 'shared\\.';
32
/* gosaSharedFolderTarget settings,
34
* AccountID = 'shared/herberts.folder@gonicus.de'
35
* 'kolab+' will result in gosaSharedFolderTarget: kolab+shared/herberts.folder@gonicus.de
37
* May be overridden in the gosa.conf.
39
protected $gosaSharedPrefix = 'kolab+';
41
/* Account ID creation */
42
protected $user_id = "%prefix%%uattrib%";
43
protected $share_id = "%prefix%%cn%@%domain%";
45
protected $userObjectClasses = array("kolabInetOrgPerson");
46
protected $shareObjectClasses = array("kolabSharedFolder");
48
/* Handle account removal like a master/slave kolab setup.
49
* The kolabDeleteflag will be added for each server.
51
protected $masterSlave = TRUE;
53
protected $acl_map = array(
56
"p" => "external post",
58
"lrswipcd" => "write",
59
"lrswipcda"=> "admin",
60
"lrswipkxtecda"=> "full-admin",
62
public function fixAttributesOnLoad()
64
mailMethodCyrus::fixAttributesOnLoad();
66
// Tell our parent that there is a relatioship between alias and
67
// gosaMailAlternateAddress. (Avoid plugin::cleanup to filter out alias).
68
if(isset($this->parent->saved_attributes['gosaMailAlternateAddress'])){
69
$this->parent->saved_attributes['alias'] = $this->parent->saved_attributes['gosaMailAlternateAddress'];
73
public function fixAttributesOnStore()
75
mailMethod::fixAttributesOnStore();
76
$this->build_account_id();
77
$this->parent->attrs['kolabDeleteflag'] = array();
79
/* The folderType is set by ::setFolderType(...) */
80
$this->parent->attrs['kolabFolderType'] = array();
81
if($this->type == "group"){
82
$this->parent->attrs['gosaSharedFolderTarget'] =
83
$this->gosaSharedPrefix.$this->account_id;
87
public function fixAttributesOnRemove()
89
mailMethod::fixAttributesOnRemove();
90
foreach($this->attributes as $source => $dest){
91
$this->attrs[$dest] = array();
92
$this->attrs[$source] = array();
94
if($this->type == "user"){
95
$ocs = $this->userObjectClasses;
97
$ocs = $this->shareObjectClasses;
99
$this->parent->attrs['objectClass'] = array_merge( $this->parent->attrs['objectClass'],$ocs);
100
$this->parent->attrs['objectClass'] = array_unique($this->parent->attrs['objectClass']);
102
if($this->type == "group"){
103
$this->parent->attrs['gosaSharedFolderTarget'] =array();
106
/* If the mail setup includes Master and Slave Kolab Server, then we have to remove the
107
* mailAccount from server, by adding a kolabDeleteflag for each server.
109
if($this->masterSlave){
110
$this->parent->attrs['kolabDeleteflag'] = array();
111
foreach($this->getKolabHost() as $md){
112
$this->parent->attrs['kolabDeleteflag'][] = $md;
115
$this->parent->attrs['kolabDeleteflag'] = $this->parent->gosaMailServer;
117
if($this->folderTypesEnabled()){
118
$this->parent->attrs['kolabFolderType'] =array();
123
/* \brief Some method require special folder types, "kolab" for example.
124
!! Those values are dummy values, the base class doesn't use folder types;
125
@return Array Return folder types.
127
public function getAvailableFolderTypes()
130
$ret['CAT'][''] = _("Unspecified");
131
$ret['CAT']['mail']= _("Mails");
132
$ret['CAT']['task']= _("Tasks");
133
$ret['CAT']['journal']= _("Journals");
134
$ret['CAT']['event']= _("Calendar");
135
$ret['CAT']['contact']= _("Contacts");
136
$ret['CAT']['note']= _("Notes");
138
$ret['SUB_CAT'][''][''] = _("Unspecified");
139
$ret['SUB_CAT']['mail'][''] = _("Unspecified");
140
$ret['SUB_CAT']['mail']['inbox'] = _("Inbox");
141
$ret['SUB_CAT']['mail']['drafts'] = _("Drafts");
142
$ret['SUB_CAT']['mail']['sentitems'] = _("Sent");
143
$ret['SUB_CAT']['mail']['junkemail'] = _("SPAM");
145
$ret['SUB_CAT']['task']['default'] = _("Default");
146
$ret['SUB_CAT']['journal']['default'] = _("Default");
147
$ret['SUB_CAT']['event']['default'] = _("Default");
148
$ret['SUB_CAT']['contact']['default'] = _("Default");
149
$ret['SUB_CAT']['note']['default'] = _("Default");
155
/*! \brief Checks whether this account is removeable or not.
156
There may be some dependencies left, eg. kolab.
158
public function accountRemoveable(&$reason = "")
160
if(isset($this->parent->attrs)){
161
$checkArray = array("kolabInvitationPolicy","unrestrictedMailSize", "calFBURL","kolabDelegate","kolabFreeBusyFuture");
162
foreach($checkArray as $index){
163
if(isset($this->parent->attrs[$index])){
164
$reason = _("Mail settings cannot be removed while there are delegations configured!");
174
/* \brief Returns the selected folder type.
175
!! Those values are dummy values, the base class doesn't use folder types;
176
@return Array The folde type.
178
public function getFolderType($default)
180
if($this->enableFolderTypes && isset($this->parent->attrs['kolabFolderType'][0])){
181
$type = $this->parent->attrs['kolabFolderType'][0];
182
if(strpos($type,".")){
183
list($cat,$sub) = explode(".",$this->parent->attrs['kolabFolderType'][0]);
189
return(array("CAT" => $cat, "SUB_CAT" => $sub));
196
/* \brief Returns the selected folder type.
197
!! Those values are dummy values, the base class doesn't use folder types;
198
@return Array The folde type.
200
public function setFolderType($type)
203
$type_str = trim($type['CAT'].".".$type['SUB_CAT']);
204
$type_str = trim($type_str,".");
206
if(empty($type_str)){
207
$attrs['kolabFolderType'] = array();
209
$attrs['kolabFolderType'] = $type_str;
212
$ldap = $this->config->get_ldap_link();
213
$ldap->cd ($this->parent->dn);
214
$ldap->modify($attrs);
215
if($ldap->success()){
216
@DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Successful</b>",
217
"<b>MAIL:</b> Set folderType to '".$type_str."'");
219
@DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Failed: </b>".$ldap->get_error(),
220
"<b>MAIL:</b> Set folderType to '".$type_str."'");
225
public function setQuota($number)
227
mailMethod::setQuota($number);
228
@DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Skipped, part of kolabd!</b>",
229
"<b>Set account quota</b> on server '".$this->MailServer);
233
public function setFolderACLs($permissions)
235
mailMethod::setFolderACLs($permissions);
236
@DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Skipped, part of kolabd!</b>",
237
"<b>Setting folder ACLs!</b>","");
241
public function updateMailbox()
243
mailMethod::updateMailbox();
244
@DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Skipped, part of kolabd!</b>",
245
"<b>Add/Update account</b> on server :".$this->MailServer);
249
public function deleteMailbox()
251
mailMethod::deleteMailbox();
252
@DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "Skipped, part of kolabd!",
253
"<b>Setting Quota</b>");
258
public function allow_remove(&$reason)
260
if(isset($this->parent->attrs)){
261
if(in_array_ics("kolabDeleteflag",array_keys($this->parent->attrs))){
262
$reason = _("Waiting for Kolab to remove mail properties...");
264
}elseif(in_array("gosaMailAccount",$this->parent->attrs['objectClass'])){
265
$reason = _("Please remove the mail settings first!");
274
/*! \brief Returns all kolabHost entries from the k=kolab object.
277
public function getKolabHost()
280
$ldap = $this->config->get_ldap_link();
281
$ldap->cd($this->config->current['BASE']);
282
$ldap->search("(&(objectClass=kolab)(k=kolab)(kolabHost=*))",array("kolabHost"));
284
if($ldap->count() == 1){
285
$attrs = $ldap->fetch();
286
for($i=0; $i <$attrs['kolabHost']['count']; $i ++ ){
287
$host[] = $attrs['kolabHost'][$i];
289
@DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Found: ".trim(implode($host,", "),", ")."</b>",
290
"Revceiving 'Mail hosts for kolab22'.");
291
}elseif($ldap->count() == 0){
292
@DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>No mailHost entries found. Check k=kolab and mailHost</b>",
293
"Revceiving 'Mail hosts for kolab22'.");
295
@DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Found more than one kolab configuration object. Giving up.</b>",
296
"Revceiving 'Mail hosts for kolab22'.");
304
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: