520eade9e339621ed2d2d85517e90362da523012
1 <?php
3 class mailgroup extends plugin
4 {
5 /* CLI vars */
6 var $cli_summary= "Manage mail groups/shared folders";
7 var $cli_description= "Some longer text\nfor help";
8 var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
9 var $method= "mailMethod";
11 /* plugin specific values */
12 var $mail= "";
13 var $uid= "";
14 var $cn= "";
15 var $gosaMailAlternateAddress= array();
16 var $gosaMailForwardingAddress= array();
17 var $gosaMailDeliveryMode= "[L ]";
18 var $gosaMailServer= "";
19 var $gosaMailQuota= "";
20 var $gosaMailMaxSize= "";
21 var $gosaVacationMessage= "";
22 var $gosaSpamSortLevel= "";
23 var $gosaSpamMailbox= "";
25 var $quotaUsage= 0;
26 var $forward_dialog= FALSE;
27 var $members= array();
28 var $mailusers= array();
29 var $perms= array();
30 var $imapacl= array('anyone' => 'p', '%members%' => 'lrsp', '' => 'p');
32 /* Helper */
33 var $indexed_acl= array();
34 var $indexed_user= array();
36 /* attribute list for save action */
37 var $attributes= array("mail", "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize",
38 "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox",
39 "gosaVacationMessage");
40 var $objectclasses= array("gosaMailAccount");
43 /* constructor, if 'dn' is set, the node loads the given
44 'dn' from LDAP */
45 function mailgroup ($config, $dn= NULL, $ui= NULL)
46 {
47 /* Configuration is fine, allways */
48 $this->config= $config;
50 /* Load bases attributes */
51 plugin::plugin($config, $dn);
53 /* Set mailMethod to the one defined in gosa.conf */
54 if (isset($this->config->current['MAILMETHOD'])){
55 $method= $this->config->current['MAILMETHOD'];
56 if (class_exists("mailMethod$method")){
57 $this->method= "mailMethod$method";
58 } else {
59 print_red(sprintf(_("There is no mail method '%s' specified in your gosa.conf available."), $method));
60 }
61 }
63 /* Convert cn to uid in case of existing entries */
64 if (isset($this->attrs['cn'][0])){
65 $this->uid= $this->attrs['cn'][0];
66 }
68 if ($dn != NULL){
70 /* Load attributes containing arrays */
71 foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
72 if (isset($this->attrs["$val"]["count"])){
73 for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
74 array_push($this->$val, $this->attrs["$val"][$i]);
75 }
76 }
77 }
79 /* Only do IMAP actions if gosaMailServer attribute is set */
80 if (isset ($this->attrs["gosaMailServer"][0])){
81 $method= new $this->method($this->config);
82 if ($method->connect($this->attrs["gosaMailServer"][0])){
83 $quota= $method->getQuota($this->uid);
85 /* Maybe the entry is not saved in new style, get
86 permissions from IMAP and convert them to acl attributes */
87 if (!isset($this->attrs['acl'])){
88 $this->imapacl= $method->getSharedFolderPermissions($this->uid);
90 /* Need to filter what a member acl could be... */
91 $vote= array();
92 $peak= 0;
93 $leader= "";
94 foreach ($this->imapacl as $user => $acl){
96 if ($user != "anyone" ){
97 if (!isset($vote[$acl])){
98 $vote[$acl]= 1;
99 } else {
100 $vote[$acl]++;
101 }
102 if ($vote[$acl] > $peak){
103 $leader= $acl;
104 $peek= $vote[$acl];
105 }
106 }
108 }
110 /* Highest count wins as %members%, remove all members
111 with the same acl */
112 $this->imapacl['%members%']= $leader;
113 foreach ($this->imapacl as $user => $acl){
114 if ($this->acl == $leader && in_array($user, $this->attrs['memberUid'])){
115 unset($this->imapacl[$user]);
116 }
117 }
119 }
121 /* Update quota values */
122 $this->quotaUsage= $quota['quotaUsage'];
123 $this->gosaMailQuota= $quota['gosaMailQuota'];
124 $method->disconnect();
125 }
127 }
129 }
131 /* Get global filter config */
132 if (!is_global("gmailfilter")){
133 $ui= get_userinfo();
134 $base= get_base_from_people($ui->dn);
135 $gmailfilter= array( "depselect" => $base,
136 "muser" => "",
137 "regex" => "*");
138 register_global("gmailfilter", $gmailfilter);
139 }
141 /* Load permissions */
142 if (isset($this->attrs['acl'])){
143 for ($i= 0; $i<$this->attrs['acl']['count']; $i++){
144 list($user, $permission)= split(' ', $this->attrs['acl'][$i]);
145 $this->imapacl[$user]= $permission;
146 if ($user != "anyone" && $user != "%members%"){
147 unset($this->imapacl['']);
148 }
149 }
150 }
152 /* Fill translations */
153 $this->perms["lrs"]= _("read");
154 $this->perms["lrsp"]= _("post");
155 $this->perms["p"]= _("external post");
156 $this->perms["lrsip"]= _("append");
157 $this->perms["lrswipcd"]= _("write");
158 }
161 function execute()
162 {
163 /* Call parent execute */
164 plugin::execute();
166 /* Load templating engine */
167 $smarty= get_smarty();
168 if ($_SESSION['js']==FALSE){
169 $smarty->assign("javascript", "false");
170 } else {
171 $smarty->assign("javascript", "true");
172 }
174 /* Do we need to flip is_account state? */
175 if (isset($_POST['modify_state'])){
176 $this->is_account= !$this->is_account;
177 }
179 /* Do we represent a valid account? */
180 if (!$this->is_account && $this->parent == NULL){
181 $display= "<img alt=\"\" src=\"images/stop.png\" align=middle> <b>".
182 _("This 'dn' has no valid mail extensions.")."</b>";
183 return ($display);
184 }
186 /* Show tab dialog headers */
187 $display= "";
188 if ($this->parent != NULL){
189 if ($this->is_account){
190 $display= $this->show_header(_("Remove mail account"),
191 _("This account has mail features enabled. You can disable them by clicking below."));
192 } else {
193 $display= $this->show_header(_("Create mail account"),
194 _("This account has mail features disabled. You can enable them by clicking below."));
195 return ($display);
196 }
197 }
199 /* Add ACL? */
200 foreach ($this->indexed_user as $nr => $user){
201 if (isset($_POST["add_$nr"])){
202 $this->imapacl[""]= "l";
203 }
204 if (isset($_POST["del_$nr"])){
205 unset ($this->imapacl[$user]);
206 }
207 }
209 /* Trigger forward add dialog? */
210 if (isset($_POST['add_local_forwarder'])){
211 $this->forward_dialog= TRUE;
212 $this->dialog= TRUE;
213 }
215 /* Cancel forward add dialog? */
216 if (isset($_POST['add_locals_cancel'])){
217 $this->forward_dialog= FALSE;
218 $this->dialog= FALSE;
219 }
221 /* Finished adding of locals? */
222 if (isset($_POST['add_locals_finish'])){
223 if (count ($_POST['local_list']) &&
224 chkacl ($this->acl, "gosaMailForwardingAddress") == ""){
226 /* Walk through list of forwarders, ignore own addresses */
227 foreach ($_POST['local_list'] as $val){
228 if (!in_array ($val, $this->gosaMailAlternateAddress) &&
229 $val != $this->mail){
231 $this->addForwarder($val);
232 }
233 }
234 }
235 $this->forward_dialog= FALSE;
236 $this->dialog= FALSE;
237 }
239 /* Add forward email addresses */
240 if (isset($_POST['add_forwarder'])){
241 if ($_POST['forward_address'] != ""){
243 /* Valid email address specified? */
244 $address= $_POST['forward_address'];
245 if (!is_email($address)){
247 print_red (_("You're trying to add an invalid email address ".
248 "to the list of forwarders."));
250 } elseif ($address == $this->mail
251 || in_array($address, $this->gosaMailAlternateAddress)) {
253 print_red (_("Adding your one of your own addresses to the forwarders makes no sense."));
255 } else {
257 /* Add it */
258 if (chkacl ($this->acl, "gosaMailForwardingAddress") == ""){
259 $this->addForwarder ($address);
260 }
262 }
263 }
264 }
266 /* Delete forward email addresses */
267 if (isset($_POST['delete_forwarder'])){
268 if (count($_POST['forwarder_list'])
269 && chkacl ($this->acl, "gosaMailForwardingAddress") == ""){
271 $this->delForwarder ($_POST['forwarder_list']);
272 }
273 }
275 /* Add alternate email addresses */
276 if (isset($_POST['add_alternate'])){
277 if ($_POST['alternate_address'] != "" &&
278 chkacl ($this->acl, "gosaMailAlternateAddress") == ""){
280 if (!is_email($_POST['alternate_address'])){
281 print_red (_("You're trying to add an invalid email address to the list of alternate addresses."));
283 } elseif (($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
284 $ui= get_userinfo();
285 if ($user != $ui->username){
286 print_red (_("The address you're trying to add is already used by user")." '$user'.");
287 }
288 }
289 }
290 }
292 /* Delete alternate email addresses */
293 if (isset($_POST['delete_alternate']) && isset ($_POST['alternates_list'])){
294 if (count($_POST['alternates_list']) &&
295 chkacl ($this->acl, "gosaMailAlternateAddress") == ""){
297 $this->delAlternate ($_POST['alternates_list']);
298 }
299 }
301 /* Show forward add dialog */
302 if ($this->forward_dialog){
303 $ldap= $this->config->get_ldap_link();
305 /* Save data */
306 $gmailfilter= get_global("gmailfilter");
307 foreach( array("depselect", "muser", "regex") as $type){
308 if (isset($_POST[$type])){
309 $gmailfilter[$type]= $_POST[$type];
310 }
311 }
312 if (isset($_GET['search'])){
313 $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
314 if ($s == "**"){
315 $s= "*";
316 }
317 $gmailfilter['regex']= $s;
318 }
319 register_global("gmailfilter", $gmailfilter);
321 /* Get actual list */
322 $mailusers= array ();
323 if ($gmailfilter['regex'] != '*' && $gmailfilter['regex'] != ""){
324 $regex= $gmailfilter['regex'];
325 $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))";
326 } else {
327 $filter= "";
328 }
329 if ($gmailfilter['muser'] != ""){
330 $user= $gmailfilter['muser'];
331 $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))";
332 }
334 /* Add already present people to the filter */
335 $exclude= "";
336 foreach ($this->gosaMailForwardingAddress as $mail){
337 $exclude.= "(mail=$mail)";
338 }
339 if ($exclude != ""){
340 $filter.= "(!(|$exclude))";
341 }
343 $acl= array($this->config->current['BASE'] => ":all");
344 $res= get_list($acl, "(&(objectClass=gosaMailAccount)$filter)", TRUE, $gmailfilter['depselect'], array("sn", "mail", "givenName"), TRUE);
345 $ldap->cd($gmailfilter['depselect']);
346 $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName"));
347 error_reporting (0);
348 while ($attrs= $ldap->fetch()){
349 if(preg_match('/%/', $attrs['mail'][0])){
350 continue;
351 }
352 $name= $this->make_name($attrs);
353 $mailusers[$attrs['mail'][0]]= $name."<".
354 $attrs['mail'][0].">";
355 }
356 error_reporting (E_ALL);
357 natcasesort ($mailusers);
358 reset ($mailusers);
360 /* Show dialog */
361 $smarty->assign("search_image", get_template_path('images/search.png'));
362 $smarty->assign("tree_image", get_template_path('images/tree.png'));
363 $smarty->assign("infoimage", get_template_path('images/info.png'));
364 $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
365 $smarty->assign("mailusers", $mailusers);
366 $smarty->assign("deplist", $this->config->idepartments);
367 $smarty->assign("apply", apply_filter());
368 $smarty->assign("alphabet", generate_alphabet());
369 $smarty->assign("hint", print_sizelimit_warning());
370 foreach( array("depselect", "muser", "regex") as $type){
371 $smarty->assign("$type", $gmailfilter[$type]);
372 }
373 $smarty->assign("hint", print_sizelimit_warning());
374 $display.= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE));
375 return ($display);
376 }
378 /* Assemble normal permissions */
379 $smarty->assign("permissionsACL", chkacl($this->acl, "permissions"));
380 if (isset($this->imapacl['anyone'])){
381 $smarty->assign("default_permissions", $this->imapacl['anyone']);
382 }
383 if (isset($this->imapacl['%members%'])){
384 $smarty->assign("member_permissions", $this->imapacl['%members%']);
385 }
387 /* Assemble extra attributes */
388 $perm= chkacl($this->acl, "permissions");
389 $tmp= "";
390 $nr= 0;
391 $count= count($this->imapacl);
392 $this->indexed_user= array();
393 $this->indexed_acl= array();
394 foreach($this->imapacl as $user => $acl){
395 if ($user != "anyone" && $user != "%members%"){
396 $tmp.= "<tr><td><input name=\"user_$nr\" size=20 maxlength=60 ".
397 "value=\"$user\" $perm></td><td><select size=\"1\" name=\"perm_$nr\" $perm>";
398 foreach ($this->perms as $key => $value){
399 if ($acl == $key){
400 $tmp.= "<option value=$key selected>$value</option>";
401 } else {
402 $tmp.= "<option value=$key>$value</option>";
403 }
404 }
405 $tmp.= "</select> ";
406 if ($nr == $count - 1){
407 $tmp.= "<input type=submit value=\""._("Add")."\" ".
408 "name=\"add_$nr\" $perm>";
409 }
410 if ($count > 3){
411 $tmp.= "<input type=submit value=\""._("Remove")."\" ".
412 "name=\"del_$nr\" $perm></td></tr>";
413 }
414 }
415 $this->indexed_user[$nr]= $user;
416 $this->indexed_acl[$nr++]= $acl;
417 }
418 $smarty->assign("plusattributes", $tmp);
420 /* Show main page */
421 $mailserver= array();
422 foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){
423 $mailserver[]= $key;
424 }
425 $smarty->assign("mailServers", $mailserver);
426 foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail",
427 "gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
428 $smarty->assign("$val", $this->$val);
429 $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
430 }
431 if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){
432 $smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota,100,15,true)));
433 $smarty->assign("quotadefined", "true");
434 } else {
435 $smarty->assign("quotadefined", "false");
436 }
438 $display.= $smarty->fetch (get_template_path('mail.tpl', TRUE));
439 return ($display);
440 }
443 /* remove object from parent */
444 function remove_from_parent()
445 {
446 /* include global link_info */
447 $ldap= $this->config->get_ldap_link();
449 /* Remove and write to LDAP */
450 plugin::remove_from_parent();
452 /* Zero arrays */
453 $this->attrs['gosaMailAlternateAddress']= array();
454 $this->attrs['gosaMailForwardingAddress']= array();
455 $this->attrs['gosaSharedFolderTarget']= array();
457 /* Keep uid */
458 unset ($this->attrs['uid']);
459 $ldap->cd($this->dn);
460 $ldap->modify($this->attrs);
461 show_ldap_error($ldap->get_error());
463 /* Connect to IMAP server for account deletion */
464 if ($this->is_account){
465 $method= new $this->method($this->config);
466 if ($method->connect($this->attrs["gosaMailServer"][0])){
467 /* Remove account from IMAP server */
468 $method->deleteMailbox($this->uid);
469 $method->disconnect();
470 }
471 }
473 /* Optionally execute a command after we're done */
474 $this->handle_post_events("remove");
475 }
478 /* Save data to object */
479 function save_object()
480 {
481 /* Assemble mail delivery mode
482 The mode field in ldap consists of values between braces, this must
483 be called when 'mail' is set, because checkboxes may not be set when
484 we're in some other dialog.
486 Example for gosaMailDeliveryMode [LR ]
487 L: Local delivery
488 R: Reject when exceeding mailsize limit
489 S: Use spam filter
490 V: Use vacation message
491 C: Use custom sieve script
492 I: Only insider delivery */
493 if (isset($_POST['mailedit'])){
495 /* Save ldap attributes */
496 plugin::save_object();
498 $tmp= "";
499 if (!isset($_POST["drop_own_mails"])){
500 $tmp.= "L";
501 }
502 if (isset($_POST["use_mailsize_limit"])){
503 $tmp.= "R";
504 }
505 if (isset($_POST["use_spam_filter"])){
506 $tmp.= "S";
507 }
508 if (isset($_POST["use_vacation"])){
509 $tmp.= "V";
510 }
511 if (isset($_POST["own_script"])){
512 $tmp.= "C";
513 }
514 if (isset($_POST["only_local"])){
515 $tmp.= "I";
516 }
517 $tmp= "[$tmp]";
519 if (chkacl ($this->acl, "gosaMailDeliveryMode") == ""){
520 $this->gosaMailDeliveryMode= $tmp;
521 }
523 /* Collect data and re-assign it to the imapacl array */
524 if (chkacl($this->acl, "permissions") == ""){
525 $this->imapacl= array();
526 $this->imapacl['%members%']= $_POST['member_permissions'];
527 $this->imapacl['anyone']= $_POST['default_permissions'];
528 foreach ($this->indexed_user as $nr => $user){
529 if (!isset($_POST["user_$nr"])){
530 continue;
531 }
532 if ($_POST["user_$nr"] != $user ||
533 $_POST["perm_$nr"] != $this->indexed_acl[$nr]){
534 $this->is_modified= TRUE;
535 }
536 $this->imapacl[$_POST["user_$nr"]]= $_POST["perm_$nr"];
537 }
538 }
539 }
541 }
544 /* Save data to LDAP, depending on is_account we save or delete */
545 function save()
546 {
547 $ldap= $this->config->get_ldap_link();
549 /* Call parents save to prepare $this->attrs */
550 plugin::save();
552 /* Save arrays */
553 $this->attrs['gosaMailAlternateAddress']= $this->gosaMailAlternateAddress;
554 $this->attrs['gosaMailForwardingAddress']= $this->gosaMailForwardingAddress;
556 /* Save shared folder target */
557 $this->attrs['gosaSharedFolderTarget']= "share+".$this->uid;
559 /* Save acl's */
560 $this->attrs['acl']= array();
561 foreach ($this->imapacl as $user => $acl){
562 if ($user == ""){
563 continue;
564 }
565 $this->attrs['acl'][]= "$user $acl";
566 }
568 /* Save data to LDAP */
569 $ldap->cd($this->dn);
570 $ldap->modify($this->attrs);
571 show_ldap_error($ldap->get_error());
573 /* Only do IMAP actions if we are not a template */
574 if (!$this->is_template){
575 $method= new $this->method($this->config);
576 if ($method->connect($this->gosaMailServer)){
577 $method->updateMailbox($this->uid);
578 $method->setQuota($this->uid, $this->gosaMailQuota);
580 /* Exchange '%member%' pseudo entry */
581 $memberacl= $this->imapacl['%members%'];
582 unset ($this->imapacl['%members%']);
583 foreach ($this->members as $user){
584 if (!isset($this->imapacl[$user])){
585 $this->imapacl[$user]= $memberacl;
586 }
587 }
589 $method->setSharedFolderPermissions($this->uid, $this->imapacl);
590 $method->disconnect();
591 }
592 }
594 /* Optionally execute a command after we're done */
595 if ($this->initially_was_account == $this->is_account){
596 if ($this->is_modified){
597 $this->handle_post_events("mofify");
598 }
599 } else {
600 $this->handle_post_events("add");
601 }
602 }
604 /* Check formular input */
605 function check()
606 {
607 $ldap= $this->config->get_ldap_link();
609 $message= array();
611 /* must: mail */
612 if ($this->mail == ""){
613 $message[]= _("The required field 'Primary address' is not set.");
614 }
615 if (!is_email($this->mail)){
616 $message[]= _("Please enter a valid email addres in 'Primary address' field.");
617 }
618 $ldap->cd($this->config->current['BASE']);
619 $ldap->search ("(&(!(objectClass=gosaUserTemplate))(|(mail=".$this->mail.")(gosaMailAlternateAddress=".
620 $this->mail."))(!(uid=".$this->cn."))(!(cn=".$this->cn.")))");
621 if ($ldap->count() != 0){
622 $message[]= _("The primary address you've entered is already in use.");
623 }
625 /* Check quota */
626 if ($this->gosaMailQuota != '' && chkacl ($this->acl, "gosaMailQuota") == ""){
627 if (!is_numeric($this->gosaMailQuota)) {
628 $message[]= _("Value in 'Quota size' is not valid.");
629 } else {
630 $this->gosaMailQuota= (int) $this->gosaMailQuota;
631 }
632 }
634 /* Check rejectsize for integer */
635 if ($this->gosaMailMaxSize != '' && chkacl ($this->acl, "gosaMailQuota") == ""){
636 if (!is_numeric($this->gosaMailMaxSize)){
637 $message[]= _("Please specify a vaild mail size for mails to be rejected.");
638 } else {
639 $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize;
640 }
641 }
643 /* Need gosaMailMaxSize if use_mailsize_limit is checked */
644 if (is_integer(strpos($this->gosaMailDeliveryMode, "reject")) && $this->gosaMailMaxSize == ""){
645 $message[]= _("You need to set the maximum mail size in order to reject anything.");
646 }
648 if(ord($this->imapacl['anyone'][0])==194){
649 $message[] = _("Please choose valid permission settings. Default permission can't be emtpy.");
650 }
652 if(empty($this->gosaMailServer)){
653 $message[] = _("Please select a valid mail server.");
654 }
656 return ($message);
657 }
659 /* Adapt from template, using 'dn' */
660 function adapt_from_template($dn)
661 {
662 plugin::adapt_from_template($dn);
664 foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
665 $this->$val= array();
666 if (isset($this->attrs["$val"]["count"])){
667 for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
668 $value= $this->attrs["$val"][$i];
669 foreach (array("sn", "givenName", "uid") as $repl){
670 if (preg_match("/%$repl/i", $value)){
671 $value= preg_replace ("/%$repl/i", $this->parent->$repl, $value);
672 }
673 }
674 array_push($this->$val, $value);
675 }
676 }
677 }
678 }
680 /* Add entry to forwarder list */
681 function addForwarder($address)
682 {
683 $this->gosaMailForwardingAddress[]= $address;
684 $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress);
686 sort ($this->gosaMailForwardingAddress);
687 reset ($this->gosaMailForwardingAddress);
688 $this->is_modified= TRUE;
689 }
691 /* Remove list of addresses from forwarder list */
692 function delForwarder($addresses)
693 {
694 $this->gosaMailForwardingAddress= array_remove_entries ($addresses,
695 $this->gosaMailForwardingAddress);
696 $this->is_modified= TRUE;
697 }
701 function addAlternate($address)
702 {
703 $ldap= $this->config->get_ldap_link();
705 $address= strtolower($address);
707 /* Is this address already assigned in LDAP? */
708 $ldap->cd ($this->config->current['BASE']);
709 $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)".
710 "(gosaMailAlternateAddress=$address)))");
712 if ($ldap->count() > 0){
713 $attrs= $ldap->fetch ();
714 return ($attrs["uid"][0]);
715 }
717 /* Add to list of alternates */
718 if (!in_array($address, $this->gosaMailAlternateAddress)){
719 $this->gosaMailAlternateAddress[]= $address;
720 }
722 sort ($this->gosaMailAlternateAddress);
723 reset ($this->gosaMailAlternateAddress);
724 $this->is_modified= TRUE;
726 return ("");
727 }
730 function delAlternate($addresses)
731 {
732 $this->gosaMailAlternateAddress= array_remove_entries ($addresses,
733 $this->gosaMailAlternateAddress);
734 $this->is_modified= TRUE;
735 }
738 function make_name($attrs)
739 {
740 $name= "";
741 if (isset($attrs['sn'][0])){
742 $name= $attrs['sn'][0];
743 }
744 if (isset($attrs['givenName'][0])){
745 if ($name != ""){
746 $name.= ", ".$attrs['givenName'][0];
747 } else {
748 $name.= $attrs['givenName'][0];
749 }
750 }
751 if ($name != ""){
752 $name.= " ";
753 }
755 return ($name);
756 }
758 }
760 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
761 ?>