Code

Updated mailAccount, prevent user from changing their mail server or address settings
[gosa.git] / gosa-plugins / mail / personal / mail / class_mailAccount.inc
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         }
133         
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         }
140           
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->domainSelectionEnabled()){
152         $this->mailDomainPart = preg_replace("/^[^@]*+@/","",$this->mail);
153         $this->mail = preg_replace("/@.*$/","\\1",$this->mail);
154         if(!in_array($this->mailDomainPart,$this->mailDomainParts)){
155           $this->mailDomainParts[] = $this->mailDomainPart;
156         }
157       }
159       /* Load attributes containing arrays */
160       foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
161         $this->$val= array();
162         if (isset($this->attrs["$val"]["count"])){
163           for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
164             array_push($this->$val, $this->attrs["$val"][$i]);
165           }
166         }
167       }
168     }
170     /* Intialize sieveManagement if necessary */
171     if($this->mailMethod->allowSieveManagement()){
172       $this->mailboxList = &$this->MailBoxes;
173       $this->sieve_management = new sieveManagement($this->config,$this->dn,$this,$this->mailMethod->getUAttrib());
174     }
176     /* Get global filter config used in add local forward
177      */
178     if (!session::is_set("mailfilter")){
179       $ui= get_userinfo();
180       $base= get_base_from_people($ui->dn);
181       $mailfilter= array( "depselect"       => $base,
182           "muser"            => "",
183           "regex"           => "*");
184       session::set("mailfilter", $mailfilter);
185     }
187     /* Disconnect mailMethod. Connect on demand later. 
188      */
189     $this->mailMethod->disconnect();
190   }
193   function execute()
194   {
195     /* Call parent execute */
196     $display = plugin::execute();
198     /* Log view */
199     if($this->is_account && !$this->view_logged){
200       $this->view_logged = TRUE;
201       new log("view","users/".get_class($this),$this->dn);
202     }
205     /****************
206       Account status
207      ****************/
209     if(isset($_POST['modify_state'])){
210       if($this->is_account && $this->acl_is_removeable() && $this->mailMethod->accountRemoveAble()){
211         $this->is_account= FALSE;
212       }elseif(!$this->is_account && $this->acl_is_createable() && $this->mailMethod->accountCreateable()){
213         $this->is_account= TRUE;
214       }
215     }
216     if(!$this->multiple_support_active){
217       if (!$this->is_account && $this->parent === NULL){
218         $display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\">&nbsp;<b>".
219           msgPool::noValidExtension(_("Mail"))."</b>";
220         $display.= back_to_main();
221         return ($display);
222       }
223       if ($this->parent !== NULL){
224         if ($this->is_account){ 
225           $reason = "";
226           if(!$this->mailMethod->accountRemoveable($reason)){
227             $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
228           }else{
229             $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),msgPool::featuresEnabled(_("Mail")));
230           }
231         } else {
232           $reason = "";
233           if(!$this->mailMethod->accountCreateable($reason)){
234             $display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
235           }else{
236             $display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),msgPool::featuresDisabled(_("Mail")));
237           }
238           return ($display);
239         }
240       }
241     }
243     /****************
244       Sieve Management Dialog
245      ****************/
246     if($this->mailMethod->allowSieveManagement()){
247       if(isset($_POST['sieveManagement'])
248           && preg_match("/C/",$this->gosaMailDeliveryMode)
249           && $this->acl_is_writeable("sieveManagement") 
250           && $this->mailMethod->allowSieveManagement()) {
251         $this->dialog = $this->sieve_management;
252       }
253       if(isset($_POST['sieve_cancel'])){
254         $this->dialog = FALSE;
255       }
256       if(isset($_POST['sieve_finish'])){
257         $this->sieve_management = $this->dialog;
258         $this->dialog = FALSE;
259       }
260       if(is_object($this->dialog)){
261         $this->dialog->save_object();
262         return($this->dialog->execute());
263       }
264     }
266     /****************
267       Forward addresses 
268      ****************/
269     if (isset($_POST['add_local_forwarder'])){
270       $this->forward_dialog= TRUE;
271       $this->dialog= TRUE;
272     }
273     if (isset($_POST['add_locals_cancel'])){
274       $this->forward_dialog= FALSE;
275       $this->dialog= FALSE;
276     }
277     if (isset($_POST['add_locals_finish'])){
278       if (isset($_POST['local_list'])){
279         if($this->acl_is_writeable("gosaMailForwardingAddress")){
280           foreach ($_POST['local_list'] as $val){
281             if (!in_array ($val, $this->gosaMailAlternateAddress) &&
282                 $val != $this->mail){
283               $this->addForwarder($val);
284               $this->is_modified= TRUE;
285             }
286           }
287         }
288         $this->forward_dialog= FALSE;
289         $this->dialog= FALSE;
290       } else {
291         msg_dialog::display(_("Error"), _("Please select an entry!"), ERROR_DIALOG);
292       }
293     }
294     if (isset($_POST['add_forwarder'])){
295       if ($_POST['forward_address'] != ""){
296         $address= $_POST['forward_address'];
297         $valid= FALSE;
298         if (!tests::is_email($address)){
299           if (!tests::is_email($address, TRUE)){
300             if ($this->is_template){
301               $valid= TRUE;
302             } else {
303               msg_dialog::display(_("Error"), msgPool::invalid(_("Mail address"),
304                     "","","your-address@your-domain.com"),ERROR_DIALOG);
305             }
306           }
307         } elseif ($address == $this->mail
308             || in_array($address, $this->gosaMailAlternateAddress)) {
309           msg_dialog::display(_("Error"),_("Cannot add primary address to the list of forwarders!") , ERROR_DIALOG);
310         } else {
311           $valid= TRUE;
312         }
313         if ($valid){
314           if($this->acl_is_writeable("gosaMailForwardingAddress")){
315             $this->addForwarder ($address);
316             $this->is_modified= TRUE;
317           }
318         }
319       }
320     }
321     if (isset($_POST['delete_forwarder'])){
322       $this->delForwarder ($_POST['forwarder_list']);
323     }
324     if ($this->forward_dialog){
325       return($this->display_forward_dialog());
326     }
329     /****************
330       Alternate addresses 
331      ****************/
333     if (isset($_POST['add_alternate'])){
334       $valid= FALSE;
335       if (!tests::is_email($_POST['alternate_address'])){
336         if ($this->is_template){
337           if (!(tests::is_email($_POST['alternate_address'], TRUE))){
338             msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"),"","","your-domain@your-domain.com"),ERROR_DIALOG);
339           } else {
340             $valid= TRUE;
341           }
342         } else {
343           msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"),"","","your-domain@your-domain.com"),ERROR_DIALOG);
344         }
345       } else {
346         $valid= TRUE;
347       }
348       if ($valid && ($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
349         $ui= get_userinfo();
350         if ($user != $ui->username){
351           msg_dialog::display(_("Error"), msgPool::duplicated(_("Mail address"))."&nbsp;".
352               sprintf(_("Address is already in use by user '%s'."), $user), ERROR_DIALOG);
353         }
354       }
355     }
356     if (isset($_POST['delete_alternate']) && isset($_POST['alternates_list'])){
357       $this->delAlternate ($_POST['alternates_list']);
358     }
360     /****************
361       SMARTY- Assign smarty variables 
362      ****************/
363     $smarty = get_smarty();
364     $smarty->assign("initially_was_account", $this->initially_was_account);
365     $smarty->assign("isModifyableMail", $this->mailMethod->isModifyableMail());
366     $smarty->assign("mailEqualsCN", $this->mailMethod->mailEqualsCN());
368     $SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
369     $tmp  = $this->plInfo();
370     foreach($tmp['plProvidedAcls'] as $name => $transl){
371       $smarty->assign("$name"."ACL", $this->getacl($name,$SkipWrite));
372     }
373     foreach($this->attributes as $attr){
374       $smarty->assign($attr,$this->$attr);
375     }
376     $smarty->assign("quotaEnabled", $this->mailMethod->quotaEnabled());
377     if($this->mailMethod->is_connected()){
378       $smarty->assign("quotaUsage",   $this->mailMethod->getQuotaUsage());
379     }else{
380       $smarty->assign("quotaUsage",   _("Unknown"));
381     }
382     $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
383     $smarty->assign("domainSelectionEnabled", $this->mailMethod->domainSelectionEnabled());
384     $smarty->assign("MailDomains", $this->mailDomainParts);
385     $smarty->assign("MailDomain" , $this->mailDomainPart);
386     $smarty->assign("MailServers", $this->mailMethod->getMailServers());
387     $smarty->assign("allowSieveManagement", $this->mailMethod->allowSieveManagement());
388     $smarty->assign("own_script",  $this->sieveManagementUsed);
390     print_a($this->multi_boxes);
392     /* _Multiple users vars_ */
393     foreach($this->attributes as $attr){
394       $u_attr = "use_".$attr;
395       $smarty->assign($u_attr,in_array($attr,$this->multi_boxes));
396     }
397     foreach(array("only_local","gosaMailForwardingAddress","use_mailsize_limit","drop_own_mails","use_vacation","use_spam_filter") as $attr){
398       $u_attr = "use_".$attr;
399       $smarty->assign($u_attr,in_array($attr,$this->multi_boxes));
400     }
403     /****************
404       SMARTY- Assign flags 
405      ****************/
407     $types = array(
408         "V"=>"use_vacation",
409         "S"=>"use_spam_filter",
410         "R"=>"use_mailsize_limit",
411         "I"=>"drop_own_mails",
412         "C"=>"own_script");
413     foreach($types as $option => $varname){
414       if (preg_match("/".$option."/", $this->gosaMailDeliveryMode)) {
415         $smarty->assign($varname, "checked");
416       } else {
417         $smarty->assign($varname, "");
418       }
419     }
420     if (!preg_match("/L/", $this->gosaMailDeliveryMode)) {
421       $smarty->assign("only_local", "checked");
422     } else {
423       $smarty->assign("only_local", "");
424     }
427     /****************
428       Smarty- Vacation settings 
429      ****************/
430     $smarty->assign("rangeEnabled", FALSE);
431     $smarty->assign("template", "");
432     if (count($this->vacationTemplates)){
433       $smarty->assign("show_templates", "true");
434       $smarty->assign("vacationtemplates", $this->vacationTemplates);
435       if (isset($_POST['vacation_template'])){
436         $smarty->assign("template", $_POST['vacation_template']);
437       }
438     } else {
439       $smarty->assign("show_templates", "false");
440     }
442     /* Vacation range assigments
443      */
444     if($this->mailMethod->vacationRangeEnabled()){
445       $smarty->assign("rangeEnabled", TRUE);
446       if($this->gosaVacationStop ==0){
447         $date= getdate(time());
448         $date["mday"]++;
449       }else{
450         $date= getdate($this->gosaVacationStop);
451       }
452       $smarty->assign("end_day", $date["mday"]);
453       $smarty->assign("end_month", $date["mon"]-1);
454       $smarty->assign("end_year", $date["year"]);
456       if($this->gosaVacationStart == 0){
457         $date= getdate(time());
458       }else{
459         $date= getdate($this->gosaVacationStart);
460       }
461       $smarty->assign("start_day", $date["mday"]);
462       $smarty->assign("start_month", $date["mon"]-1);
463       $smarty->assign("start_year", $date["year"]);
464       $days= array();
465       for($d= 1; $d<32; $d++){
466         $days[$d]= $d;
467       }
468       $years= array();
469       for($y= $date['year']-10; $y<$date['year']+10; $y++){
470         $years[]= $y;
471       }
472       $months= msgPool::months();
473       $smarty->assign("months", $months);
474       $smarty->assign("years", $years);
475       $smarty->assign("days", $days);
477     }
479     /* fill filter settings 
480      */
481     $smarty->assign("spamlevel", $this->SpamLevels);
482     $smarty->assign("spambox"  , $this->MailBoxes);
484     $smarty->assign("multiple_support",$this->multiple_support_active);  
485     return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
486   }
490   /* Save data to object */
491   function save_object()
492   {
493     if (isset($_POST['mailTab'])){
495       /* Save ldap attributes */
496       plugin::save_object();
498       /* Get posted mail domain part, if necessary  
499        */
500       if($this->mailMethod->domainSelectionEnabled() && isset($_POST['MailDomain'])){
501         if(in_array(get_post('MailDomain'), $this->mailDomainParts)){
502           $this->mailDomainPart = get_post('MailDomain');
503         }
504       }
506       /* Import vacation message? 
507        */
508       if (isset($_POST["import_vacation"]) && isset($this->vacationTemplates[$_POST["vacation_template"]])){
509         if($this->multiple_support_active){
510           $contents = ltrim(preg_replace("/^DESC:.*$/m","",file_get_contents($_POST["vacation_template"])));
511         }else{
512           $contents = $this->prepare_vacation_template(file_get_contents($_POST["vacation_template"]));
513         }
514         $this->gosaVacationMessage= htmlspecialchars($contents);
515       }
517       /* Handle flags 
518        */
519       if(isset($_POST['own_script'])){
520         if(!preg_match("/C/",$this->gosaMailDeliveryMode)){
521           $str= preg_replace("/[\[\]]/","",$this->gosaMailDeliveryMode);
522           $this->gosaMailDeliveryMode = "[".$str."C]";
523         }
524       }else{
526         /* Assemble mail delivery mode
527            The mode field in ldap consists of values between braces, this must
528            be called when 'mail' is set, because checkboxes may not be set when
529            we're in some other dialog.
531            Example for gosaMailDeliveryMode [LR        ]
532            L -  Local delivery
533            R -  Reject when exceeding mailsize limit
534            S -  Use spam filter
535            V -  Use vacation message
536            C -  Use custm sieve script
537            I -  Only insider delivery */
539         $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
542         /* Handle delivery flags */
543         if($this->acl_is_writeable("gosaMailDeliveryModeL")){
544           if(!preg_match("/L/",$tmp) && !isset($_POST['only_local'])){
545             $tmp.="L";
546           }elseif(preg_match("/L/",$tmp) && isset($_POST['only_local'])){
547             $tmp = preg_replace("/L/","",$tmp);
548           }
549         }
550         $opts = array(
551             "R"   => "use_mailsize_limit",
552             "S"   => "use_spam_filter",
553             "V"   => "use_vacation",
554             "C"   => "own_script",
555             "I"   => "drop_own_mails");
557         foreach($opts as $flag => $post){
558           if($this->acl_is_writeable("gosaMailDeliveryMode".$flag)){
559             if(!preg_match("/".$flag."/",$tmp) && isset($_POST[$post])){
560               $tmp.= $flag;
561             }elseif(preg_match("/".$flag."/",$tmp) && !isset($_POST[$post])){
562               $tmp = preg_replace("/".$flag."/","",$tmp);
563             }
564           }
565         }
567         $tmp= "[$tmp]";
568         if ($this->gosaMailDeliveryMode != $tmp){
569           $this->is_modified= TRUE;
570         }
571         $this->gosaMailDeliveryMode= $tmp;
572         if($this->mailMethod->vacationRangeEnabled()){
573           if($this->acl_is_writeable("gosaVacationMessage") && preg_match("/V/",$this->gosaMailDeliveryMode)){
574             if(isset($_POST['gosaVacationStart'])){
575               $this->gosaVacationStart = $_POST['gosaVacationStart'];
576             }
577             if(isset($_POST['gosaVacationStop'])){
578               $this->gosaVacationStop = $_POST['gosaVacationStop'];
579             }
580           }
581         }
582       }
583     }
584   }
587   /*! \brief  Parse vacation templates and build up an array
588     containing 'filename' => 'description'. 
589     Used to fill vacation dropdown box.
590     @return Array   All useable vacation templates.
591    */ 
592   function get_vacation_templates()
593   {
594     $vct = array();
595     if ($this->config->get_cfg_value("vacationTemplateDirectory") != ""){
596       $dir= $this->config->get_cfg_value("vacationTemplateDirectory");
597       if (is_dir($dir) && is_readable($dir)){
598         $dh = opendir($dir);
599         while($file = readdir($dh)){
600           $description= "";
601           if (is_file($dir."/".$file)){
602             $fh = fopen($dir."/".$file, "r");
603             $line= fgets($fh, 256);
604             if (!preg_match('/^DESC:/', $line)){
605               msg_dialog::display(_("Configuration error"), sprintf(_("No DESC tag in vacation template '%s'!"), $file), ERROR_DIALOG);
606             }else{
607               $description= trim(preg_replace('/^DESC:\s*/', '', $line));
608             }
609             fclose ($fh);
610           }
611           if ($description != ""){
612             $vct["$dir/$file"]= $description;
613           }
614         }
615         closedir($dh);
616       }
617     }
618     return($vct); 
619   }
622   /*! \brief  Adds the given mail address to the list of mail forwarders 
623    */ 
624   function addForwarder($address)
625   {
626     if(empty($address)) return;
627     if($this->acl_is_writeable("gosaMailForwardingAddress")){
628       $this->gosaMailForwardingAddress[]= $address;
629       $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress);
630       sort ($this->gosaMailForwardingAddress);
631       reset ($this->gosaMailForwardingAddress);
632       $this->is_modified= TRUE;
633     }else{
634       msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
635     }
636   }
639   /*! \brief  Removes the given mail address from the list of mail forwarders 
640    */ 
641   function delForwarder($addresses)
642   {
643     if($this->acl_is_writeable("gosaMailForwardingAddress")){
644       $this->gosaMailForwardingAddress= array_remove_entries ($addresses, $this->gosaMailForwardingAddress);
645       $this->is_modified= TRUE;
646     }else{
647       msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
648     }
649   }
652   /*! \brief  Add given mail address to the list of alternate adresses ,
653     .          check if this mal address is used, skip adding in this case 
654    */ 
655   function addAlternate($address)
656   {
657     if(empty($address)) return;
658     if($this->acl_is_writeable("gosaMailAlternateAddress")){
659       $ldap= $this->config->get_ldap_link();
660       $address= strtolower($address);
662       /* Is this address already assigned in LDAP? */
663       $ldap->cd ($this->config->current['BASE']);
664       $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)".
665           "(alias=$address)(gosaMailAlternateAddress=$address)))", array("uid"));
666       if ($ldap->count() > 0){
667         $attrs= $ldap->fetch ();
668         return ($attrs["uid"][0]);
669       }
670       if (!in_array($address, $this->gosaMailAlternateAddress)){
671         $this->gosaMailAlternateAddress[]= $address;
672         $this->is_modified= TRUE;
673       }
674       sort ($this->gosaMailAlternateAddress);
675       reset ($this->gosaMailAlternateAddress);
676       return ("");
677     }else{
678       msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
679     }
680   }
683   /*! \brief  Removes the given mail address from the alternate addresses list 
684    */ 
685   function delAlternate($addresses)
686   {
687     if($this->acl_is_writeable("gosaMailAlternateAddress")){
688       $this->gosaMailAlternateAddress= array_remove_entries ($addresses,$this->gosaMailAlternateAddress);
689       $this->is_modified= TRUE;
690     }else{
691       msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG);
692     }
693   }
696   /*! \brief  Prepare importet vacation string. \
697     .         Replace placeholder like %givenName a.s.o.
698     @param  string  Vacation string
699     @return string  Completed vacation string
700    */
701   private function prepare_vacation_template($contents)
702   {
703     /* Replace attributes */
704     $attrs = array();
705     $obj   = NULL;
706     if(isset($this->parent->by_object['user'])){
707       $attrs  = $this->parent->by_object['user']->attributes;
708       $obj    = $this->parent->by_object['user'];
709     }else{
710       $obj    = new user($this->config,$this->dn);
711       $attrs  = $obj->attributes;
712     }
713     if($obj){
714       foreach ($attrs as $val){
715         if(preg_match("/dateOfBirth/",$val)){
716           if($obj->use_dob){
717             $contents= preg_replace("/%$val/",date("Y-d-m",$obj->dateOfBirth),$contents);
718           }
719         }else {
720           $contents= preg_replace("/%$val/",
721               $obj->$val, $contents);
722         }
724         /* Replace vacation start and end time */
725         if(preg_match("/%start/",$contents)){
726           $contents = preg_replace("/%start/",date("d.m.Y",$this->gosaVacationStart),$contents);
727         }
728         if(preg_match("/%end/",$contents)){
729           $contents = preg_replace("/%end/",date("d.m.Y",$this->gosaVacationStop),$contents);
730         }
731       }
732     }
733     $contents = ltrim(preg_replace("/^DESC:.*$/m","",$contents),"\n ");
734     return($contents);
735   }
738   /*! \brief  Displays a dialog that allows mail address selection.
739    */ 
740   function display_forward_dialog()
741   {
742     restore_error_handler();
744     $smarty = get_smarty();
745     $ldap= $this->config->get_ldap_link();
747     /* Save data */
748     $mailfilter= session::get("mailfilter");
749     foreach( array("depselect", "muser", "regex") as $type){
750       if (isset($_POST[$type])){
751         $mailfilter[$type]= $_POST[$type];
752       }
753     }
754     if (isset($_GET['search'])){
755       $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
756       if ($s == "**"){
757         $s= "*";
758       }
759       $mailfilter['regex']= $s;
760     }
761     session::set("mailfilter", $mailfilter);
763     /* Get actual list */
764     $mailusers= array ();
765     if ($mailfilter['regex'] != '*' && $mailfilter['regex'] != ""){
766       $regex= $mailfilter['regex'];
767       $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))";
768     } else {
769       $filter= "";
770     }
771     if ($mailfilter['muser'] != ""){
772       $user= $mailfilter['muser'];
773       $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))";
774     }
776     /* Add already present people to the filter */
777     $exclude= "";
778     foreach ($this->gosaMailForwardingAddress as $mail){
779       $exclude.= "(mail=$mail)";
780     }
781     if ($exclude != ""){
782       $filter.= "(!(|$exclude))";
783     }
784     $res= get_list("(&(objectClass=gosaMailAccount)$filter)", "users", $mailfilter['depselect'],
785         array("sn", "mail", "givenName"), GL_SIZELIMIT | GL_SUBSEARCH);
786     $ldap->cd($mailfilter['depselect']);
787     $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName"));
788     while ($attrs= $ldap->fetch()){
789       if(preg_match('/%/', $attrs['mail'][0])){
790         continue;
791       }
792       $name= $this->make_name($attrs);
793       $mailusers[$attrs['mail'][0]]= $name."&lt;".
794         $attrs['mail'][0]."&gt;";
795     }
796     natcasesort ($mailusers);
797     reset ($mailusers);
799     /* Show dialog */
800     $smarty->assign("search_image", get_template_path('images/lists/search.png'));
801     $smarty->assign("usearch_image", get_template_path('images/lists/search-user.png'));
802     $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
803     $smarty->assign("infoimage", get_template_path('images/info.png'));
804     $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
805     $smarty->assign("mailusers", $mailusers);
806     if (isset($_POST['depselect'])){
807       $smarty->assign("depselect", $_POST['depselect']);
808     }
809     $smarty->assign("deplist", $this->config->idepartments);
810     $smarty->assign("apply", apply_filter());
811     $smarty->assign("alphabet", generate_alphabet());
812     $smarty->assign("hint", print_sizelimit_warning());
813     foreach( array("depselect", "muser", "regex") as $type){
814       $smarty->assign("$type", $mailfilter[$type]);
815     }
816     $smarty->assign("hint", print_sizelimit_warning());
817     $display= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE, dirname(__FILE__)));
818     return ($display);
819   }
822   /*! \brief  Removes the mailAccount extension from ldap 
823    */  
824   function remove_from_parent()
825   {
826     /* Cancel if there's nothing to do here */
827     if (!$this->initially_was_account){
828       return;
829     }
831     /* If domain part was selectable, contruct mail address */
832     if($this->mailMethod->domainSelectionEnabled()){
833       $this->mail = $this->mail."@".$this->mailDomainPart;
834     }
836     /* Remove GOsa attributes */
837     plugin::remove_from_parent();
839     /* Zero arrays */
840     $this->attrs['gosaMailAlternateAddress'] = array();
841     $this->attrs['gosaMailForwardingAddress']= array();
844     $this->mailMethod->fixAttributesOnRemove();
845     $this->cleanup();
847     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save");
848     $ldap= $this->config->get_ldap_link();
849     $ldap->cd($this->dn);
850     $ldap->modify ($this->attrs);
852     /* Add "view" to logging class */
853     new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
854     if (!$ldap->success()){
855       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
856     }
857     
858     /* Let the mailMethod remove this mailbox, e.g. from imap and
859        update shared folder membership, ACL may need to be updated. 
860      */
861     if (!$this->is_template){
863       if(!$this->mailMethod->connect()){
864         msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."), 
865               $this->mailMethod->get_error()), ERROR_DIALOG);
866       }else{
867         if(!$this->mailMethod->deleteMailbox()){
868           msg_dialog::display(_("Mail error"), sprintf(_("Cannot remove mailbox! Error was: %s."), 
869                 $this->mailMethod->get_error()), ERROR_DIALOG);
870         }
871         if(!$this->mailMethod->updateSharedFolder()){
872           msg_dialog::display(_("Mail error"), sprintf(_("Cannot update shared folder permissions! Error was: %s."), 
873                 $this->mailMethod->get_error()), ERROR_DIALOG);
874         }
875       }
876     }
877     $this->mailMethod->disconnect();
879     /* Optionally execute a command after we're done */
880     $this->handle_post_events("remove",array("uid" => $this->uid));
881   }
884   /*! \brief  Save the mailAccount settings to the ldap database.
885    */
886   function save()
887   {
888     $ldap= $this->config->get_ldap_link();
890     /* If domain part was selectable, contruct mail address */
891     if($this->mailMethod->domainSelectionEnabled()){
892       $this->mail = $this->mail."@".$this->mailDomainPart;
893     }
894     
895     /* Enforce lowercase mail address and trim whitespaces
896      */
897     $this->mail = trim(strtolower($this->mail));
899     /* Call parents save to prepare $this->attrs */
900     plugin::save();
902     /* Save arrays */
903     $this->attrs['gosaMailAlternateAddress'] = $this->gosaMailAlternateAddress;
904     $this->attrs['gosaMailForwardingAddress']= $this->gosaMailForwardingAddress;
906     if(!$this->mailMethod->vacationRangeEnabled()){
907       $this->attrs['gosaVacationStart'] = $this->attrs['gosaVacationStop'] = array();
908     }elseif (!preg_match('/V/', $this->gosaMailDeliveryMode)){
909       unset($this->attrs['gosaVacationStart']);
910       unset($this->attrs['gosaVacationStop']);
911     }
913     /* Map method attributes */ 
914     $this->mailMethod->fixAttributesOnStore();
915     
916     /* Save data to LDAP */
917     $ldap->cd($this->dn);
918     $this->cleanup();
919     $ldap->modify ($this->attrs);
921     if (!$ldap->success()){
922       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
923     }
925     /* Log last action */
926     if($this->initially_was_account){
927       new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
928     }else{
929       new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
930     }
932     /* Only do IMAP actions if we are not a template */
933     if (!$this->is_template){
934       $this->mailMethod->connect();
935       if(!$this->mailMethod->is_connected()){
936         msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."), 
937               $this->mailMethod->get_error()), ERROR_DIALOG);
938       }else{
939         if(!$this->mailMethod->updateMailbox()){
940           msg_dialog::display(_("Mail error"), sprintf(_("Cannot update mailbox! Error was: %s."), 
941                 $this->mailMethod->get_error()), ERROR_DIALOG);
942         }
943         if(!$this->mailMethod->setQuota($this->gosaMailQuota)){
944           msg_dialog::display(_("Mail error"), sprintf(_("Cannot write quota settings! Error was: %s."), 
945                 $this->mailMethod->get_error()), ERROR_DIALOG);
946         }
948         if (!is_integer(strpos($this->gosaMailDeliveryMode, "C"))){
951           /* Do not write sieve settings if this account is new and 
952              doesn't seem to exist.
953            */
954           if(!$this->initially_was_account && !$this->mailMethod->account_exists()){
955             @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,
956                 "Skipping sieve settings, the account doesn't seem to be created already.</b>","");
957           }else{
958             if(!$this->mailMethod->saveSieveSettings()){
959               msg_dialog::display(_("Mail error"), $this->mailMethod->get_error(), ERROR_DIALOG);
960             }
961           }
962         }else{
963       
964          echo "Check sieve management here";
966           @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, 
967               "User uses an own sieve script, skipping sieve update.".$str."</b>","");
968         }
970         if(!$this->mailMethod->updateSharedFolder()){
971           msg_dialog::display(_("Mail error"), sprintf(_("Cannot update shared folder permissions! Error was: %s."), 
972                 $this->mailMethod->get_error()), ERROR_DIALOG);
973         }
974       }
975     }
976     $this->mailMethod->disconnect();
978     /* Optionally execute a command after we're done */
979     if ($this->initially_was_account == $this->is_account){
980       if ($this->is_modified){
981         $this->handle_post_events("modify", array("uid" => $this->uid));
982       }
983     } else {
984       $this->handle_post_events("add", array("uid" => $this->uid));
985     }
986   }
989   /*! \brief  Check given values 
990    */
991   function check()
992   {
993     if(!$this->is_account){
994       return(array());
995     }
997     $ldap= $this->config->get_ldap_link();
999     /* Call common method to give check the hook */
1000     $message= plugin::check();
1002     if(empty($this->gosaMailServer)){
1003       $message[]= msgPool::noserver(_("Mail"));
1004     }
1006     /* Mail address checks */
1007     $mail = $this->mail;
1008     if($this->mailMethod->domainSelectionEnabled()){
1009       $mail.= "@".$this->mailDomainPart;
1010     }
1012     if (empty($mail)){
1013       $message[]= msgPool::required(_("Primary address"));
1014     }
1015     if ($this->is_template){
1016       if (!tests::is_email($mail, TRUE)){
1017         $message[]= msgPool::invalid(_("Mail address"),"","","%givenName.%sn@your-domain.com");
1018       }
1019     } else {
1020       if (!tests::is_email($mail)){
1021         $message[]= msgPool::invalid(_("Mail address"),"","","your-address@your-domain.com");
1022       }
1023     }
1025     /* Check if this mail address is already in use */
1026     $ldap->cd($this->config->current['BASE']);
1027     $filter = "(&(!(objectClass=gosaUserTemplate))(!(uid=".$this->uid."))".
1028       "(objectClass=gosaMailAccount)".
1029       "(|(mail=".$mail.")(alias=".$mail.")(gosaMailAlternateAddress=".$mail.")))";
1030     $ldap->search($filter,array("uid"));
1031     if ($ldap->count() != 0){
1032       $message[]= msgPool::duplicated(_("Mail address"));
1033     }
1036     /* Check quota */
1037     if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){
1038       if (!is_numeric($this->gosaMailQuota)) {
1039         $message[]= msgPool::invalid(_("Quota size"),$this->gosaMailQuota,"/^[0-9]*/");
1040       } else {
1041         $this->gosaMailQuota= (int) $this->gosaMailQuota;
1042       }
1043     }
1045     /* Check rejectsize for integer */
1046     if ($this->gosaMailMaxSize != '' && $this->acl_is_writeable("gosaMailMaxSize")){
1047       if (!is_numeric($this->gosaMailMaxSize)){
1048         $message[]= msgPool::invalid(_("Mail reject size"),$this->gosaMailMaxSize,"/^[0-9]*/");
1049       } else {
1050         $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize;
1051       }
1052     }
1054     /* Need gosaMailMaxSize if use_mailsize_limit is checked */
1055     if (is_integer(strpos($this->gosaMailDeliveryMode, "R")) && $this->gosaMailMaxSize == ""){
1056       $message[]= msgPool::required(_("Mail reject size"));
1057     }
1059     if((preg_match("/S/", $this->gosaMailDeliveryMode))&&(empty($this->gosaSpamMailbox))) {
1060       $message[]= msgPool::required(_("Spam folder"));
1061     }
1063     if ($this->mailMethod->vacationRangeEnabled() 
1064         && preg_match('/V/', $this->gosaMailDeliveryMode) 
1065         && $this->gosaVacationStart > $this->gosaVacationStop){
1066       $message[]= msgPool::invalid(_("Vacation interval"));
1067     }
1068     return($message);
1069   }
1072   /*! \brief  Adapt from template, using 'dn' 
1073    */
1074   function adapt_from_template($dn, $skip= array())
1075   {
1076     plugin::adapt_from_template($dn, $skip);
1078     foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
1080       if (in_array($val, $skip)){
1081         continue;
1082       }
1084       $this->$val= array();
1085       if (isset($this->attrs["$val"]["count"])){
1086         for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
1087           $value= $this->attrs["$val"][$i];
1088           foreach (array("sn", "givenName", "uid") as $repl){
1089             if (preg_match("/%$repl/i", $value)){
1090               $value= preg_replace ("/%$repl/i", $this->parent->$repl, $value);
1091             }
1092           }
1093           array_push($this->$val, strtolower(rewrite($value)));
1094         }
1095       }
1096     }
1097     $this->mail= strtolower(rewrite($this->mail));
1098   }
1101   /*! \brief  Creates the mail part for the copy & paste dialog 
1102    */ 
1103   function getCopyDialog()
1104   {
1105     if(!$this->is_account) return("");
1106     $smarty = get_smarty();
1107     $smarty->assign("mail",$this->mail);
1108     $smarty->assign("gosaMailAlternateAddress",$this->gosaMailAlternateAddress);
1109     $smarty->assign("gosaMailForwardingAddress",$this->gosaMailForwardingAddress);
1110     $str = $smarty->fetch(get_template_path("copypaste.tpl",TRUE, dirname(__FILE__)));
1112     $ret = array();
1113     $ret['status'] = "";
1114     $ret['string'] = $str;
1115     return($ret);
1116   }
1118     
1119   /*! \brief  save_object for copy&paste vars 
1120    */  
1121   function saveCopyDialog()
1122   {
1123     if(!$this->is_account) return;
1125     /* Execute to save mailAlternateAddress && gosaMailForwardingAddress */
1126     $this->execute();
1127     if(isset($_POST['mail'])){
1128       $this->mail = $_POST['mail'];
1129     }
1130   }
1132   
1133   /*! \brief  Prepare this account to be copied 
1134    */
1135   function PrepareForCopyPaste($source)
1136   {
1137     plugin::PrepareForCopyPaste($source);
1139     /* Reset alternate mail addresses */
1140     $this->gosaMailAlternateAddress = array();
1141   }
1144   /*! \brief  Prepare this class the be useable when editing multiple users at once 
1145    */
1146   function get_multi_edit_values()
1147   {
1148     $ret = plugin::get_multi_edit_values();
1149     if(in_array("gosaMailQuota",$this->multi_boxes)){
1150       $ret['gosaMailQuota'] = $this->gosaMailQuota;
1151     }
1152     $flag_add = $flag_remove = array();
1153     $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
1154     $opts = array(
1155         "R"   => "use_mailsize_limit",
1156         "S"   => "use_spam_filter",
1157         "L"   => "only_local",
1158         "V"   => "use_vacation",
1159         "C"   => "own_script",
1160         "I"   => "drop_own_mails");
1161     foreach($opts as $flag => $post){
1162       if(in_array($post, $this->multi_boxes)){
1163         if(preg_match("/".$flag."/",$tmp)){
1164           $flag_add[] = $flag;
1165         }else{
1166           $flag_remove[] = $flag;
1167         }
1168       }
1169     }
1170     $ret['flag_add'] = $flag_add;
1171     $ret['flag_remove'] = $flag_remove;
1173     echo "1";
1174     if($this->mailMethod->vacationRangeEnabled()){
1175       echo "2";
1176       if(in_array("V",$flag_add)){
1177         $ret['gosaVacationStart'] =  $this->gosaVacationStart = $_POST['gosaVacationStart'];
1178         $ret['gosaVacationStop'] =  $this->gosaVacationStop = $_POST['gosaVacationStop'];
1179       }
1180     }
1181     return($ret);
1182   }
1185   /*! \brief  Check given input for multiple user edit 
1186    */
1187   function multiple_check()
1188   {
1189     $message = plugin::multiple_check();
1191     if(empty($this->gosaMailServer) && in_array("gosaMailServer",$this->multi_boxes)){
1192       $message[]= msgPool::noserver(_("Mail"));
1193     }
1195     /* Check quota */
1196     if ($this->gosaMailQuota != ''  && in_array("gosaMailQuota",$this->multi_boxes)){
1197       if (!is_numeric($this->gosaMailQuota)) {
1198         $message[]= msgPool::invalid(_("Quota size"),$this->gosaMailQuota,"/^[0-9]*/");
1199       } else {
1200         $this->gosaMailQuota= (int) $this->gosaMailQuota;
1201       }
1202     }
1204     /* Check rejectsize for integer */
1205     if ($this->gosaMailMaxSize != '' && in_array("gosaMailMaxSize",$this->multi_boxes)){
1206       if (!is_numeric($this->gosaMailMaxSize)){
1207         $message[]= msgPool::invalid(_("Mail reject size"),$this->gosaMailMaxSize,"/^[0-9]*/");
1208       } else {
1209         $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize;
1210       }
1211     }
1213     if(empty($this->gosaSpamMailbox) && in_array("gosaSpamMailbox",$this->multi_boxes)){
1214       $message[]= msgPool::required(_("Spam folder"));
1215     }
1217     if (  in_array("use_vacation",$this->multi_boxes) &&
1218         preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){
1219       $message[]= msgPool::invalid(_("Vacation interval"));
1220     }
1221     return($message);
1222   }
1224   
1225   /*! \brief  ...
1226    */
1227   function set_multi_edit_values($values)
1228   {
1229     plugin::set_multi_edit_values($values);
1230     $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
1231     if(isset($values['flag_add'])){
1232       foreach($values['flag_add'] as $flag){
1233         if(!preg_match("/".$flag."/",$tmp)){
1234           $tmp .= $flag;
1235         }
1236       }
1237     }
1238     if(isset($values['flag_remove'])){
1239       foreach($values['flag_remove'] as $flag){
1240         if(preg_match("/".$flag."/",$tmp)){
1241           $tmp = preg_replace("/".$flag."/","",$tmp);
1242         }
1243       }
1244     }
1245     $this->gosaMailDeliveryMode = "[".$tmp."]";
1247     /* Set vacation message and replace placeholder like %givenName
1248      */
1249     if(isset($values['gosaVacationMessage'])){
1250       $this->gosaVacationMessage = $this->prepare_vacation_template($values['gosaVacationMessage']);
1251     }
1252   }
1255   /*! \brief  Initialize plugin to be used as multiple edit class. 
1256    */
1257   function init_multiple_support($attrs,$all)
1258   {
1259     plugin::init_multiple_support($attrs,$all);
1260     if(isset($this->multi_attrs['gosaMailQuota'])){
1261       $this->gosaMailQuota = $this->multi_attrs['gosaMailQuota'];
1262     }
1263   }
1265  
1266   /*! \brief
1267    */
1268   function get_multi_init_values()
1269   {
1270     $attrs = plugin::get_multi_init_values();
1271     $attrs['gosaMailQuota'] = $this->gosaMailQuota;
1272     return($attrs);
1273   }
1276   /*! \brief  Display multiple edit dialog 
1277    */
1278   function multiple_execute()
1279   {
1280     return($this->execute());
1281   }
1283   
1284   /*! \brief  Save posts from multiple edit dialog 
1285    */
1286   function multiple_save_object()
1287   {
1288     plugin::multiple_save_object();
1290     $this->save_object();
1291     foreach(array("only_local","gosaMailForwardingAddress","use_mailsize_limit","drop_own_mails","use_vacation","use_spam_filter") as $attr){
1292       if(isset($_POST["use_".$attr])){
1293         $this->multi_boxes[] = $attr;
1294       }
1295     }
1296   }
1299   /*! \brief  Creates the user names for the add_local_forward dialog
1300    */
1301   function make_name($attrs)
1302   {
1303     $name= "";
1304     if (isset($attrs['sn'][0])){
1305       $name= $attrs['sn'][0];
1306     }
1307     if (isset($attrs['givenName'][0])){
1308       if ($name != ""){
1309         $name.= ", ".$attrs['givenName'][0];
1310       } else {
1311         $name.= $attrs['givenName'][0];
1312       }
1313     }
1314     if ($name != ""){
1315       $name.= " ";
1316     }
1318     return ($name);
1319   }
1322   /*! \brief  ACL settings 
1323    */
1324   static function plInfo()
1325   {
1326     return (array(
1327           "plShortName"     => _("Mail"),
1328           "plDescription"   => _("Mail settings"),
1329           "plSelfModify"    => TRUE,
1330           "plDepends"       => array("user"),                     // This plugin depends on
1331           "plPriority"      => 4,                                 // Position in tabs
1332           "plSection"     => array("personal" => _("My account")),
1333           "plCategory"    => array("users"),
1334           "plOptions"       => array(),
1336           "plProvidedAcls"  => array(
1337             "mail"                      =>  _("Mail address"),
1338             "gosaMailServer"            =>  _("Mail server"),
1339             "gosaMailQuota"             =>  _("Quota size"),
1341             "gosaMailDeliveryModeV"     =>  _("Add vacation information"),  // This is flag of gosaMailDeliveryMode
1342             "gosaVacationMessage"       =>  _("Vacation message"),
1344             "gosaMailDeliveryModeS"     =>  _("Use spam filter"),           // This is flag of gosaMailDeliveryMode
1345             "gosaSpamSortLevel"         =>  _("Spam level"),
1346             "gosaSpamMailbox"           =>  _("Spam mail box"),
1348             "sieveManagement"           =>  _("Sieve management"),
1350             "gosaMailDeliveryModeR"     =>  _("Reject due to mailsize"),    // This is flag of gosaMailDeliveryMode
1351             "gosaMailMaxSize"           =>  _("Mail max size"),
1353             "gosaMailForwardingAddress" =>  _("Forwarding address"),
1354             "gosaMailDeliveryModeL"     =>  _("Local delivery"),            // This is flag of gosaMailDeliveryMode
1355             "gosaMailDeliveryModeI"     =>  _("No delivery to own mailbox "),     // This is flag of gosaMailDeliveryMode
1356             "gosaMailAlternateAddress"  =>  _("Mail alternative addresses"),
1358             "gosaMailForwardingAddress" =>  _("Forwarding address"),
1359             "gosaMailDeliveryModeC"     =>  _("Use custom sieve script"))   // This is flag of gosaMailDeliveryMode
1360               ));
1361   }
1366 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1367 ?>