1 <?php
2 /*!
3 \brief mail plugin
4 \author Fabian Hicker <Fabian.Hickert@GONICUS.de>
5 \version 2.6.2
6 \date 03.12.2007
8 This class provides the functionality to read and write all attributes
9 relevant for gosaMailAccounts from/to the LDAP.
10 It does syntax checking and displays the formulars required.
11 Special handling like sieve or imap actions will be implemented
12 by the mailMethods.
15 Functions :
17 - mailAccount (&$config, $dn= NULL)
18 - execute()
19 - save_object()
20 - get_vacation_templates()
21 - addForwarder($address)
22 - delForwarder($addresses)
23 - addAlternate($address)
24 - delAlternate($addresses)
25 - prepare_vacation_template($contents)
26 - display_forward_dialog()
27 - remove_from_parent()
28 - save()
29 - check()
30 - adapt_from_template($dn, $skip= array())
31 - getCopyDialog()
32 - saveCopyDialog()
33 - PrepareForCopyPaste($source)
34 - get_multi_edit_values()
35 - multiple_check()
36 - set_multi_edit_values($values)
37 - init_multiple_support($attrs,$all)
38 - get_multi_init_values()
39 - multiple_execute()
40 - multiple_save_object()
41 - make_name($attrs)
42 - plInfo()
45 */
47 class mailAccount extends plugin
48 {
49 /* Definitions */
50 var $plHeadline = "Mail";
51 var $plDescription = "This does something";
52 var $view_logged = FALSE;
53 var $is_account = FALSE;
54 var $initially_was_account = FALSE;
56 /* GOsa mail attributes */
57 var $mail = "";
58 var $gosaVacationStart = 0;
59 var $gosaVacationStop = 0;
60 var $gosaMailAlternateAddress = array();
61 var $gosaMailForwardingAddress = array();
62 var $gosaMailDeliveryMode = "[L ]";
63 var $gosaMailServer = "";
64 var $gosaMailQuota = "";
65 var $gosaMailMaxSize = "";
66 var $gosaVacationMessage = "";
67 var $gosaSpamSortLevel = "";
68 var $gosaSpamMailbox = "";
70 /* The methods defaults */
71 var $mailMethod = NULL;
72 var $MailDomain = "";
73 var $sieveManagementUsed = FALSE;
74 var $vacationTemplates = array();
75 var $sieve_management = NULL;
76 var $forward_dialog = FALSE;
77 var $initial_uid = "";
78 var $mailDomainPart = "";
79 var $mailDomainParts = array();
80 var $MailBoxes = array("INBOX");
82 /* Used LDAP attributes && classes */
83 var $attributes= array(
84 "mail", "gosaMailServer","gosaMailQuota", "gosaMailMaxSize","gosaMailForwardingAddress",
85 "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox","gosaMailAlternateAddress",
86 "gosaVacationStart","gosaVacationStop", "gosaVacationMessage", "gosaMailAlternateAddress",
87 "gosaMailForwardingAddress");
88 var $objectclasses= array("gosaMailAccount");
90 var $multiple_support = TRUE;
92 /*! \brief Initialize the mailAccount
93 */
94 function __construct (&$config, $dn= NULL)
95 {
96 plugin::plugin($config,$dn);
98 /* Intialize the used mailMethod
99 */
100 $tmp = new mailMethod($config,$this);
101 $this->mailMethod = $tmp->get_method();
102 $this->mailMethod->fixAttributesOnLoad();
103 $this->mailDomainParts = $this->mailMethod->getMailDomains();
104 $this->SpamLevels = $this->mailMethod->getSpamLevels();
106 /* Remember account status
107 */
108 $this->initially_was_account = $this->is_account;
110 /* Initialize vacation settings
111 */
112 if(empty($this->gosaVacationStart)){
113 $this->gosaVacationStart = time();
114 $this->gosaVacationStop = time();
115 }
117 /* Read vacation templates
118 */
119 $this->vacationTemplates = $this->get_vacation_templates();
121 /* Initialize configured values
122 */
123 if($this->is_account){
125 if($this->mailMethod->connect() && $this->mailMethod->account_exists()){
127 /* Read quota */
128 $this->gosaMailQuota = $this->mailMethod->getQuota($this->gosaMailQuota);
129 if($this->mailMethod->is_error()){
130 msg_dialog::display(_("Mail error"), sprintf(_("Cannot read quota settings! Error was: %s."),
131 $this->mailMethod->get_error()), ERROR_DIALOG);
132 }
134 /* Read mailboxes */
135 $this->MailBoxes = $this->mailMethod->getMailboxList($this->MailBoxes);
136 if($this->mailMethod->is_error()){
137 msg_dialog::display(_("Mail error"), sprintf(_("Cannot get list of mailboxes! Error was: %s."),
138 $this->mailMethod->get_error()), ERROR_DIALOG);
139 }
141 }elseif(!$this->mailMethod->is_connected()){
142 msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
143 $this->mailMethod->get_error()), ERROR_DIALOG);
144 }elseif(!$this->mailMethod->account_exists()){
145 msg_dialog::display(_("Mail error"), sprintf(_("Mailbox '%s' doesn't exists on mail server: %s."),
146 $this->mailMethod->get_account_id(),$this->gosaMailServer), ERROR_DIALOG);
147 }
149 /* If the doamin part is selectable, we have to split the mail address
150 */
151 if(!(!$this->mailMethod->isModifyableMail() && $this->is_account)){
152 if($this->mailMethod->domainSelectionEnabled()){
153 $this->mailDomainPart = preg_replace("/^[^@]*+@/","",$this->mail);
154 $this->mail = preg_replace("/@.*$/","\\1",$this->mail);
155 if(!in_array($this->mailDomainPart,$this->mailDomainParts)){
156 $this->mailDomainParts[] = $this->mailDomainPart;
157 }
158 }
159 }
161 /* Load attributes containing arrays */
162 foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
163 $this->$val= array();
164 if (isset($this->attrs["$val"]["count"])){
165 for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
166 array_push($this->$val, $this->attrs["$val"][$i]);
167 }
168 }
169 }
170 }
172 /* Intialize sieveManagement if necessary */
173 if($this->mailMethod->allowSieveManagement()){
174 $this->mailboxList = &$this->MailBoxes;
175 $this->sieve_management = new sieveManagement($this->config,$this->dn,$this,$this->mailMethod->getUAttrib());
176 }
178 /* Get global filter config used in add local forward
179 */
180 if (!session::is_set("mailfilter")){
181 $ui= get_userinfo();
182 $base= get_base_from_people($ui->dn);
183 $mailfilter= array( "depselect" => $base,
184 "muser" => "",
185 "regex" => "*");
186 session::set("mailfilter", $mailfilter);
187 }
189 /* Disconnect mailMethod. Connect on demand later.
190 */
191 $this->mailMethod->disconnect();
192 }
195 function execute()
196 {
198 /* Call parent execute */
199 $display = plugin::execute();
201 /* Log view */
202 if($this->is_account && !$this->view_logged){
203 $this->view_logged = TRUE;
204 new log("view","users/".get_class($this),$this->dn);
205 }
208 /****************
209 Account status
210 ****************/
212 if(isset($_POST['modify_state'])){
213 if($this->is_account && $this->acl_is_removeable() && $this->mailMethod->accountRemoveAble()){
214 $this->is_account= FALSE;
215 }elseif(!$this->is_account && $this->acl_is_createable() && $this->mailMethod->accountCreateable()){
216 $this->is_account= TRUE;
217 }
218 }
219 if(!$this->multiple_support_active){
220 if (!$this->is_account && $this->parent === NULL){
221 $display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\"> <b>".
222 msgPool::noValidExtension(_("Mail"))."</b>";
223 $display.= back_to_main();
224 return ($display);
225 }
226 if ($this->parent !== NULL){
227 if ($this->is_account){
228 $reason = "";
229 if(!$this->mailMethod->accountRemoveable($reason)){
230 $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
231 }else{
232 $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),msgPool::featuresEnabled(_("Mail")));
233 }
234 } else {
235 $reason = "";
236 if(!$this->mailMethod->accountCreateable($reason)){
237 $display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
238 }else{
239 $display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),msgPool::featuresDisabled(_("Mail")));
240 }
241 return ($display);
242 }
243 }
244 }
246 /****************
247 Sieve Management Dialog
248 ****************/
249 if($this->mailMethod->allowSieveManagement()){
250 if(isset($_POST['sieveManagement'])
251 && preg_match("/C/",$this->gosaMailDeliveryMode)
252 && $this->acl_is_writeable("sieveManagement")
253 && $this->mailMethod->allowSieveManagement()) {
254 $this->dialog = $this->sieve_management;
255 }
256 if(isset($_POST['sieve_cancel'])){
257 $this->dialog = FALSE;
258 }
259 if(isset($_POST['sieve_finish'])){
260 $this->sieve_management = $this->dialog;
261 $this->dialog = FALSE;
262 }
263 if(is_object($this->dialog)){
264 $this->dialog->save_object();
265 return($this->dialog->execute());
266 }
267 }
269 /****************
270 Forward addresses
271 ****************/
272 if (isset($_POST['add_local_forwarder'])){
273 $this->forward_dialog= TRUE;
274 $this->dialog= TRUE;
275 }
276 if (isset($_POST['add_locals_cancel'])){
277 $this->forward_dialog= FALSE;
278 $this->dialog= FALSE;
279 }
280 if (isset($_POST['add_locals_finish'])){
281 if (isset($_POST['local_list'])){
282 if($this->acl_is_writeable("gosaMailForwardingAddress")){
283 foreach ($_POST['local_list'] as $val){
284 if (!in_array ($val, $this->gosaMailAlternateAddress) &&
285 $val != $this->mail){
286 $this->addForwarder($val);
287 $this->is_modified= TRUE;
288 }
289 }
290 }
291 $this->forward_dialog= FALSE;
292 $this->dialog= FALSE;
293 } else {
294 msg_dialog::display(_("Error"), _("Please select an entry!"), ERROR_DIALOG);
295 }
296 }
297 if (isset($_POST['add_forwarder'])){
298 if ($_POST['forward_address'] != ""){
299 $address= $_POST['forward_address'];
300 $valid= FALSE;
301 if (!tests::is_email($address)){
302 if (!tests::is_email($address, TRUE)){
303 if ($this->is_template){
304 $valid= TRUE;
305 } else {
306 msg_dialog::display(_("Error"), msgPool::invalid(_("Mail address"),
307 "","","your-address@your-domain.com"),ERROR_DIALOG);
308 }
309 }
310 } elseif ($address == $this->mail
311 || in_array($address, $this->gosaMailAlternateAddress)) {
312 msg_dialog::display(_("Error"),_("Cannot add primary address to the list of forwarders!") , ERROR_DIALOG);
313 } else {
314 $valid= TRUE;
315 }
316 if ($valid){
317 if($this->acl_is_writeable("gosaMailForwardingAddress")){
318 $this->addForwarder ($address);
319 $this->is_modified= TRUE;
320 }
321 }
322 }
323 }
324 if (isset($_POST['delete_forwarder'])){
325 $this->delForwarder ($_POST['forwarder_list']);
326 }
327 if ($this->forward_dialog){
328 return($this->display_forward_dialog());
329 }
332 /****************
333 Alternate addresses
334 ****************/
336 if (isset($_POST['add_alternate'])){
337 $valid= FALSE;
338 if (!tests::is_email($_POST['alternate_address'])){
339 if ($this->is_template){
340 if (!(tests::is_email($_POST['alternate_address'], TRUE))){
341 msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"),"","","your-domain@your-domain.com"),ERROR_DIALOG);
342 } else {
343 $valid= TRUE;
344 }
345 } else {
346 msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"),"","","your-domain@your-domain.com"),ERROR_DIALOG);
347 }
348 } else {
349 $valid= TRUE;
350 }
351 if ($valid && ($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
352 $ui= get_userinfo();
353 if ($user != $ui->username){
354 msg_dialog::display(_("Error"), msgPool::duplicated(_("Mail address"))." ".
355 sprintf(_("Address is already in use by user '%s'."), $user), ERROR_DIALOG);
356 }
357 }
358 }
359 if (isset($_POST['delete_alternate']) && isset($_POST['alternates_list'])){
360 $this->delAlternate ($_POST['alternates_list']);
361 }
363 /****************
364 SMARTY- Assign smarty variables
365 ****************/
366 $smarty = get_smarty();
367 $smarty->assign("initially_was_account", $this->initially_was_account);
368 $smarty->assign("isModifyableMail" , $this->mailMethod->isModifyableMail());
369 $smarty->assign("isModifyableServer", $this->mailMethod->isModifyableServer());
370 $smarty->assign("mailEqualsCN", $this->mailMethod->mailEqualsCN());
372 $SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
373 $tmp = $this->plInfo();
374 foreach($tmp['plProvidedAcls'] as $name => $transl){
375 $smarty->assign("$name"."ACL", $this->getacl($name,$SkipWrite));
376 }
377 foreach($this->attributes as $attr){
378 $smarty->assign($attr,$this->$attr);
379 }
380 $smarty->assign("quotaEnabled", $this->mailMethod->quotaEnabled());
381 if($this->mailMethod->is_connected()){
382 $smarty->assign("quotaUsage", $this->mailMethod->getQuotaUsage());
383 }else{
384 $smarty->assign("quotaUsage", _("Unknown"));
385 }
386 $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
387 $smarty->assign("domainSelectionEnabled", $this->mailMethod->domainSelectionEnabled());
388 $smarty->assign("MailDomains", $this->mailDomainParts);
389 $smarty->assign("MailDomain" , $this->mailDomainPart);
390 $smarty->assign("MailServers", $this->mailMethod->getMailServers());
391 $smarty->assign("allowSieveManagement", $this->mailMethod->allowSieveManagement());
392 $smarty->assign("own_script", $this->sieveManagementUsed);
394 print_a($this->multi_boxes);
396 /* _Multiple users vars_ */
397 foreach($this->attributes as $attr){
398 $u_attr = "use_".$attr;
399 $smarty->assign($u_attr,in_array($attr,$this->multi_boxes));
400 }
401 foreach(array("only_local","gosaMailForwardingAddress","use_mailsize_limit","drop_own_mails","use_vacation","use_spam_filter") as $attr){
402 $u_attr = "use_".$attr;
403 $smarty->assign($u_attr,in_array($attr,$this->multi_boxes));
404 }
407 /****************
408 SMARTY- Assign flags
409 ****************/
411 $types = array(
412 "V"=>"use_vacation",
413 "S"=>"use_spam_filter",
414 "R"=>"use_mailsize_limit",
415 "I"=>"drop_own_mails",
416 "C"=>"own_script");
417 foreach($types as $option => $varname){
418 if (preg_match("/".$option."/", $this->gosaMailDeliveryMode)) {
419 $smarty->assign($varname, "checked");
420 } else {
421 $smarty->assign($varname, "");
422 }
423 }
424 if (!preg_match("/L/", $this->gosaMailDeliveryMode)) {
425 $smarty->assign("only_local", "checked");
426 } else {
427 $smarty->assign("only_local", "");
428 }
431 /****************
432 Smarty- Vacation settings
433 ****************/
434 $smarty->assign("rangeEnabled", FALSE);
435 $smarty->assign("template", "");
436 if (count($this->vacationTemplates)){
437 $smarty->assign("show_templates", "true");
438 $smarty->assign("vacationtemplates", $this->vacationTemplates);
439 if (isset($_POST['vacation_template'])){
440 $smarty->assign("template", $_POST['vacation_template']);
441 }
442 } else {
443 $smarty->assign("show_templates", "false");
444 }
446 /* Vacation range assigments
447 */
448 if($this->mailMethod->vacationRangeEnabled()){
449 $smarty->assign("rangeEnabled", TRUE);
450 if($this->gosaVacationStop ==0){
451 $date= getdate(time());
452 $date["mday"]++;
453 }else{
454 $date= getdate($this->gosaVacationStop);
455 }
456 $smarty->assign("end_day", $date["mday"]);
457 $smarty->assign("end_month", $date["mon"]-1);
458 $smarty->assign("end_year", $date["year"]);
460 if($this->gosaVacationStart == 0){
461 $date= getdate(time());
462 }else{
463 $date= getdate($this->gosaVacationStart);
464 }
465 $smarty->assign("start_day", $date["mday"]);
466 $smarty->assign("start_month", $date["mon"]-1);
467 $smarty->assign("start_year", $date["year"]);
468 $days= array();
469 for($d= 1; $d<32; $d++){
470 $days[$d]= $d;
471 }
472 $years= array();
473 for($y= $date['year']-10; $y<$date['year']+10; $y++){
474 $years[]= $y;
475 }
476 $months= msgPool::months();
477 $smarty->assign("months", $months);
478 $smarty->assign("years", $years);
479 $smarty->assign("days", $days);
481 }
483 /* fill filter settings
484 */
485 $smarty->assign("spamlevel", $this->SpamLevels);
486 $smarty->assign("spambox" , $this->MailBoxes);
488 $smarty->assign("multiple_support",$this->multiple_support_active);
489 return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
490 }
494 /* Save data to object */
495 function save_object()
496 {
497 if (isset($_POST['mailTab'])){
499 /* Save ldap attributes */
500 $mail = $this->mail;
501 $server = $this->gosaMailServer;
502 plugin::save_object();
504 if(!$this->mailMethod->isModifyableServer() && $this->initially_was_account)){
505 $this->gosaMailServer = $server;
506 }
508 if(!$this->mailMethod->isModifyableMail() && $this->initially_was_account){
509 $this->mail = $mail;
510 }else{
512 /* Get posted mail domain part, if necessary
513 */
514 if($this->mailMethod->domainSelectionEnabled() && isset($_POST['MailDomain'])){
515 if(in_array(get_post('MailDomain'), $this->mailDomainParts)){
516 $this->mailDomainPart = get_post('MailDomain');
517 }
518 }
519 }
521 /* Import vacation message?
522 */
523 if (isset($_POST["import_vacation"]) && isset($this->vacationTemplates[$_POST["vacation_template"]])){
524 if($this->multiple_support_active){
525 $contents = ltrim(preg_replace("/^DESC:.*$/m","",file_get_contents($_POST["vacation_template"])));
526 }else{
527 $contents = $this->prepare_vacation_template(file_get_contents($_POST["vacation_template"]));
528 }
529 $this->gosaVacationMessage= htmlspecialchars($contents);
530 }
532 /* Handle flags
533 */
534 if(isset($_POST['own_script'])){
535 if(!preg_match("/C/",$this->gosaMailDeliveryMode)){
536 $str= preg_replace("/[\[\]]/","",$this->gosaMailDeliveryMode);
537 $this->gosaMailDeliveryMode = "[".$str."C]";
538 }
539 }else{
541 /* Assemble mail delivery mode
542 The mode field in ldap consists of values between braces, this must
543 be called when 'mail' is set, because checkboxes may not be set when
544 we're in some other dialog.
546 Example for gosaMailDeliveryMode [LR ]
547 L - Local delivery
548 R - Reject when exceeding mailsize limit
549 S - Use spam filter
550 V - Use vacation message
551 C - Use custm sieve script
552 I - Only insider delivery */
554 $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
557 /* Handle delivery flags */
558 if($this->acl_is_writeable("gosaMailDeliveryModeL")){
559 if(!preg_match("/L/",$tmp) && !isset($_POST['only_local'])){
560 $tmp.="L";
561 }elseif(preg_match("/L/",$tmp) && isset($_POST['only_local'])){
562 $tmp = preg_replace("/L/","",$tmp);
563 }
564 }
565 $opts = array(
566 "R" => "use_mailsize_limit",
567 "S" => "use_spam_filter",
568 "V" => "use_vacation",
569 "C" => "own_script",
570 "I" => "drop_own_mails");
572 foreach($opts as $flag => $post){
573 if($this->acl_is_writeable("gosaMailDeliveryMode".$flag)){
574 if(!preg_match("/".$flag."/",$tmp) && isset($_POST[$post])){
575 $tmp.= $flag;
576 }elseif(preg_match("/".$flag."/",$tmp) && !isset($_POST[$post])){
577 $tmp = preg_replace("/".$flag."/","",$tmp);
578 }
579 }
580 }
582 $tmp= "[$tmp]";
583 if ($this->gosaMailDeliveryMode != $tmp){
584 $this->is_modified= TRUE;
585 }
586 $this->gosaMailDeliveryMode= $tmp;
587 if($this->mailMethod->vacationRangeEnabled()){
588 if($this->acl_is_writeable("gosaVacationMessage") && preg_match("/V/",$this->gosaMailDeliveryMode)){
589 if(isset($_POST['gosaVacationStart'])){
590 $this->gosaVacationStart = $_POST['gosaVacationStart'];
591 }
592 if(isset($_POST['gosaVacationStop'])){
593 $this->gosaVacationStop = $_POST['gosaVacationStop'];
594 }
595 }
596 }
597 }
598 }
599 }
602 /*! \brief Parse vacation templates and build up an array
603 containing 'filename' => 'description'.
604 Used to fill vacation dropdown box.
605 @return Array All useable vacation templates.
606 */
607 function get_vacation_templates()
608 {
609 $vct = array();
610 if ($this->config->get_cfg_value("vacationTemplateDirectory") != ""){
611 $dir= $this->config->get_cfg_value("vacationTemplateDirectory");
612 if (is_dir($dir) && is_readable($dir)){
613 $dh = opendir($dir);
614 while($file = readdir($dh)){
615 $description= "";
616 if (is_file($dir."/".$file)){
617 $fh = fopen($dir."/".$file, "r");
618 $line= fgets($fh, 256);
619 if (!preg_match('/^DESC:/', $line)){
620 msg_dialog::display(_("Configuration error"), sprintf(_("No DESC tag in vacation template '%s'!"), $file), ERROR_DIALOG);
621 }else{
622 $description= trim(preg_replace('/^DESC:\s*/', '', $line));
623 }
624 fclose ($fh);
625 }
626 if ($description != ""){
627 $vct["$dir/$file"]= $description;
628 }
629 }
630 closedir($dh);
631 }
632 }
633 return($vct);
634 }
637 /*! \brief Adds the given mail address to the list of mail forwarders
638 */
639 function addForwarder($address)
640 {
641 if(empty($address)) return;
642 if($this->acl_is_writeable("gosaMailForwardingAddress")){
643 $this->gosaMailForwardingAddress[]= $address;
644 $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress);
645 sort ($this->gosaMailForwardingAddress);
646 reset ($this->gosaMailForwardingAddress);
647 $this->is_modified= TRUE;
648 }else{
649 msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
650 }
651 }
654 /*! \brief Removes the given mail address from the list of mail forwarders
655 */
656 function delForwarder($addresses)
657 {
658 if($this->acl_is_writeable("gosaMailForwardingAddress")){
659 $this->gosaMailForwardingAddress= array_remove_entries ($addresses, $this->gosaMailForwardingAddress);
660 $this->is_modified= TRUE;
661 }else{
662 msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
663 }
664 }
667 /*! \brief Add given mail address to the list of alternate adresses ,
668 . check if this mal address is used, skip adding in this case
669 */
670 function addAlternate($address)
671 {
672 if(empty($address)) return;
673 if($this->acl_is_writeable("gosaMailAlternateAddress")){
674 $ldap= $this->config->get_ldap_link();
675 $address= strtolower($address);
677 /* Is this address already assigned in LDAP? */
678 $ldap->cd ($this->config->current['BASE']);
679 $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)".
680 "(alias=$address)(gosaMailAlternateAddress=$address)))", array("uid"));
681 if ($ldap->count() > 0){
682 $attrs= $ldap->fetch ();
683 return ($attrs["uid"][0]);
684 }
685 if (!in_array($address, $this->gosaMailAlternateAddress)){
686 $this->gosaMailAlternateAddress[]= $address;
687 $this->is_modified= TRUE;
688 }
689 sort ($this->gosaMailAlternateAddress);
690 reset ($this->gosaMailAlternateAddress);
691 return ("");
692 }else{
693 msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
694 }
695 }
698 /*! \brief Removes the given mail address from the alternate addresses list
699 */
700 function delAlternate($addresses)
701 {
702 if($this->acl_is_writeable("gosaMailAlternateAddress")){
703 $this->gosaMailAlternateAddress= array_remove_entries ($addresses,$this->gosaMailAlternateAddress);
704 $this->is_modified= TRUE;
705 }else{
706 msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
707 }
708 }
711 /*! \brief Prepare importet vacation string. \
712 . Replace placeholder like %givenName a.s.o.
713 @param string Vacation string
714 @return string Completed vacation string
715 */
716 private function prepare_vacation_template($contents)
717 {
718 /* Replace attributes */
719 $attrs = array();
720 $obj = NULL;
721 if(isset($this->parent->by_object['user'])){
722 $attrs = $this->parent->by_object['user']->attributes;
723 $obj = $this->parent->by_object['user'];
724 }else{
725 $obj = new user($this->config,$this->dn);
726 $attrs = $obj->attributes;
727 }
728 if($obj){
729 foreach ($attrs as $val){
730 if(preg_match("/dateOfBirth/",$val)){
731 if($obj->use_dob){
732 $contents= preg_replace("/%$val/",date("Y-d-m",$obj->dateOfBirth),$contents);
733 }
734 }else {
735 $contents= preg_replace("/%$val/",
736 $obj->$val, $contents);
737 }
739 /* Replace vacation start and end time */
740 if(preg_match("/%start/",$contents)){
741 $contents = preg_replace("/%start/",date("d.m.Y",$this->gosaVacationStart),$contents);
742 }
743 if(preg_match("/%end/",$contents)){
744 $contents = preg_replace("/%end/",date("d.m.Y",$this->gosaVacationStop),$contents);
745 }
746 }
747 }
748 $contents = ltrim(preg_replace("/^DESC:.*$/m","",$contents),"\n ");
749 return($contents);
750 }
753 /*! \brief Displays a dialog that allows mail address selection.
754 */
755 function display_forward_dialog()
756 {
757 restore_error_handler();
759 $smarty = get_smarty();
760 $ldap= $this->config->get_ldap_link();
762 /* Save data */
763 $mailfilter= session::get("mailfilter");
764 foreach( array("depselect", "muser", "regex") as $type){
765 if (isset($_POST[$type])){
766 $mailfilter[$type]= $_POST[$type];
767 }
768 }
769 if (isset($_GET['search'])){
770 $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
771 if ($s == "**"){
772 $s= "*";
773 }
774 $mailfilter['regex']= $s;
775 }
776 session::set("mailfilter", $mailfilter);
778 /* Get actual list */
779 $mailusers= array ();
780 if ($mailfilter['regex'] != '*' && $mailfilter['regex'] != ""){
781 $regex= $mailfilter['regex'];
782 $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))";
783 } else {
784 $filter= "";
785 }
786 if ($mailfilter['muser'] != ""){
787 $user= $mailfilter['muser'];
788 $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))";
789 }
791 /* Add already present people to the filter */
792 $exclude= "";
793 foreach ($this->gosaMailForwardingAddress as $mail){
794 $exclude.= "(mail=$mail)";
795 }
796 if ($exclude != ""){
797 $filter.= "(!(|$exclude))";
798 }
799 $res= get_list("(&(objectClass=gosaMailAccount)$filter)", "users", $mailfilter['depselect'],
800 array("sn", "mail", "givenName"), GL_SIZELIMIT | GL_SUBSEARCH);
801 $ldap->cd($mailfilter['depselect']);
802 $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName"));
803 while ($attrs= $ldap->fetch()){
804 if(preg_match('/%/', $attrs['mail'][0])){
805 continue;
806 }
807 $name= $this->make_name($attrs);
808 $mailusers[$attrs['mail'][0]]= $name."<".
809 $attrs['mail'][0].">";
810 }
811 natcasesort ($mailusers);
812 reset ($mailusers);
814 /* Show dialog */
815 $smarty->assign("search_image", get_template_path('images/lists/search.png'));
816 $smarty->assign("usearch_image", get_template_path('images/lists/search-user.png'));
817 $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
818 $smarty->assign("infoimage", get_template_path('images/info.png'));
819 $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
820 $smarty->assign("mailusers", $mailusers);
821 if (isset($_POST['depselect'])){
822 $smarty->assign("depselect", $_POST['depselect']);
823 }
824 $smarty->assign("deplist", $this->config->idepartments);
825 $smarty->assign("apply", apply_filter());
826 $smarty->assign("alphabet", generate_alphabet());
827 $smarty->assign("hint", print_sizelimit_warning());
828 foreach( array("depselect", "muser", "regex") as $type){
829 $smarty->assign("$type", $mailfilter[$type]);
830 }
831 $smarty->assign("hint", print_sizelimit_warning());
832 $display= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE, dirname(__FILE__)));
833 return ($display);
834 }
837 /*! \brief Removes the mailAccount extension from ldap
838 */
839 function remove_from_parent()
840 {
841 /* Cancel if there's nothing to do here */
842 if (!$this->initially_was_account){
843 return;
844 }
846 /* If domain part was selectable, contruct mail address */
847 if($this->mailMethod->domainSelectionEnabled()){
848 $this->mail = $this->mail."@".$this->mailDomainPart;
849 }
851 /* Update sharedFolder dependencies.
852 Open each shared folder and remove this account.
853 Then Save the group to ensure that all necessary
854 actions will be taken (imap acls updated aso.).
855 */
856 $ldap = $this->config->get_ldap_link();
857 $ldap->cd($this->config->current['BASE']);
858 $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$this->uid."))",array("dn"));
859 while($attrs = $ldap->fetch()){
860 $grp = new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $attrs['dn']);
861 if(isset($grp->by_object['mailgroup']) && isset($grp->by_object['group'])){
862 $grp->by_object['group']->removeUser($this->uid);
864 /* Do not save the complete group! This will quit the complete membership
865 */
866 $grp->by_object['mailgroup']->save();
867 }
868 }
870 /* Remove GOsa attributes */
871 plugin::remove_from_parent();
873 /* Zero arrays */
874 $this->attrs['gosaMailAlternateAddress'] = array();
875 $this->attrs['gosaMailForwardingAddress']= array();
878 $this->mailMethod->fixAttributesOnRemove();
879 $this->cleanup();
881 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save");
882 $ldap= $this->config->get_ldap_link();
883 $ldap->cd($this->dn);
884 $ldap->modify ($this->attrs);
886 /* Add "view" to logging class */
887 new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
888 if (!$ldap->success()){
889 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
890 }
892 /* Let the mailMethod remove this mailbox, e.g. from imap and
893 update shared folder membership, ACL may need to be updated.
894 */
895 if (!$this->is_template){
897 if(!$this->mailMethod->connect()){
898 msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
899 $this->mailMethod->get_error()), ERROR_DIALOG);
900 }else{
901 if(!$this->mailMethod->deleteMailbox()){
902 msg_dialog::display(_("Mail error"), sprintf(_("Cannot remove mailbox! Error was: %s."),
903 $this->mailMethod->get_error()), ERROR_DIALOG);
904 }
905 }
906 }
907 $this->mailMethod->disconnect();
909 /* Optionally execute a command after we're done */
910 $this->handle_post_events("remove",array("uid" => $this->uid));
911 }
914 /*! \brief Save the mailAccount settings to the ldap database.
915 */
916 function save()
917 {
918 $ldap= $this->config->get_ldap_link();
920 /* If domain part was selectable, contruct mail address */
921 if(!(!$this->mailMethod->isModifyableMail() && $this->initially_was_account)){
923 if($this->mailMethod->domainSelectionEnabled()){
924 $this->mail = $this->mail."@".$this->mailDomainPart;
925 }
927 /* Enforce lowercase mail address and trim whitespaces
928 */
929 $this->mail = trim(strtolower($this->mail));
930 }
933 /* Call parents save to prepare $this->attrs */
934 plugin::save();
936 /* Save arrays */
937 $this->attrs['gosaMailAlternateAddress'] = $this->gosaMailAlternateAddress;
938 $this->attrs['gosaMailForwardingAddress']= $this->gosaMailForwardingAddress;
940 if(!$this->mailMethod->vacationRangeEnabled()){
941 $this->attrs['gosaVacationStart'] = $this->attrs['gosaVacationStop'] = array();
942 }elseif (!preg_match('/V/', $this->gosaMailDeliveryMode)){
943 unset($this->attrs['gosaVacationStart']);
944 unset($this->attrs['gosaVacationStop']);
945 }
947 /* Map method attributes */
948 $this->mailMethod->fixAttributesOnStore();
950 /* Save data to LDAP */
951 $ldap->cd($this->dn);
952 $this->cleanup();
953 $ldap->modify ($this->attrs);
955 if (!$ldap->success()){
956 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
957 }
959 /* Log last action */
960 if($this->initially_was_account){
961 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
962 }else{
963 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
964 }
966 /* Only do IMAP actions if we are not a template */
967 if (!$this->is_template){
968 $this->mailMethod->connect();
969 if(!$this->mailMethod->is_connected()){
970 msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
971 $this->mailMethod->get_error()), ERROR_DIALOG);
972 }else{
973 if(!$this->mailMethod->updateMailbox()){
974 msg_dialog::display(_("Mail error"), sprintf(_("Cannot update mailbox! Error was: %s."),
975 $this->mailMethod->get_error()), ERROR_DIALOG);
976 }
977 if(!$this->mailMethod->setQuota($this->gosaMailQuota)){
978 msg_dialog::display(_("Mail error"), sprintf(_("Cannot write quota settings! Error was: %s."),
979 $this->mailMethod->get_error()), ERROR_DIALOG);
980 }
982 if (!is_integer(strpos($this->gosaMailDeliveryMode, "C"))){
984 /* Do not write sieve settings if this account is new and
985 doesn't seem to exist.
986 */
987 if(!$this->initially_was_account && !$this->mailMethod->account_exists()){
988 @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,
989 "Skipping sieve settings, the account doesn't seem to be created already.</b>","");
990 }else{
991 if(!$this->mailMethod->saveSieveSettings()){
992 msg_dialog::display(_("Mail error"), $this->mailMethod->get_error(), ERROR_DIALOG);
993 }
994 }
995 }else{
996 echo "Check sieve management here";
997 @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,
998 "User uses an own sieve script, skipping sieve update.".$str."</b>","");
999 }
1000 }
1001 }
1002 $this->mailMethod->disconnect();
1004 /* Update sharedFolder dependencies.
1005 Open each shared folder and remove this account.
1006 Then Save the group to ensure that all necessary
1007 actions will be taken (imap acls updated aso.).
1008 */
1009 if(!$this->initially_was_account){
1010 $ldap = $this->config->get_ldap_link();
1011 $ldap->cd($this->config->current['BASE']);
1012 $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$this->uid."))",array("dn"));
1013 while($attrs = $ldap->fetch()){
1014 $grp = new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $attrs['dn']);
1015 if(isset($grp->by_object['mailgroup'])){
1016 /* Do not save the complete group! This will quit the complete membership
1017 */
1018 $grp->by_object['mailgroup']->save();
1019 }
1020 }
1021 }
1023 /* Optionally execute a command after we're done */
1024 if ($this->initially_was_account == $this->is_account){
1025 if ($this->is_modified){
1026 $this->handle_post_events("modify", array("uid" => $this->uid));
1027 }
1028 } else {
1029 $this->handle_post_events("add", array("uid" => $this->uid));
1030 }
1031 }
1034 /*! \brief Check given values
1035 */
1036 function check()
1037 {
1038 if(!$this->is_account){
1039 return(array());
1040 }
1042 $ldap= $this->config->get_ldap_link();
1044 /* Call common method to give check the hook */
1045 $message= plugin::check();
1047 if(empty($this->gosaMailServer)){
1048 $message[]= msgPool::noserver(_("Mail"));
1049 }
1051 /* Mail address checks */
1052 $mail = $this->mail;
1053 if(!(!$this->mailMethod->isModifyableMail() && $this->initially_was_account)){
1055 if($this->mailMethod->domainSelectionEnabled()){
1056 $mail.= "@".$this->mailDomainPart;
1057 }
1059 if (empty($mail)){
1060 $message[]= msgPool::required(_("Primary address"));
1061 }
1062 if ($this->is_template){
1063 if (!tests::is_email($mail, TRUE)){
1064 $message[]= msgPool::invalid(_("Mail address"),"","","%givenName.%sn@your-domain.com");
1065 }
1066 } else {
1067 if (!tests::is_email($mail)){
1068 $message[]= msgPool::invalid(_("Mail address"),"","","your-address@your-domain.com");
1069 }
1070 }
1072 /* Check if this mail address is already in use */
1073 $ldap->cd($this->config->current['BASE']);
1074 $filter = "(&(!(objectClass=gosaUserTemplate))(!(uid=".$this->uid."))".
1075 "(objectClass=gosaMailAccount)".
1076 "(|(mail=".$mail.")(alias=".$mail.")(gosaMailAlternateAddress=".$mail.")))";
1077 $ldap->search($filter,array("uid"));
1078 if ($ldap->count() != 0){
1079 $message[]= msgPool::duplicated(_("Mail address"));
1080 }
1081 }
1084 /* Check quota */
1085 if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){
1086 if (!is_numeric($this->gosaMailQuota)) {
1087 $message[]= msgPool::invalid(_("Quota size"),$this->gosaMailQuota,"/^[0-9]*/");
1088 } else {
1089 $this->gosaMailQuota= (int) $this->gosaMailQuota;
1090 }
1091 }
1093 /* Check rejectsize for integer */
1094 if ($this->gosaMailMaxSize != '' && $this->acl_is_writeable("gosaMailMaxSize")){
1095 if (!is_numeric($this->gosaMailMaxSize)){
1096 $message[]= msgPool::invalid(_("Mail reject size"),$this->gosaMailMaxSize,"/^[0-9]*/");
1097 } else {
1098 $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize;
1099 }
1100 }
1102 /* Need gosaMailMaxSize if use_mailsize_limit is checked */
1103 if (is_integer(strpos($this->gosaMailDeliveryMode, "R")) && $this->gosaMailMaxSize == ""){
1104 $message[]= msgPool::required(_("Mail reject size"));
1105 }
1107 if((preg_match("/S/", $this->gosaMailDeliveryMode))&&(empty($this->gosaSpamMailbox))) {
1108 $message[]= msgPool::required(_("Spam folder"));
1109 }
1111 if ($this->mailMethod->vacationRangeEnabled()
1112 && preg_match('/V/', $this->gosaMailDeliveryMode)
1113 && $this->gosaVacationStart > $this->gosaVacationStop){
1114 $message[]= msgPool::invalid(_("Vacation interval"));
1115 }
1116 return($message);
1117 }
1120 /*! \brief Adapt from template, using 'dn'
1121 */
1122 function adapt_from_template($dn, $skip= array())
1123 {
1124 plugin::adapt_from_template($dn, $skip);
1126 foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
1128 if (in_array($val, $skip)){
1129 continue;
1130 }
1132 $this->$val= array();
1133 if (isset($this->attrs["$val"]["count"])){
1134 for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
1135 $value= $this->attrs["$val"][$i];
1136 foreach (array("sn", "givenName", "uid") as $repl){
1137 if (preg_match("/%$repl/i", $value)){
1138 $value= preg_replace ("/%$repl/i", $this->parent->$repl, $value);
1139 }
1140 }
1141 array_push($this->$val, strtolower(rewrite($value)));
1142 }
1143 }
1144 }
1145 $this->mail= strtolower(rewrite($this->mail));
1146 }
1149 /*! \brief Creates the mail part for the copy & paste dialog
1150 */
1151 function getCopyDialog()
1152 {
1153 if(!$this->is_account) return("");
1154 $smarty = get_smarty();
1155 $smarty->assign("mail",$this->mail);
1156 $smarty->assign("gosaMailAlternateAddress",$this->gosaMailAlternateAddress);
1157 $smarty->assign("gosaMailForwardingAddress",$this->gosaMailForwardingAddress);
1158 $str = $smarty->fetch(get_template_path("copypaste.tpl",TRUE, dirname(__FILE__)));
1160 $ret = array();
1161 $ret['status'] = "";
1162 $ret['string'] = $str;
1163 return($ret);
1164 }
1167 /*! \brief save_object for copy&paste vars
1168 */
1169 function saveCopyDialog()
1170 {
1171 if(!$this->is_account) return;
1173 /* Execute to save mailAlternateAddress && gosaMailForwardingAddress */
1174 $this->execute();
1175 if(isset($_POST['mail'])){
1176 $this->mail = $_POST['mail'];
1177 }
1178 }
1181 /*! \brief Prepare this account to be copied
1182 */
1183 function PrepareForCopyPaste($source)
1184 {
1185 plugin::PrepareForCopyPaste($source);
1187 /* Reset alternate mail addresses */
1188 $this->gosaMailAlternateAddress = array();
1189 }
1192 /*! \brief Prepare this class the be useable when editing multiple users at once
1193 */
1194 function get_multi_edit_values()
1195 {
1196 $ret = plugin::get_multi_edit_values();
1197 if(in_array("gosaMailQuota",$this->multi_boxes)){
1198 $ret['gosaMailQuota'] = $this->gosaMailQuota;
1199 }
1200 $flag_add = $flag_remove = array();
1201 $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
1202 $opts = array(
1203 "R" => "use_mailsize_limit",
1204 "S" => "use_spam_filter",
1205 "L" => "only_local",
1206 "V" => "use_vacation",
1207 "C" => "own_script",
1208 "I" => "drop_own_mails");
1209 foreach($opts as $flag => $post){
1210 if(in_array($post, $this->multi_boxes)){
1211 if(preg_match("/".$flag."/",$tmp)){
1212 $flag_add[] = $flag;
1213 }else{
1214 $flag_remove[] = $flag;
1215 }
1216 }
1217 }
1218 $ret['flag_add'] = $flag_add;
1219 $ret['flag_remove'] = $flag_remove;
1221 echo "1";
1222 if($this->mailMethod->vacationRangeEnabled()){
1223 echo "2";
1224 if(in_array("V",$flag_add)){
1225 $ret['gosaVacationStart'] = $this->gosaVacationStart = $_POST['gosaVacationStart'];
1226 $ret['gosaVacationStop'] = $this->gosaVacationStop = $_POST['gosaVacationStop'];
1227 }
1228 }
1229 return($ret);
1230 }
1233 /*! \brief Check given input for multiple user edit
1234 */
1235 function multiple_check()
1236 {
1237 $message = plugin::multiple_check();
1239 if(empty($this->gosaMailServer) && in_array("gosaMailServer",$this->multi_boxes)){
1240 $message[]= msgPool::noserver(_("Mail"));
1241 }
1243 /* Check quota */
1244 if ($this->gosaMailQuota != '' && in_array("gosaMailQuota",$this->multi_boxes)){
1245 if (!is_numeric($this->gosaMailQuota)) {
1246 $message[]= msgPool::invalid(_("Quota size"),$this->gosaMailQuota,"/^[0-9]*/");
1247 } else {
1248 $this->gosaMailQuota= (int) $this->gosaMailQuota;
1249 }
1250 }
1252 /* Check rejectsize for integer */
1253 if ($this->gosaMailMaxSize != '' && in_array("gosaMailMaxSize",$this->multi_boxes)){
1254 if (!is_numeric($this->gosaMailMaxSize)){
1255 $message[]= msgPool::invalid(_("Mail reject size"),$this->gosaMailMaxSize,"/^[0-9]*/");
1256 } else {
1257 $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize;
1258 }
1259 }
1261 if(empty($this->gosaSpamMailbox) && in_array("gosaSpamMailbox",$this->multi_boxes)){
1262 $message[]= msgPool::required(_("Spam folder"));
1263 }
1265 if ( in_array("use_vacation",$this->multi_boxes) &&
1266 preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){
1267 $message[]= msgPool::invalid(_("Vacation interval"));
1268 }
1269 return($message);
1270 }
1273 /*! \brief ...
1274 */
1275 function set_multi_edit_values($values)
1276 {
1277 plugin::set_multi_edit_values($values);
1278 $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
1279 if(isset($values['flag_add'])){
1280 foreach($values['flag_add'] as $flag){
1281 if(!preg_match("/".$flag."/",$tmp)){
1282 $tmp .= $flag;
1283 }
1284 }
1285 }
1286 if(isset($values['flag_remove'])){
1287 foreach($values['flag_remove'] as $flag){
1288 if(preg_match("/".$flag."/",$tmp)){
1289 $tmp = preg_replace("/".$flag."/","",$tmp);
1290 }
1291 }
1292 }
1293 $this->gosaMailDeliveryMode = "[".$tmp."]";
1295 /* Set vacation message and replace placeholder like %givenName
1296 */
1297 if(isset($values['gosaVacationMessage'])){
1298 $this->gosaVacationMessage = $this->prepare_vacation_template($values['gosaVacationMessage']);
1299 }
1300 }
1303 /*! \brief Initialize plugin to be used as multiple edit class.
1304 */
1305 function init_multiple_support($attrs,$all)
1306 {
1307 plugin::init_multiple_support($attrs,$all);
1308 if(isset($this->multi_attrs['gosaMailQuota'])){
1309 $this->gosaMailQuota = $this->multi_attrs['gosaMailQuota'];
1310 }
1311 }
1314 /*! \brief
1315 */
1316 function get_multi_init_values()
1317 {
1318 $attrs = plugin::get_multi_init_values();
1319 $attrs['gosaMailQuota'] = $this->gosaMailQuota;
1320 return($attrs);
1321 }
1324 /*! \brief Display multiple edit dialog
1325 */
1326 function multiple_execute()
1327 {
1328 return($this->execute());
1329 }
1332 /*! \brief Save posts from multiple edit dialog
1333 */
1334 function multiple_save_object()
1335 {
1336 plugin::multiple_save_object();
1338 $this->save_object();
1339 foreach(array("only_local","gosaMailForwardingAddress","use_mailsize_limit","drop_own_mails","use_vacation","use_spam_filter") as $attr){
1340 if(isset($_POST["use_".$attr])){
1341 $this->multi_boxes[] = $attr;
1342 }
1343 }
1344 }
1347 /*! \brief Creates the user names for the add_local_forward dialog
1348 */
1349 function make_name($attrs)
1350 {
1351 $name= "";
1352 if (isset($attrs['sn'][0])){
1353 $name= $attrs['sn'][0];
1354 }
1355 if (isset($attrs['givenName'][0])){
1356 if ($name != ""){
1357 $name.= ", ".$attrs['givenName'][0];
1358 } else {
1359 $name.= $attrs['givenName'][0];
1360 }
1361 }
1362 if ($name != ""){
1363 $name.= " ";
1364 }
1366 return ($name);
1367 }
1370 function allow_remove()
1371 {
1372 $resason = "";
1373 if(!$this->mailMethod->allow_remove($reason)){
1374 return($reason);
1375 }
1376 return("");
1377 }
1381 /*! \brief ACL settings
1382 */
1383 static function plInfo()
1384 {
1385 return (array(
1386 "plShortName" => _("Mail"),
1387 "plDescription" => _("Mail settings"),
1388 "plSelfModify" => TRUE,
1389 "plDepends" => array("user"), // This plugin depends on
1390 "plPriority" => 4, // Position in tabs
1391 "plSection" => array("personal" => _("My account")),
1392 "plCategory" => array("users"),
1393 "plOptions" => array(),
1395 "plProvidedAcls" => array(
1396 "mail" => _("Mail address"),
1397 "gosaMailServer" => _("Mail server"),
1398 "gosaMailQuota" => _("Quota size"),
1400 "gosaMailDeliveryModeV" => _("Add vacation information"), // This is flag of gosaMailDeliveryMode
1401 "gosaVacationMessage" => _("Vacation message"),
1403 "gosaMailDeliveryModeS" => _("Use spam filter"), // This is flag of gosaMailDeliveryMode
1404 "gosaSpamSortLevel" => _("Spam level"),
1405 "gosaSpamMailbox" => _("Spam mail box"),
1407 "sieveManagement" => _("Sieve management"),
1409 "gosaMailDeliveryModeR" => _("Reject due to mailsize"), // This is flag of gosaMailDeliveryMode
1410 "gosaMailMaxSize" => _("Mail max size"),
1412 "gosaMailForwardingAddress" => _("Forwarding address"),
1413 "gosaMailDeliveryModeL" => _("Local delivery"), // This is flag of gosaMailDeliveryMode
1414 "gosaMailDeliveryModeI" => _("No delivery to own mailbox "), // This is flag of gosaMailDeliveryMode
1415 "gosaMailAlternateAddress" => _("Mail alternative addresses"),
1417 "gosaMailForwardingAddress" => _("Forwarding address"),
1418 "gosaMailDeliveryModeC" => _("Use custom sieve script")) // This is flag of gosaMailDeliveryMode
1419 ));
1420 }
1423 }
1425 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1426 ?>