Code

Updated group Mail
[gosa.git] / gosa-plugins / mail / admin / groups / mail / class_groupMail.inc
1 <?php
3 class mailgroup extends plugin
4 {
5   var $uid                        = "";       // User id 
6   var $cn                         = "";       // cn
7   var $orig_cn                    = "";       // cn
9   var $method                     = "mailMethod"; // Used Mail method 
10   var $mmethod                    = "";           // Contains the gosa.conf MAILMETHOD
11   var $mail                       = "";           // Default mail address 
13   var $gosaMailAlternateAddress   = array();  // Set default Alternate Mail Adresses to empty array
14   var $gosaMailForwardingAddress  = array();  // Forwarding also empty
16   var $gosaMailForwardingAddress_Some  = array();  // Used in multiple edit 
18   var $gosaMailServer             = "";       // Selected mailserver 
19   var $gosaMailQuota              = "";       // Defined Quota 
20   var $quotaUsage                 = 0;        // Currently used quota
22   var $gosaVacationMessage        = "";       // Vocation message 
24   var $imapacl                    = array('anyone'    => 'p',     // Set acls for everyone
25       '%members%' => 'lrswp',  // %members% are all group-members
26       ''          => 'p');    // Every user added gets this right
28   var $kolabFolderTypeSubType = "";
29   var $kolabFolderTypeType = "";
31   var $gosaSpamSortLevel          = "";     
32   var $gosaSpamMailbox            = "";
33   var $gosaSharedFolderTarget     ;
35   var $forward_dialog             = FALSE;    
37   var $members                    = array();  // Group members
39   var $mailusers                  = array();
40   var $perms                      = array();
41   var $gosaMailDeliveryMode       = "[L        ]";   // 
42   var $gosaMailMaxSize            = "";       // 
43   
44   var $remove_folder_from_imap    = true;
46   /* Helper */
47   var $indexed_acl= array();
48   var $indexed_user= array();
50   var $view_logged = FALSE;
52   /* attribute list for save action */
53   var $attributes= array( "mail",   "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize",
54       "gosaMailAlternateAddress", "gosaMailForwardingAddress",
55       "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox",
56       "acl","gosaSharedFolderTarget", "gosaVacationMessage");
58   var $objectclasses= array("gosaMailAccount");
59   var $CopyPasteVars          = array("quotaUsage","imapacl");
61   var $multiple_support = TRUE;
65   var $folder_prefix  = "";
66   var $user_prefix    = "";
68   var $account_name   = "";
70   function mailgroup (&$config, $dn= NULL, $ui= NULL)
71   {
72     /* Initialise all available attributes ... if possible
73      */
74     plugin::plugin($config, $dn);
75     if (isset($this->attrs['cn'][0])){
76       $this->uid = $this->cn = $this->attrs['cn'][0];
77     }
78     $this->orig_cn = $this->cn;
80     /* Set mailMethod to the one defined in gosa.conf 
81      */
82     if ($this->config->get_cfg_value("mailmethod")){
83       $this->mmethod= $this->config->get_cfg_value("mailmethod");
84     }
86     /* Check if selected mail method exists 
87      */
88     $cls = get_correct_class_name("mailMethod$this->mmethod");
89     if ($cls && class_exists($cls)){
90       $this->method= $cls;
91     } else {
92       msg_dialog::display(_("Configuration error"), sprintf(_("Cannot locate mail method '%s'!"), $this->mmethod), ERROR_DIALOG);
93     }
95     /* Load Mailserver  
96      */
97     if(isset($this->attrs['gosaMailServer'][0])){
98       $this->gosaMailServer =  $this->attrs['gosaMailServer'][0];
99     }
101     /* Get folder type */
102     if(preg_match("/olab/i",$this->config->get_cfg_value("mailmethod"))){
103       if(isset($this->attrs['kolabFolderType'])){
104         $tmp = split("\.",$this->attrs['kolabFolderType'][0]);
105         $this->kolabFolderTypeType = $tmp[0];
106         $this->kolabFolderTypeSubType = $tmp[1];
107       }
108     }
110     /* Create new instance of our defined mailclass
111      */
112     $method= new $this->method($this->config);
114     $this->folder_prefix  = $method->folder_prefix;
115     $this->user_prefix    = $method->user_prefix;
117     /* Build account name 
118      */
119     $uattrib = $method->uattrib;
121     /* Map uid to cn, because we are in a group currently */
122     if($uattrib == "uid") $uattrib ="cn"; 
123  
124     if (isset($this->attrs[$uattrib][0])){
125   
126       $this->account_name= $this->attrs[$uattrib][0];
127       if(preg_match("/@/",$this->account_name)){
128         $cn = "";
129         if(isset($this->attrs['cn'][0])){
130           $cn = $this->attrs['cn'][0];
131         }
132         $this->account_name = preg_replace("/^[^@]*/",$cn,$this->account_name);
133       }
134     }
136     /* If this isn't a new mailgroup, read all required data from ldap
137      */
138     if (($dn != "new")&&($dn !== NULL)){
140       /* Load attributes which represent multiple entries  
141        */
142       foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
143         $this->$val = array();
144         if (isset($this->attrs["$val"]["count"])){
145           for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
146             array_push($this->$val, $this->attrs["$val"][$i]);
147           }
148         }
149       }
151       /* Only do IMAP actions if gosaMailServer attribute is set 
152        */
153       if (isset ($this->attrs["gosaMailServer"][0])){
155         if ($method->connect($this->attrs["gosaMailServer"][0])){
157           /* If we do NOT use kolab or equal methods, 
158              read imap the acls from the mail method class.
159              They will be merged later with the ldap specified acls.
160            */
161           if(!preg_match("/olab/i",$this->mmethod) && !empty($this->mmethod)){
162             $this->imapacl=  $method->getSharedFolderPermissions($this->folder_prefix.$this->account_name);
164             /* Need to filter what a member acl could be... */
165             $vote= array();
166             $peak= 0;
167             $leader= "";
168             foreach ($this->imapacl as $user => $acl){
170               if ($user != "anyone" ){
171                 if (!isset($vote[$acl])){
172                   $vote[$acl]= 1;
173                 } else {
174                   $vote[$acl]++;
175                 }
176                 if ($vote[$acl] > $peak){
177                   $leader= $acl;
178                   $peek= $vote[$acl];
179                 }
180               }
181             }
182             /* Highest count wins as %members%, remove all members
183                with the same acl */
184             if(!empty($leader)){
185               $this->imapacl['%members%']= $leader;
186             }
187             foreach ($this->imapacl as $user => $acl){
188               if ($this->acl == $leader && in_array($user, $this->attrs['memberUid'])){
189                 unset($this->imapacl[$user]);
190               }
191             }
192           }
194           /* Adapt attributes if needed */
195           $method->fixAttributesOnLoad($this);
197           /*  get Quota */
198           $quota= $method->getQuota($this->folder_prefix.$this->account_name);
200           /* Update quota values */
201           if(is_array($quota)){
202             if ($quota['gosaMailQuota'] == 2147483647){
203               $this->quotaUsage= "";
204               $this->gosaMailQuota= "";
205             } else {
206               $this->quotaUsage= $quota['quotaUsage'];
207               $this->gosaMailQuota= $quota['gosaMailQuota'];
208             }
209           }else{
210             $this->quotaUsage     = "";
211             $this->gosaMailQuota  = "";
212           }
213           $method->disconnect();
214         }   // ENDE $method->connect($this->attrs["gosaMailServer"][0])){
215       }   // ENDE gosaMailServer
216     }   // ENDE dn != "new"
219     /* Get global filter config */
220     if (!session::is_set("gmailfilter")){
221       $ui= get_userinfo();
222       $base= get_base_from_people($ui->dn);
223       $gmailfilter= array( "depselect"       => $base,
224           "muser"            => "",
225           "regex"           => "*");
226       session::set("gmailfilter", $gmailfilter);
227     }
229     /* Load permissions */
230     $tmp = array();
231     $ldap = $this->config->get_ldap_link();
233     /* Read acls  from ldap and merge them with
234      *  acls read from mail method.
235      */
236     if (isset($this->attrs['acl'])){
238       for ($i= 0; $i<$this->attrs['acl']['count']; $i++){
239         list($user, $permission)= split(' ', $this->attrs['acl'][$i]);
241         /* Add to list */
242         $this->imapacl[$user]= $permission;
244         /* Get all user permissions sorted by acl, to detect the most used acl
245            This acl is then used for %members%
246          */
247         if ($user != "anyone" && $user != "%members%"){
248           $tmp[$permission][] = $user;
249         }
251         /* There is an entry in $this->imapacl like this this ... 
252            $this->attrs['imapacl']['anyone'] = "p";
253            $this->attrs['imapacl']['%members%'] = "lprs";
254            $this->attrs['imapacl'][''] = ""; <------ This is used to diplay an empty 
255            Field for special acls in our template.
256            If there is at least one special acl in out imapacl,
257            we don't need this entry anymore, because it is already displayed. 
258          */
259         if ($user != "anyone" && $user != "%members%"){
260           unset($this->imapacl['']);
261         }
262       }
263     }
265     /**
266      * Detect group members which use the same acl
267      *  as used for %members% and remove them.
268      **/
270     /* In this section we detect which acl is the most used.
271        This will be used as %members% acl.
272      */
273     $tmp2 = array(); 
274     foreach($tmp as $acl => $user){
275       $tmp2[count($tmp[$acl])]=$acl;
276     }
277     /* Most used at last 
278      */
279     ksort($tmp2);      
281     /* Assign last (most used acl) to %members% acl 
282      */
283     $str = array_pop($tmp2);
284     if(!empty($str)) {
285       $this->imapacl['%members%']=$str;
286     }
287     if(!isset($this->imapacl['%members%'])){
288       $this->imapacl['%members%'] = "lrspw";
289     }
292     /* Open ldap connection 
293      */
294     $ldap = $this->config->get_ldap_link();
295     $ldap->cd($this->config->current['BASE']);
297     /* Remove those users, that use %members% acl && are member of this group. */
298     foreach($this->imapacl as $mail => $permission){
299       $ldap->search("(&(objectClass=person)(|(mail=".$mail.")(uid=".$mail.")))",array("uid"));
300       $atr = $ldap->fetch();
301       if((isset($this->attrs['memberUid'])) && (is_array($this->attrs['memberUid']))){
302         if((isset($atr['uid'][0]))&&(in_array($atr['uid'][0],$this->attrs['memberUid']))&&($permission == $this->imapacl['%members%'])){
303           unset($this->imapacl[$mail]);
304         }
305       }
306     }
308     /**
309      * ENDE: Detect group member with same acl and replace them with %members%
310      **/
311     $this->indexed_user = array("%members%","anyone");
313     /* Append an empty entry, for special acl handling */
314     if(count($this->imapacl)==2){
315       $this->imapacl[''] ="lrsw";
316       $this->indexed_user[] = '';
317     }
319     /* Load Mailserver
320      */
321     if(isset($this->attrs['gosaMailServer'][0])){
322       $this->gosaMailServer =  $this->attrs['gosaMailServer'][0];
323     }
324     /* Fill translations */
325     $this->perms["lrsw"]= _("read");
326     $this->perms["lrswp"]= _("post");
327     $this->perms["p"]= _("external post");
328     $this->perms["lrswip"]= _("append");
329     $this->perms["lrswipcd"]= _("write");
330     $this->perms["lrswipcda"]= _("admin");
331     $this->perms[""]= _("none");
332   }
336   function execute()
337   {
338     /* Call parent execute */
339     //plugin::execute();
340     $display = "";
342     /* Log view */
343     if($this->is_account && !$this->view_logged){
344       $this->view_logged = TRUE;
345       new log("view","groups/".get_class($this),$this->dn);
346     }
348     /* Load templating engine */
349     $smarty= get_smarty();
351     /* Assign acls */
352     $tmp = $this->plInfo();
353     foreach($tmp['plProvidedAcls'] as $name => $translation) {
354       $smarty->assign($name."ACL",$this->getacl($name));
355     }
357     if (session::get('js')==FALSE){
358       $smarty->assign("javascript", "false");
359     } else {
360       $smarty->assign("javascript", "true");
361     }
363     /* Handle actions should not be done, when 
364      *  editing multiple entries at once. e.g. account state
365      */ 
366     if(!$this->multiple_support_active){
368       /* Do we need to flip is_account state? */
369       if(isset($_POST['modify_state'])){
370         if($this->is_account && $this->acl_is_removeable()){
371           $this->is_account= FALSE;
372         }elseif(!$this->is_account && $this->acl_is_createable()){
373           $this->is_account= TRUE;
374         }
375       }
377       $display = "";
379       /* Do we represent a valid account? */
380       if (!$this->is_account && $this->parent === NULL){
382         $display.= "<img alt=\"\" src=\"images/small-error.png\" align=middle>&nbsp;<b>".msgPool::noValidExtension(_("mail"))."</b>";
383         return ($display);
384       }
386       /* Show tab dialog headers */
387       $display= "";
388       if ($this->parent !== NULL){
389         if ($this->is_account){
390           $display.= $this->show_disable_header(_("Remove mail account"),
391               msgPool::featuresEnabled(_("mail")));
392         } else {
393           $display.= $this->show_enable_header(_("Create mail account"),
394               msgPool::featuresDisabled(_("mail")));
396           /* Show checkbox that allows us to remove imap entry too*/
397           if($this->initially_was_account){
398             $c = "";
399             if($this->remove_folder_from_imap){
400               $c= " checked ";
401             }
402             $display .= "<h2>Shared folder delete options</h2>
403               <input class='center' type='checkbox' name='remove_folder_from_imap' value='1' ".$c."
404               title='"._("Remove shared folder from mail server database when entry gets removed in LDAP")."'>";
405             $display .= _("Remove the shared folder and all its contents after saving this account");
406           }
407           return ($display);
408         }
409       }
410     }
412     /* Add ACL? */
413     if($this->acl_is_writeable("acl")){
414       foreach ($this->indexed_user as $nr => $user){
415         if (isset($_POST["add_$nr"])){
416           $this->imapacl[""]= "l";
417         }
418         if (isset($_POST["del_$nr"])){
419           unset ($this->imapacl[$user]);
420         }
421       }
422     }
424     /* Trigger forward add dialog? */
425     if($this->acl_is_writeable("gosaMailForwardingAddress")){
426       if (isset($_POST['add_local_forwarder'])){
427         $this->forward_dialog= TRUE;
428         $this->dialog= TRUE;
429       }
430     }
432     /* Cancel forward add dialog? */
433     if($this->acl_is_writeable("gosaMailForwardingAddress")){
434       if (isset($_POST['add_locals_cancel'])){
435         $this->forward_dialog= FALSE;
436         $this->dialog= FALSE;
437       }
438     }
440     /* Finished adding of locals? */
441     if ((isset($_POST['add_locals_finish'])) && ($this->acl_is_writeable("gosaMailForwardingAddress"))) {
442       if (count ($_POST['local_list']) && $this->acl_is_writeable("gosaMailForwardingAddress")){
444         /* Walk through list of forwarders, ignore own addresses */
445         foreach ($_POST['local_list'] as $val){
446           if (!in_array ($val, $this->gosaMailAlternateAddress) &&
447               $val != $this->mail){
449             $this->addForwarder($val);
450           }
451         }
452       }
453       $this->forward_dialog= FALSE;
454       $this->dialog= FALSE;
455     }
457     /* Add forward email addresses */
458     if ((isset($_POST['add_forwarder'])) && ($this->acl_is_writeable("gosaMailForwardingAddress"))){
459       if ($_POST['forward_address'] != ""){
461         /* Valid email address specified? */
462         $address= $_POST['forward_address'];
463         if (!tests::is_email($address)){
464           msg_dialog::display(_("Error"), msgPool::invalid(_("forward address")), ERROR_DIALOG);
465         } elseif ($address == $this->mail
466             || in_array($address, $this->gosaMailAlternateAddress)) {
468           msg_dialog::display(_("Error"), _("Cannot forward to users own mail address!"), ERROR_DIALOG);
470         } else {
472           /* Add it */
473           if ($this->acl_is_writeable("gosaMailForwardingAddress")){
474             $this->addForwarder ($address);
475           }
477         }
478       }
479     }
481     /* Delete forward email addresses */
482     if (isset($_POST['delete_forwarder']) && ($this->acl_is_writeable("gosaMailForwardingAddress"))){
483       if (count($_POST['forwarder_list'])&& $this->acl_is_writeable("gosaMailForwardingAddress")){
485         $this->delForwarder ($_POST['forwarder_list']);
486       }
487     }
489     /* Add alternate email addresses */
490     if (isset($_POST['add_alternate'])){
491       if ($_POST['alternate_address'] != "" && $this->acl_is_writeable("gosaMailAlternateAddress")){
493         if (!tests::is_email($_POST['alternate_address'])){
494           msg_dialog::display(_("Error"),msgPool::invalid(_("Alternate address")), ERROR_DIALOG);
496         } elseif (($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
497           $ui= get_userinfo();
498           if ($user != $ui->username){
499           msg_dialog::display(_("Error"),msgPool::duplicated(_("Mail address")), ERROR_DIALOG);
500           }
501         }
502       }
503     }
505     /* Delete alternate email addresses */
506     if($this->acl_is_writeable("gosaMailAlternateAddress")){
507       if (isset($_POST['delete_alternate']) && isset ($_POST['alternates_list'])){
508         if (count($_POST['alternates_list']) && $this->acl_is_writeable("gosaMailAlternateAddress")){
509           $this->delAlternate ($_POST['alternates_list']);
510         }
511       }
512     }
514     /* Show forward add dialog */
515     if ($this->forward_dialog){
516       $ldap= $this->config->get_ldap_link();
518       /* Save data */
519       $gmailfilter= session::get("gmailfilter");
520       foreach( array("depselect", "muser", "regex") as $type){
521         if (isset($_POST[$type])){
522           $gmailfilter[$type]= $_POST[$type];
523         }
524       }
525       if (isset($_GET['search'])){
526         $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
527         if ($s == "**"){
528           $s= "*";
529         }
530         $gmailfilter['regex']= $s;
531       }
532       session::set("gmailfilter", $gmailfilter);
534       /* Get actual list */
535       $mailusers= array ();
536       if ($gmailfilter['regex'] != '*' && $gmailfilter['regex'] != ""){
537         $regex= $gmailfilter['regex'];
538         $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))";
539       } else {
540         $filter= "";
541       }
542       if ($gmailfilter['muser'] != ""){
543         $user= $gmailfilter['muser'];
544         $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))";
545       }
547       /* Add already present people to the filter */
548       $exclude= "";
549       foreach ($this->gosaMailForwardingAddress as $mail){
550         $exclude.= "(mail=$mail)";
551       }
552       if ($exclude != ""){
553         $filter.= "(!(|$exclude))";
554       }
556       $res= get_list("(&(objectClass=gosaMailAccount)$filter)", "users", $gmailfilter['depselect'],
557                      array("sn", "mail", "givenName"), GL_SUBSEARCH | GL_SIZELIMIT);
558       $ldap->cd($gmailfilter['depselect']);
559       $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName"));
560       error_reporting (0);
561       while ($attrs= $ldap->fetch()){
562         if(preg_match('/%/', $attrs['mail'][0])){
563           continue;
564         }
565         $name= $this->make_name($attrs);
566         $mailusers[$attrs['mail'][0]]= $name."&lt;".
567           $attrs['mail'][0]."&gt;";
568       }
569       error_reporting (E_ALL | E_STRICT);
570       natcasesort ($mailusers);
571       reset ($mailusers);
573       /* Show dialog */
574       $smarty->assign("search_image", get_template_path('images/lists/search.png'));
575       $smarty->assign("usearch_image", get_template_path('images/lists/search-user.png'));
576       $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
577       $smarty->assign("infoimage", get_template_path('images/info.png'));
578       $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
579       $smarty->assign("mailusers", $mailusers);
580       $smarty->assign("deplist", $this->config->idepartments);
581       $smarty->assign("apply", apply_filter());
582       $smarty->assign("alphabet", generate_alphabet());
583       $smarty->assign("hint", print_sizelimit_warning());
584       foreach( array("depselect", "muser", "regex") as $type){
585         $smarty->assign("$type", $gmailfilter[$type]);
586       }
587       $smarty->assign("hint", print_sizelimit_warning());
588       $display.= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE, dirname(__FILE__)));
589       return ($display);
590     }
592     /* Assemble normal permissions */
593     if (isset($this->imapacl['anyone'])){
594       $smarty->assign("default_permissions", $this->imapacl['anyone']);
595     }
596     $smarty->assign("member_permissions", "lrsp");
597     if (isset($this->imapacl['%members%'])){
598       $smarty->assign("member_permissions", $this->imapacl['%members%']);
599     }
601     /* Assemble extra attributes */
602     $perm= $this->getacl( "acl");
603     $tmp= "";
604     $nr= 0;
605     $count= count($this->imapacl);
606     $this->indexed_user= array();
607     $this->indexed_acl= array();
608     foreach($this->imapacl as $user => $acl){
610       /* Add additional acl settings */
611       if ($user != "anyone" && $user != "%members%"){
613         $Dis  = "";
614         if(!preg_match("/w/",$perm)){
615           $Dis = " disabled ";
616         }
617   
618         /* Reset given Acls to ensure that nobody can read username and acls if not allwoed */
619         if(!preg_match("/r/",$perm)){
620           $user = "";
621           $nr   = "none";
622           $key  = "none";  
623         }
625         $tmp.= "<tr>  
626                  <td>
627                   <input name=\"user_$nr\" size=20 maxlength=60 value=\"$user\" ".$Dis.">
628                  </td>
629                  <td>
630                  <select size=\"1\" name=\"perm_$nr\" ".$Dis.">";
632         /* Add acl options for this additional acl setting */
633         if(preg_match("/r/",$perm)){
634           foreach ($this->perms as $key => $value){
635             if ($acl == $key){
636               $tmp.= "<option value=\"$key\" selected>$value</option>";
637             } else {
638               $tmp.= "<option value=\"$key\">$value</option>";
639             }
640           }
641         }
642         $tmp.= "</select>&nbsp;";
645         
646         if ($nr == $count - 1){
647           if($this->acl_is_writeable("acl")){
648             $tmp.= "<input type=submit value=\""._("Add")."\" ".
649               "name=\"add_$nr\" >";
650           }
651         }
652         if ($count > 3){
653           if($this->acl_is_writeable("acl")){
654             $tmp.= "<input type=submit value=\""._("Remove")."\" ".
655               "name=\"del_$nr\" ></td></tr>";        
656           }
657         }
658       }
659       $this->indexed_user[$nr]= $user;
660       $this->indexed_acl[$nr++]= $acl;
661     }
662     $smarty->assign("plusattributes", $tmp);
664     /* Show main page */
665     $mailserver= array();
666     $ui = get_userinfo();
667     foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){
668       if(!preg_match("/r/",$ui->get_category_permissions($val['server_dn'],"server"))) continue;
669       $mailserver[]= $key;
670     }
672     /* Append currently selected server if we are not allowed to view it. 
673      */
674     if(isset($this->config->data['SERVERS']['IMAP'][$this->gosaMailServer]) && 
675         !in_array($this->gosaMailServer,$mailserver)){
676       $mailserver[] = $this->gosaMailServer;
677     }
679     $smarty->assign("mailServers", $mailserver);
680     foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail",
681           "gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
682       $smarty->assign("$val", $this->$val);
683     }
684     if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){
685       if($this->acl_is_readable("gosaMailQuota")){
686         $smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota),100,15,true));
687         $smarty->assign("quotadefined", "true");
688       }else{
689         $smarty->assign("quotadefined", "true");
690         $smarty->assign("quotausage", "-");
691       }
692     } else {
693       $smarty->assign("quotadefined", "false");
694     }
696     if(preg_match("/olab/i",$this->config->get_cfg_value("mailmethod"))){
698       $smarty->assign("kolab", TRUE);
699       $smarty->assign("JS",session::get('js'));
700       $smarty->assign("kolabFolderTypeTypes",    array (   ''      => _('Unspecified'),  'mail' => _('Mails'),
701                                                             'task'  => _('Tasks') ,       'journal' => _('Journals'),
702                                                             'calendar' => _('Calendar'),       'contact' => _('Contacts'), 
703                                                             'note'  => _('Notes')));
704       if($this->kolabFolderTypeType == "mail"){
705         $smarty->assign("kolabFolderTypeSubTypes", array(    
706               ''          => _('Unspecified'),  'inbox'     => _("Inbox")   , 
707               'drafts'    => _("Drafts"),       'sentitems' => _("Sent items"),
708               'junkemail' => _("Junk mail")));
709       }else{
710         $smarty->assign("kolabFolderTypeSubTypes", array(  'default' => _("Default")));
711       }
712       $smarty->assign("kolabFolderTypeType",     $this->kolabFolderTypeType);
713       $smarty->assign("kolabFolderTypeSubType",  $this->kolabFolderTypeSubType);
714     }else{
715       $smarty->assign("kolab", FALSE);
716     }
718     /* Multiple support handling */
719     foreach($this->attributes as $attr){
720       if(in_array($attr,$this->multi_boxes)){
721         $smarty->assign("use_".$attr,TRUE);
722       }else{
723         $smarty->assign("use_".$attr,FALSE);
724       }
725     }
727     /* Multiple support handling */
728     foreach(array("kolabFolderType") as $attr){
729       if(in_array($attr,$this->multi_boxes)){
730         $smarty->assign("use_".$attr,TRUE);
731       }else{
732         $smarty->assign("use_".$attr,FALSE);
733       }
734     }
736     $smarty->assign("Forward_all",$this->gosaMailForwardingAddress);
737     $smarty->assign("Forward_some",$this->gosaMailForwardingAddress_Some);
739     if (preg_match("/I/", $this->gosaMailDeliveryMode)) {
740       $smarty->assign("only_local", "checked");
741     }else{
742       $smarty->assign("only_local", "");
743     }
745     $smarty->assign("multiple_support",$this->multiple_support_active);
746     $display.= $smarty->fetch (get_template_path('mail.tpl', TRUE, dirname(__FILE__)));
747     return ($display);
748   }
751   /* remove object from parent */
752   function remove_from_parent()
753   {
754     if(!$this->initially_was_account){
755       return;
756     }
757   
758     /* Added these ObjectClass and Attributes, because they were not 
759        removed correctly, only in case of kolab ... 
760      */
761     if(preg_match("/olab/i",$this->config->get_cfg_value("mailmethod"))){
762       $this->attributes[]="acl";
763       $this->objectclasses[] = "kolabSharedFolder";
764     }
765     /* include global link_info */
766     $ldap= $this->config->get_ldap_link();
768     /* Remove and write to LDAP */
769     plugin::remove_from_parent();
771     /* Zero arrays */
772     $this->attrs['gosaMailAlternateAddress']= array();
773     $this->attrs['gosaMailForwardingAddress']= array();
774     $this->attrs['gosaSharedFolderTarget']= array();
776     /* Connect to IMAP server for account deletion */
777     if ($this->initially_was_account){
778  
779       $method= new $this->method($this->config);
780       $method->fixAttributesOnRemove($this);
781       if ($method->connect($this->gosaMailServer) && $this->remove_folder_from_imap){
783         /* Remove account from IMAP server */
784         $method->deleteMailbox($this->folder_prefix.$this->account_name);
785         $method->disconnect();
786       }
787     }
788     /* Keep uid */
789     unset ($this->attrs['uid']);
791     $ldap->cd($this->dn);
792     $ldap->modify ($this->attrs); 
793     if (!$ldap->success()){
794       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
795     }
798     new log("remove","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
800     /* Optionally execute a command after we're done */
801     $this->handle_post_events("remove");
802   }
805   /* Save data to object */
806   function save_object()
807   {
809     /* Add special kolab attributes */    
810     if(preg_match("/olab/i",$this->config->get_cfg_value("mailmethod"))){
811       if(isset($_POST['kolabFolderTypeType']) && $this->acl_is_writeable("kolabFolderType")){
812         $this->kolabFolderTypeType = get_post("kolabFolderTypeType");
813         $this->kolabFolderTypeSubType = get_post("kolabFolderTypeSubType");
814       }
815     }
816   
817     /* Check if user wants to remove the shared folder from imap too */
818     if($this->initially_was_account && !$this->is_account){
819       if(isset($_POST['remove_folder_from_imap'])){
820         $this->remove_folder_from_imap = true;
821       }else{
822         $this->remove_folder_from_imap = false;
823       }
824     }
826     /* Assemble mail delivery mode
827        The mode field in ldap consists of values between braces, this must
828        be called when 'mail' is set, because checkboxes may not be set when
829        we're in some other dialog.
831        Example for gosaMailDeliveryMode [LR        ]
832 L: Local delivery
833 R: Reject when exceeding mailsize limit
834 S: Use spam filter
835 V: Use vacation message
836 C: Use custom sieve script
837 I: Only insider delivery */
838     if (isset($_POST['mailedit'])){
840       plugin::save_object();
842       $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
844       /* Handle delivery flags */
845       if($this->acl_is_writeable("gosaMailDeliveryModeL")){
846         if(!preg_match("/L/",$tmp) && !isset($_POST['drop_own_mails'])){
847           $tmp.="L";
848         }elseif(preg_match("/L/",$tmp) && isset($_POST['drop_own_mails'])){
849           $tmp = preg_replace("/L/","",$tmp);
850         }
851       }
853       $opts = array(
854           "R"   => "use_mailsize_limit",
855           "S"   => "use_spam_filter",
856           "V"   => "use_vacation",
857           "C"   => "own_script",
858           "I"   => "only_local");
860       foreach($opts as $flag => $post){
861         if($this->acl_is_writeable("gosaMailDeliveryMode".$flag)){
862           if(!preg_match("/".$flag."/",$tmp) && isset($_POST[$post])){
863             $tmp.= $flag;
864           }elseif(preg_match("/".$flag."/",$tmp) && !isset($_POST[$post])){
865             $tmp = preg_replace("/".$flag."/","",$tmp);
866           }
867         }
868       }
870       $tmp= "[$tmp]";
871       if ($this->gosaMailDeliveryMode != $tmp){
872         $this->is_modified= TRUE;
873       }
874       $this->gosaMailDeliveryMode= $tmp;
876       /* Collect data and re-assign it to the imapacl array */
877       if ($this->acl_is_writeable("acl")){
878         $this->imapacl= array();
879         $this->imapacl['%members%']= $_POST['member_permissions'];
880         $this->imapacl['anyone']= $_POST['default_permissions'];
881         foreach ($this->indexed_user as $nr => $user){
882           if (!isset($_POST["user_$nr"])){
883             continue;
884           }
885           if ($_POST["user_$nr"] != $user ||
886               $_POST["perm_$nr"] != $this->indexed_acl[$nr]){
887             $this->is_modified= TRUE;
888           }
889           $this->imapacl[$_POST["user_$nr"]]= $_POST["perm_$nr"];
890         }
891       }
892     }
894   }
897   /* Save data to LDAP, depending on is_account we save or delete */
898   function save()
899   {
900     $ldap= $this->config->get_ldap_link();
901     $ldap->cd($this->config->current['BASE']);
903     /* Call parents save to prepare $this->attrs */
904     plugin::save();
905    
906     /* Update sharefolder account name */ 
907     if(isset($this->parent->by_object['group']->cn)) {
908       $this->account_name = $this->parent->by_object['group']->cn;
909     }
911     /* Save arrays */
912     $this->attrs['gosaMailAlternateAddress']  = $this->gosaMailAlternateAddress;
913     $this->attrs['gosaMailForwardingAddress'] = $this->gosaMailForwardingAddress;
914     $this->attrs['gosaSharedFolderTarget']    = "share+".$this->account_name;
915     $this->attrs['acl']= array();
917     /* Prepare Mail server attribute */
918     if(preg_match("/olab/i",$this->mmethod)){
919       if (empty($this->gosaMailServer)||is_array($this->gosaMailServer)){
920         if(isset($this->attrs['gosaMailServer'][0])){
921           $this->gosaMailServer = $this->attrs['gosaMailServer'][0];
922         }
923       }
924     }  
926     /* Exchange '%member%' pseudo entry */
927     $memberacl= $this->imapacl['%members%'];
928     foreach ($this->members as $user){
929       if (!isset($this->imapacl[$user])){
930         $this->imapacl[$user]= $memberacl;
931       }
932     }
934     /* Prepare kolab attributes to be written  */
935     if(preg_match("/olab/i",$this->mmethod)){
936       if(!empty($this->kolabFolderTypeType)){
937         $this->attrs['kolabFolderType'] = $this->kolabFolderTypeType.".".$this->kolabFolderTypeSubType;
938       }else{
939         $this->attrs['kolabFolderType'] = array();
940       }
941     }
943     /* Get naming attribute for mail accounts */
944     $tmp = new $this->method($this->config);
945     $uattrib = $tmp->uattrib;
947     /* Create ACL array
948        What is done here.
950        1.  Do not write acl entries for empty entries.
951        2.  Check if given user is a valid GOsa user.
952        - If he is one, check if he has a valid mail extension
953        -If this is true, add the user to the ACL entry.
954        -If this is NOT true, skip ACL entries for this user.
955        - He is not a GOsa Account, so write the ACL. (Manually entered ACL)
956        3. In case of "olab" mail method, remove the entry from the $this->imapacl array
957        because the kolab deamon will set the acls for us.
959      */
960     $acls_set_for = array();
961     foreach ($this->imapacl as $user => $acl){
963       /* Skip empty entries */
964       if (empty($user) || $user == ""){
965         unset($this->imapacl[$user]);
966       }
968       /* Skip placeholder */
969       if (empty($user) || $user == "" || preg_match("/%members%/",$user)){
970         continue;
971       }
973       /* Check if your is a real GOsa user
974        * If user is a real GOsa user but do not have an email address - SKIP adding acls
975        * If user is a real GOsa user with an email address - add acls
976        */
977       $ldap->search("(&(objectClass=person)(|(uid=".$user.")(mail=".$user.")))",array("mail","uid"));
978       if($ldap->count()){
980         /* Has the user a valid mail account? */
981         $attrs = $ldap->fetch();
982         if(isset($attrs['mail'][0])){
984           $name = $attrs[$uattrib][0];
986           /* Do not overwrite manually set ACLs with group member acls 
987           */
988           if(!in_array($name,$acls_set_for)){
989             $this->attrs['acl'][]= $name." ".$acl;
990           }
991           $acls_set_for[] = $name;
992       
994           /* Do not write imap acl directly i nkolab mode, let the kolab deamon do this. */
995           unset($this->imapacl[$user]);
996           if(!preg_match("/olab/i",$this->mmethod)){
997             $this->imapacl[$name] = $acl;
998           }
1000         }else{
1002           /* User is a valid GOsa account, but he has no mail extension. Skip ACLs */
1003           unset($this->imapacl[$user]);
1004         }
1005       }else{
1007         /* Seems to be a manually a added acl
1008          * Write this acl.
1009          */
1011         /* Do not overwrite manually set ACLs with group member acls 
1012          */
1013         if(!in_array($user,$acls_set_for)){
1014           $this->attrs['acl'][]= $user." ".$acl;
1015           $acls_set_for[] = $user;
1016         }
1018         /* In case of kolab methods, let the deamon add the imap acls */
1019         if(preg_match("/olab/i",$this->mmethod)){
1020           unset($this->imapacl[$user]);
1021         }
1022       }
1023     }
1025     /* Handle mail method actions, set acls, quota ...*/
1026     if ((!$this->is_template)&&(!empty($this->gosaMailServer))){
1027       $method= new $this->method($this->config);
1028       $method->fixAttributesOnStore($this);
1029       if (($method->connect($this->gosaMailServer))){
1030         $method->updateMailbox($this->folder_prefix.$this->account_name);
1031         $method->setQuota($this->folder_prefix.$this->account_name, $this->gosaMailQuota);
1033         /* Only write imap acls directly if we are not
1034          *  using a kolab like mail method.
1035          */
1036         if(!preg_match("/olab/i",$this->mmethod)){
1037           $method->setSharedFolderPermissions($this->folder_prefix.$this->account_name, $this->imapacl);
1038         }
1039         $method->disconnect();
1040       }
1041     }
1043     /* Save data to LDAP */
1044     $ldap->cd($this->dn);
1045     $this->cleanup();
1046     $ldap->modify ($this->attrs); 
1047     if (!$ldap->success()){
1048       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
1049     }
1050     
1051     if($this->initially_was_account){
1052       new log("modify","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1053     }else{
1054       new log("create","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());  
1055     }
1056     
1058     /* Optionally execute a command after we're done */
1059     if ($this->initially_was_account == $this->is_account){
1060       if ($this->is_modified){
1061         $this->handle_post_events("modify");
1062       }
1063     } else {
1064       $this->handle_post_events("add");
1065     }
1066   }
1070   /* Check formular input */
1071   function check()
1072   {
1073     $ldap= $this->config->get_ldap_link();
1075     /* Call common method to give check the hook */
1076     $message= plugin::check();
1078     if(!$this->is_account) return array();
1079     
1080     //$message[] = $str;      
1082     /* must: mail */
1083     if ($this->mail == ""){
1084       $message[]= msgPool::required(_("Mail address"));
1085     }
1086     if (!tests::is_email($this->mail)){
1087       $message[]= msgPool::invalid(_("Mail address"),"","",_("your-name@your-domain.com"));
1088     }
1089     $ldap->cd($this->config->current['BASE']);
1090     $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=".
1091         $this->mail."))(!(uid=".$this->orig_cn."))(!(cn=".$this->orig_cn.")))");
1092     if ($ldap->count() != 0){
1093       $message[]= msgPool::duplicated(_("Mail address"));
1094     }
1095   
1096     /* Check quota */
1097     if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){
1098       if (!is_numeric($this->gosaMailQuota)) {
1099         $message[]= msgPool::invalid(_("Quota size"),$this->gosaMailQuota,"/[0-9]/");
1100       } else {
1101         $this->gosaMailQuota= (int) $this->gosaMailQuota;
1102       }
1103     }
1105     /* Check rejectsize for integer */
1106     if ($this->gosaMailMaxSize != '' && $this->acl_is_writeable("gosaMailQuota")){
1107       if (!is_numeric($this->gosaMailMaxSize)){
1108         $message[]= msgPool::invalid(_("Mail max size"));
1109       } else {
1110         $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize;
1111       }
1112     }
1114     /* Need gosaMailMaxSize if use_mailsize_limit is checked */
1115     if (is_integer(strpos($this->gosaMailDeliveryMode, "reject")) && $this->gosaMailMaxSize == ""){
1116       $message[]= _("You need to set the maximum mail size in order to reject anything.");
1117     }
1119     if(ord($this->imapacl['anyone'][0])==194){
1120       $message[] = _("Please choose valid permission settings. Default permission can't be emtpy.");
1121     }
1123     if(empty($this->gosaMailServer)){
1124       $message[] = msgPool::required(_("Mail server"));
1125     }
1127     return ($message);
1128   }
1130   /* Adapt from template, using 'dn' */
1131   function adapt_from_template($dn, $skip= array())
1132   {
1133     plugin::adapt_from_template($dn, $skip);
1135     foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
1136  
1137       if (in_array($val, $skip)){
1138         continue;
1139       }
1141       $this->$val= array();
1142       if (isset($this->attrs["$val"]["count"])){
1143         for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
1144           $value= $this->attrs["$val"][$i];
1145           foreach (array("sn", "givenName", "uid") as $repl){
1146             if (preg_match("/%$repl/i", $value)){
1147               $value= preg_replace ("/%$repl/i", $this->parent->$repl, $value);
1148             }
1149           }
1150           array_push($this->$val, $value);
1151         }
1152       }
1153     }
1154   }
1156   /* Add entry to forwarder list */
1157   function addForwarder($address)
1158   {
1159     $this->gosaMailForwardingAddress[]= $address;
1160     $this->gosaMailForwardingAddress= array_unique($this->gosaMailForwardingAddress);
1162     /* Update multiple edit values too */
1163     if($this->multiple_support_active){
1164       $this->gosaMailForwardingAddress_Some= 
1165         array_remove_entries (array($address),$this->gosaMailForwardingAddress_Some);
1166     }
1168     sort ($this->gosaMailForwardingAddress);
1169     reset ($this->gosaMailForwardingAddress);
1170     $this->is_modified= TRUE;
1171   }
1173   /* Remove list of addresses from forwarder list */
1174   function delForwarder($addresses)
1175   {
1176     $this->gosaMailForwardingAddress= array_remove_entries ($addresses,
1177         $this->gosaMailForwardingAddress);
1179     /* Update multiple edit values too */
1180     if($this->multiple_support_active){
1181       $this->gosaMailForwardingAddress_Some = array_remove_entries ($addresses,
1182           $this->gosaMailForwardingAddress_Some);
1183     }
1184     $this->is_modified= TRUE;
1185   }
1189   function addAlternate($address)
1190   {
1191     $ldap= $this->config->get_ldap_link();
1193     $address= strtolower($address);
1195     /* Is this address already assigned in LDAP? */
1196     $ldap->cd ($this->config->current['BASE']);
1197     $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)".
1198         "(gosaMailAlternateAddress=$address)))");
1200     if ($ldap->count() > 0){
1201       $attrs= $ldap->fetch ();
1202       return ($attrs["uid"][0]);
1203     }
1205     /* Add to list of alternates */
1206     if (!in_array($address, $this->gosaMailAlternateAddress)){
1207       $this->gosaMailAlternateAddress[]= $address;
1208     }
1210     sort ($this->gosaMailAlternateAddress);
1211     reset ($this->gosaMailAlternateAddress);
1212     $this->is_modified= TRUE;
1214     return ("");
1215   }
1218   function delAlternate($addresses)
1219   {
1220     $this->gosaMailAlternateAddress= array_remove_entries ($addresses,
1221         $this->gosaMailAlternateAddress);
1222     $this->is_modified= TRUE;
1223   }
1226   function make_name($attrs)
1227   {
1228     $name= "";
1229     if (isset($attrs['sn'][0])){
1230       $name= $attrs['sn'][0];
1231     }
1232     if (isset($attrs['givenName'][0])){
1233       if ($name != ""){
1234         $name.= ", ".$attrs['givenName'][0];
1235       } else {
1236         $name.= $attrs['givenName'][0];
1237       }
1238     }
1239     if ($name != ""){
1240       $name.= " ";
1241     }
1243     return ($name);
1244   }
1246   function getCopyDialog()
1247   {
1248     if(!$this->is_account) return("");
1250     $smarty = get_smarty();
1251     $smarty->assign("gosaMailAlternateAddress",$this->gosaMailAlternateAddress);
1252     $smarty->assign("gosaMailForwardingAddress",$this->gosaMailForwardingAddress);
1253     $smarty->assign("mail",$this->mail);
1254     $display= $smarty->fetch (get_template_path('paste_mail.tpl', TRUE, dirname(__FILE__)));
1255     $ret = array();
1256     $ret['string'] = $display;
1257     $ret['status'] = "";
1258     return($ret);
1259   }
1261   function saveCopyDialog()
1262   {
1263     if(!$this->is_account) return;
1265     /* Perform ADD / REMOVE ... for mail alternate / mail forwarding addresses 
1266     */
1267     $this->execute();
1268     if(isset($_POST['mail'])){
1269       $this->mail = $_POST['mail'];
1270     }
1271   }
1274   function PrepareForCopyPaste($source)
1275   {
1276     plugin::PrepareForCopyPaste($source);
1277  
1278     /* Reset alternate mail addresses */
1279     $this->gosaMailAlternateAddress = array();
1280   }
1283   /* Return plugin informations for acl handling  */
1284   static function plInfo()
1285   {
1286     return (array(
1287           "plShortName"   => _("Mail"),
1288           "plDescription" => _("Group mail"),
1289           "plSelfModify"  => FALSE,
1290           "plDepends"     => array(),
1291           "plPriority"    => 10,
1292           "plSection"     => array("administration"),
1293           "plCategory"    => array("groups"), 
1294           "plProvidedAcls"=> array(
1295             "mail"                      => _("Mail address"),
1296             "gosaMailQuota"             => _("Quota size"),
1297             "gosaMailServer"            => _("Mail server"),
1298             "kolabFolderType"           => _("Folder type")." ("._("Kolab").")",
1299             "gosaMailAlternateAddress"  => _("Alternate addresses"),
1300             "gosaMailForwardingAddress" => _("Forwarding addresses"),
1301             "gosaMailDeliveryModeI"     => _("Only local"),
1302             "acl"                       => _("Permissions"))
1303           ));
1304   }
1306   
1307   /* Remove given ACL for given member (uid,mail) ..
1308    */
1309   function removeUserAcl($index )
1310   {
1311     if(isset($this->imapacl[$index])){
1312       unset($this->imapacl[$index]);
1313     }
1314   }
1316   function multiple_execute()
1317   {
1318     return($this->execute());
1319   }
1322   function init_multiple_support($attrs,$all)
1323   {
1324     plugin::init_multiple_support($attrs,$all);
1326     $this->gosaMailForwardingAddress = array();
1327     if(isset($attrs['gosaMailForwardingAddress'])){
1328       for($i = 0 ; $i < $attrs['gosaMailForwardingAddress']['count'] ; $i++){
1329         $this->gosaMailForwardingAddress[] = $attrs['gosaMailForwardingAddress'][$i];
1330       }
1331     }
1333     $this->gosaMailForwardingAddress_Some = array();
1334     if(isset($all['gosaMailForwardingAddress'])){
1335       for($i = 0 ; $i < $all['gosaMailForwardingAddress']['count'] ; $i++){
1336         if(!in_array($all['gosaMailForwardingAddress'][$i],$this->gosaMailForwardingAddress)){
1337           $this->gosaMailForwardingAddress_Some[] = $all['gosaMailForwardingAddress'][$i];
1338         }
1339       }
1340     }
1341   }
1343   function multiple_save_object()
1344   {
1345     if(isset($_POST['multiple_mail_group_posted'])){
1346       plugin::multiple_save_object();
1347       
1348       foreach(array("kolabFolderType") as $attr){
1349         if(isset($_POST['use_'.$attr])){
1350           $this->multi_boxes[] = $attr;
1351         }
1352       }
1354       /* Add special kolab attributes */
1355       if(preg_match("/olab/i",$this->config->get_cfg_value("mailmethod"))){
1356         if(isset($_POST['kolabFolderTypeType']) && $this->acl_is_writeable("kolabFolderType")){
1357           $this->kolabFolderTypeType = get_post("kolabFolderTypeType");
1358           $this->kolabFolderTypeSubType = get_post("kolabFolderTypeSubType");
1359         }
1360       }
1362       /* Collect data and re-assign it to the imapacl array */
1363       if ($this->acl_is_writeable("acl")){
1364         $this->imapacl= array();
1365         $this->imapacl['%members%']= $_POST['member_permissions'];
1366         $this->imapacl['anyone']= $_POST['default_permissions'];
1367         foreach ($this->indexed_user as $nr => $user){
1368           if (!isset($_POST["user_$nr"])){
1369             continue;
1370           }
1371           if ($_POST["user_$nr"] != $user ||
1372               $_POST["perm_$nr"] != $this->indexed_acl[$nr]){
1373             $this->is_modified= TRUE;
1374           }
1375           $this->imapacl[$_POST["user_$nr"]]= $_POST["perm_$nr"];
1376         }
1377       }
1378     }
1379   }
1380   
1381   
1382   /* Return selected values for multiple edit */
1383   function get_multi_edit_values()
1384   {
1385     $ret = plugin::get_multi_edit_values();
1386     $ret['Forward_some'] = $this->gosaMailForwardingAddress_Some;    
1387     $ret['Forward_all'] = $this->gosaMailForwardingAddress;    
1388     if(in_array('kolabFolderType',$this->multi_boxes)){
1389       $ret['kolabFolderTypeType'] = $this->kolabFolderTypeType;
1390       $ret['kolabFolderTypeSubType'] = $this->kolabFolderTypeSubType;
1391     }
1392     if(in_array("acl",$this->multi_boxes)){
1393       $ret['imapacl'] = $this->imapacl;
1394     }
1395     return($ret);
1396   }
1398   function set_multi_edit_values($attrs)
1399   {
1400     $forward = array();
1401     foreach($attrs['Forward_some'] as $addr){
1402       if(in_array($addr,$this->gosaMailForwardingAddress)){
1403         $forward[] = $addr;
1404       }
1405     }
1406     foreach($attrs['Forward_all'] as $addr){
1407       $forward[] = $addr;
1408     }
1409     plugin::set_multi_edit_values($attrs);
1410     $this->gosaMailForwardingAddress = $forward;
1411   }
1414   // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1415 ?>