f7744376383a24247d20379ec9bb82c810835ec2
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 if ($quota['gosaMailQuota'] == 2147483647){
123 $this->quotaUsage= "";
124 $this->gosaMailQuota= "";
125 } else {
126 $this->quotaUsage= $quota['quotaUsage'];
127 $this->gosaMailQuota= $quota['gosaMailQuota'];
128 }
129 $method->disconnect();
130 }
132 }
134 /* Adapt attributes if needed */
135 $method->fixAttributesOnLoad($this);
136 }
138 /* Get global filter config */
139 if (!is_global("gmailfilter")){
140 $ui= get_userinfo();
141 $base= get_base_from_people($ui->dn);
142 $gmailfilter= array( "depselect" => $base,
143 "muser" => "",
144 "regex" => "*");
145 register_global("gmailfilter", $gmailfilter);
146 }
148 /* Load permissions */
149 if (isset($this->attrs['acl'])){
150 for ($i= 0; $i<$this->attrs['acl']['count']; $i++){
151 list($user, $permission)= split(' ', $this->attrs['acl'][$i]);
152 $this->imapacl[$user]= $permission;
153 if ($user != "anyone" && $user != "%members%"){
154 unset($this->imapacl['']);
155 }
156 }
157 }
159 /* Fill translations */
160 $this->perms["lrs"]= _("read");
161 $this->perms["lrsp"]= _("post");
162 $this->perms["p"]= _("external post");
163 $this->perms["lrsip"]= _("append");
164 $this->perms["lrswipcd"]= _("write");
165 }
168 function execute()
169 {
170 /* Call parent execute */
171 plugin::execute();
173 /* Load templating engine */
174 $smarty= get_smarty();
175 if ($_SESSION['js']==FALSE){
176 $smarty->assign("javascript", "false");
177 } else {
178 $smarty->assign("javascript", "true");
179 }
181 /* Do we need to flip is_account state? */
182 if (isset($_POST['modify_state'])){
183 $this->is_account= !$this->is_account;
184 }
186 /* Do we represent a valid account? */
187 if (!$this->is_account && $this->parent == NULL){
188 $display= "<img alt=\"\" src=\"images/stop.png\" align=middle> <b>".
189 _("This 'dn' has no valid mail extensions.")."</b>";
190 return ($display);
191 }
193 /* Show tab dialog headers */
194 $display= "";
195 if ($this->parent != NULL){
196 if ($this->is_account){
197 $display= $this->show_header(_("Remove mail account"),
198 _("This account has mail features enabled. You can disable them by clicking below."));
199 } else {
200 $display= $this->show_header(_("Create mail account"),
201 _("This account has mail features disabled. You can enable them by clicking below."));
202 return ($display);
203 }
204 }
206 /* Add ACL? */
207 foreach ($this->indexed_user as $nr => $user){
208 if (isset($_POST["add_$nr"])){
209 $this->imapacl[""]= "l";
210 }
211 if (isset($_POST["del_$nr"])){
212 unset ($this->imapacl[$user]);
213 }
214 }
216 /* Trigger forward add dialog? */
217 if (isset($_POST['add_local_forwarder'])){
218 $this->forward_dialog= TRUE;
219 $this->dialog= TRUE;
220 }
222 /* Cancel forward add dialog? */
223 if (isset($_POST['add_locals_cancel'])){
224 $this->forward_dialog= FALSE;
225 $this->dialog= FALSE;
226 }
228 /* Finished adding of locals? */
229 if (isset($_POST['add_locals_finish'])){
230 if (count ($_POST['local_list']) &&
231 chkacl ($this->acl, "gosaMailForwardingAddress") == ""){
233 /* Walk through list of forwarders, ignore own addresses */
234 foreach ($_POST['local_list'] as $val){
235 if (!in_array ($val, $this->gosaMailAlternateAddress) &&
236 $val != $this->mail){
238 $this->addForwarder($val);
239 }
240 }
241 }
242 $this->forward_dialog= FALSE;
243 $this->dialog= FALSE;
244 }
246 /* Add forward email addresses */
247 if (isset($_POST['add_forwarder'])){
248 if ($_POST['forward_address'] != ""){
250 /* Valid email address specified? */
251 $address= $_POST['forward_address'];
252 if (!is_email($address)){
254 print_red (_("You're trying to add an invalid email address ".
255 "to the list of forwarders."));
257 } elseif ($address == $this->mail
258 || in_array($address, $this->gosaMailAlternateAddress)) {
260 print_red (_("Adding your one of your own addresses to the forwarders makes no sense."));
262 } else {
264 /* Add it */
265 if (chkacl ($this->acl, "gosaMailForwardingAddress") == ""){
266 $this->addForwarder ($address);
267 }
269 }
270 }
271 }
273 /* Delete forward email addresses */
274 if (isset($_POST['delete_forwarder'])){
275 if (count($_POST['forwarder_list'])
276 && chkacl ($this->acl, "gosaMailForwardingAddress") == ""){
278 $this->delForwarder ($_POST['forwarder_list']);
279 }
280 }
282 /* Add alternate email addresses */
283 if (isset($_POST['add_alternate'])){
284 if ($_POST['alternate_address'] != "" &&
285 chkacl ($this->acl, "gosaMailAlternateAddress") == ""){
287 if (!is_email($_POST['alternate_address'])){
288 print_red (_("You're trying to add an invalid email address to the list of alternate addresses."));
290 } elseif (($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
291 $ui= get_userinfo();
292 if ($user != $ui->username){
293 print_red (_("The address you're trying to add is already used by user")." '$user'.");
294 }
295 }
296 }
297 }
299 /* Delete alternate email addresses */
300 if (isset($_POST['delete_alternate']) && isset ($_POST['alternates_list'])){
301 if (count($_POST['alternates_list']) &&
302 chkacl ($this->acl, "gosaMailAlternateAddress") == ""){
304 $this->delAlternate ($_POST['alternates_list']);
305 }
306 }
308 /* Show forward add dialog */
309 if ($this->forward_dialog){
310 $ldap= $this->config->get_ldap_link();
312 /* Save data */
313 $gmailfilter= get_global("gmailfilter");
314 foreach( array("depselect", "muser", "regex") as $type){
315 if (isset($_POST[$type])){
316 $gmailfilter[$type]= $_POST[$type];
317 }
318 }
319 if (isset($_GET['search'])){
320 $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
321 if ($s == "**"){
322 $s= "*";
323 }
324 $gmailfilter['regex']= $s;
325 }
326 register_global("gmailfilter", $gmailfilter);
328 /* Get actual list */
329 $mailusers= array ();
330 if ($gmailfilter['regex'] != '*' && $gmailfilter['regex'] != ""){
331 $regex= $gmailfilter['regex'];
332 $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))";
333 } else {
334 $filter= "";
335 }
336 if ($gmailfilter['muser'] != ""){
337 $user= $gmailfilter['muser'];
338 $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))";
339 }
341 /* Add already present people to the filter */
342 $exclude= "";
343 foreach ($this->gosaMailForwardingAddress as $mail){
344 $exclude.= "(mail=$mail)";
345 }
346 if ($exclude != ""){
347 $filter.= "(!(|$exclude))";
348 }
350 $acl= array($this->config->current['BASE'] => ":all");
351 $res= get_list($acl, "(&(objectClass=gosaMailAccount)$filter)", TRUE, $gmailfilter['depselect'], array("sn", "mail", "givenName"), TRUE);
352 $ldap->cd($gmailfilter['depselect']);
353 $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName"));
354 error_reporting (0);
355 while ($attrs= $ldap->fetch()){
356 if(preg_match('/%/', $attrs['mail'][0])){
357 continue;
358 }
359 $name= $this->make_name($attrs);
360 $mailusers[$attrs['mail'][0]]= $name."<".
361 $attrs['mail'][0].">";
362 }
363 error_reporting (E_ALL);
364 natcasesort ($mailusers);
365 reset ($mailusers);
367 /* Show dialog */
368 $smarty->assign("search_image", get_template_path('images/search.png'));
369 $smarty->assign("usearch_image", get_template_path('images/search_user.png'));
370 $smarty->assign("tree_image", get_template_path('images/tree.png'));
371 $smarty->assign("infoimage", get_template_path('images/info.png'));
372 $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
373 $smarty->assign("mailusers", $mailusers);
374 $smarty->assign("deplist", $this->config->idepartments);
375 $smarty->assign("apply", apply_filter());
376 $smarty->assign("alphabet", generate_alphabet());
377 $smarty->assign("hint", print_sizelimit_warning());
378 foreach( array("depselect", "muser", "regex") as $type){
379 $smarty->assign("$type", $gmailfilter[$type]);
380 }
381 $smarty->assign("hint", print_sizelimit_warning());
382 $display.= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE));
383 return ($display);
384 }
386 /* Assemble normal permissions */
387 $smarty->assign("permissionsACL", chkacl($this->acl, "permissions"));
388 if (isset($this->imapacl['anyone'])){
389 $smarty->assign("default_permissions", $this->imapacl['anyone']);
390 }
391 if (isset($this->imapacl['%members%'])){
392 $smarty->assign("member_permissions", $this->imapacl['%members%']);
393 }
395 /* Assemble extra attributes */
396 $perm= chkacl($this->acl, "permissions");
397 $tmp= "";
398 $nr= 0;
399 $count= count($this->imapacl);
400 $this->indexed_user= array();
401 $this->indexed_acl= array();
402 foreach($this->imapacl as $user => $acl){
403 if ($user != "anyone" && $user != "%members%"){
404 $tmp.= "<tr><td><input name=\"user_$nr\" size=20 maxlength=60 ".
405 "value=\"$user\" $perm></td><td><select size=\"1\" name=\"perm_$nr\" $perm>";
406 foreach ($this->perms as $key => $value){
407 if ($acl == $key){
408 $tmp.= "<option value=$key selected>$value</option>";
409 } else {
410 $tmp.= "<option value=$key>$value</option>";
411 }
412 }
413 $tmp.= "</select> ";
414 if ($nr == $count - 1){
415 $tmp.= "<input type=submit value=\""._("Add")."\" ".
416 "name=\"add_$nr\" $perm>";
417 }
418 if ($count > 3){
419 $tmp.= "<input type=submit value=\""._("Remove")."\" ".
420 "name=\"del_$nr\" $perm></td></tr>";
421 }
422 }
423 $this->indexed_user[$nr]= $user;
424 $this->indexed_acl[$nr++]= $acl;
425 }
426 $smarty->assign("plusattributes", $tmp);
428 /* Show main page */
429 $mailserver= array();
430 foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){
431 $mailserver[]= $key;
432 }
433 $smarty->assign("mailServers", $mailserver);
434 foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail",
435 "gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
436 $smarty->assign("$val", $this->$val);
437 $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
438 }
439 if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){
440 $smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota,100,15,true)));
441 $smarty->assign("quotadefined", "true");
442 } else {
443 $smarty->assign("quotadefined", "false");
444 }
446 $display.= $smarty->fetch (get_template_path('mail.tpl', TRUE));
447 return ($display);
448 }
451 /* remove object from parent */
452 function remove_from_parent()
453 {
454 /* include global link_info */
455 $ldap= $this->config->get_ldap_link();
457 /* Remove and write to LDAP */
458 plugin::remove_from_parent();
460 /* Zero arrays */
461 $this->attrs['gosaMailAlternateAddress']= array();
462 $this->attrs['gosaMailForwardingAddress']= array();
463 $this->attrs['gosaSharedFolderTarget']= array();
465 /* Keep uid */
466 unset ($this->attrs['uid']);
467 $ldap->cd($this->dn);
468 $ldap->modify($this->attrs);
469 show_ldap_error($ldap->get_error());
471 /* Connect to IMAP server for account deletion */
472 if ($this->is_account){
473 $method= new $this->method($this->config);
474 if ($method->connect($this->attrs["gosaMailServer"][0])){
475 /* Remove account from IMAP server */
476 $method->deleteMailbox($this->uid);
477 $method->disconnect();
478 }
479 $method->fixAttributesOnRemove($this);
480 }
482 /* Optionally execute a command after we're done */
483 $this->handle_post_events("remove");
484 }
487 /* Save data to object */
488 function save_object()
489 {
490 /* Assemble mail delivery mode
491 The mode field in ldap consists of values between braces, this must
492 be called when 'mail' is set, because checkboxes may not be set when
493 we're in some other dialog.
495 Example for gosaMailDeliveryMode [LR ]
496 L: Local delivery
497 R: Reject when exceeding mailsize limit
498 S: Use spam filter
499 V: Use vacation message
500 C: Use custom sieve script
501 I: Only insider delivery */
502 if (isset($_POST['mailedit'])){
504 /* Save ldap attributes */
505 plugin::save_object();
507 $tmp= "";
508 if (!isset($_POST["drop_own_mails"])){
509 $tmp.= "L";
510 }
511 if (isset($_POST["use_mailsize_limit"])){
512 $tmp.= "R";
513 }
514 if (isset($_POST["use_spam_filter"])){
515 $tmp.= "S";
516 }
517 if (isset($_POST["use_vacation"])){
518 $tmp.= "V";
519 }
520 if (isset($_POST["own_script"])){
521 $tmp.= "C";
522 }
523 if (isset($_POST["only_local"])){
524 $tmp.= "I";
525 }
526 $tmp= "[$tmp]";
528 if (chkacl ($this->acl, "gosaMailDeliveryMode") == ""){
529 $this->gosaMailDeliveryMode= $tmp;
530 }
532 /* Collect data and re-assign it to the imapacl array */
533 if (chkacl($this->acl, "permissions") == ""){
534 $this->imapacl= array();
535 $this->imapacl['%members%']= $_POST['member_permissions'];
536 $this->imapacl['anyone']= $_POST['default_permissions'];
537 foreach ($this->indexed_user as $nr => $user){
538 if (!isset($_POST["user_$nr"])){
539 continue;
540 }
541 if ($_POST["user_$nr"] != $user ||
542 $_POST["perm_$nr"] != $this->indexed_acl[$nr]){
543 $this->is_modified= TRUE;
544 }
545 $this->imapacl[$_POST["user_$nr"]]= $_POST["perm_$nr"];
546 }
547 }
548 }
550 }
553 /* Save data to LDAP, depending on is_account we save or delete */
554 function save()
555 {
556 $ldap= $this->config->get_ldap_link();
558 /* Call parents save to prepare $this->attrs */
559 plugin::save();
561 /* Save arrays */
562 $this->attrs['gosaMailAlternateAddress']= $this->gosaMailAlternateAddress;
563 $this->attrs['gosaMailForwardingAddress']= $this->gosaMailForwardingAddress;
565 /* Save shared folder target */
566 $this->attrs['gosaSharedFolderTarget']= "share+".$this->uid;
568 /* Save acl's */
569 $this->attrs['acl']= array();
570 foreach ($this->imapacl as $user => $acl){
571 if ($user == ""){
572 continue;
573 }
574 $this->attrs['acl'][]= "$user $acl";
575 }
577 /* Save data to LDAP */
578 $ldap->cd($this->dn);
579 $ldap->modify($this->attrs);
580 show_ldap_error($ldap->get_error());
582 /* Only do IMAP actions if we are not a template */
583 if (!$this->is_template){
584 $method= new $this->method($this->config);
585 $method->fixAttributesOnStore($this);
586 if ($method->connect($this->gosaMailServer)){
587 $method->updateMailbox($this->uid);
588 $method->setQuota($this->uid, $this->gosaMailQuota);
590 /* Exchange '%member%' pseudo entry */
591 $memberacl= $this->imapacl['%members%'];
592 unset ($this->imapacl['%members%']);
593 foreach ($this->members as $user){
594 if (!isset($this->imapacl[$user])){
595 $this->imapacl[$user]= $memberacl;
596 }
597 }
599 $method->setSharedFolderPermissions($this->uid, $this->imapacl);
600 $method->disconnect();
601 }
602 }
604 /* Optionally execute a command after we're done */
605 if ($this->initially_was_account == $this->is_account){
606 if ($this->is_modified){
607 $this->handle_post_events("mofify");
608 }
609 } else {
610 $this->handle_post_events("add");
611 }
612 }
614 /* Check formular input */
615 function check()
616 {
617 $ldap= $this->config->get_ldap_link();
619 $message= array();
621 /* must: mail */
622 if ($this->mail == ""){
623 $message[]= _("The required field 'Primary address' is not set.");
624 }
625 if (!is_email($this->mail)){
626 $message[]= _("Please enter a valid email addres in 'Primary address' field.");
627 }
628 $ldap->cd($this->config->current['BASE']);
629 $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=".
630 $this->mail."))(!(uid=".$this->cn."))(!(cn=".$this->cn.")))");
631 if ($ldap->count() != 0){
632 $message[]= _("The primary address you've entered is already in use.");
633 }
635 /* Check quota */
636 if ($this->gosaMailQuota != '' && chkacl ($this->acl, "gosaMailQuota") == ""){
637 if (!is_numeric($this->gosaMailQuota)) {
638 $message[]= _("Value in 'Quota size' is not valid.");
639 } else {
640 $this->gosaMailQuota= (int) $this->gosaMailQuota;
641 }
642 }
644 /* Check rejectsize for integer */
645 if ($this->gosaMailMaxSize != '' && chkacl ($this->acl, "gosaMailQuota") == ""){
646 if (!is_numeric($this->gosaMailMaxSize)){
647 $message[]= _("Please specify a vaild mail size for mails to be rejected.");
648 } else {
649 $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize;
650 }
651 }
653 /* Need gosaMailMaxSize if use_mailsize_limit is checked */
654 if (is_integer(strpos($this->gosaMailDeliveryMode, "reject")) && $this->gosaMailMaxSize == ""){
655 $message[]= _("You need to set the maximum mail size in order to reject anything.");
656 }
658 if(ord($this->imapacl['anyone'][0])==194){
659 $message[] = _("Please choose valid permission settings. Default permission can't be emtpy.");
660 }
662 if(empty($this->gosaMailServer)){
663 $message[] = _("Please select a valid mail server.");
664 }
666 return ($message);
667 }
669 /* Adapt from template, using 'dn' */
670 function adapt_from_template($dn)
671 {
672 plugin::adapt_from_template($dn);
674 foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
675 $this->$val= array();
676 if (isset($this->attrs["$val"]["count"])){
677 for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
678 $value= $this->attrs["$val"][$i];
679 foreach (array("sn", "givenName", "uid") as $repl){
680 if (preg_match("/%$repl/i", $value)){
681 $value= preg_replace ("/%$repl/i", $this->parent->$repl, $value);
682 }
683 }
684 array_push($this->$val, $value);
685 }
686 }
687 }
688 }
690 /* Add entry to forwarder list */
691 function addForwarder($address)
692 {
693 $this->gosaMailForwardingAddress[]= $address;
694 $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress);
696 sort ($this->gosaMailForwardingAddress);
697 reset ($this->gosaMailForwardingAddress);
698 $this->is_modified= TRUE;
699 }
701 /* Remove list of addresses from forwarder list */
702 function delForwarder($addresses)
703 {
704 $this->gosaMailForwardingAddress= array_remove_entries ($addresses,
705 $this->gosaMailForwardingAddress);
706 $this->is_modified= TRUE;
707 }
711 function addAlternate($address)
712 {
713 $ldap= $this->config->get_ldap_link();
715 $address= strtolower($address);
717 /* Is this address already assigned in LDAP? */
718 $ldap->cd ($this->config->current['BASE']);
719 $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)".
720 "(gosaMailAlternateAddress=$address)))");
722 if ($ldap->count() > 0){
723 $attrs= $ldap->fetch ();
724 return ($attrs["uid"][0]);
725 }
727 /* Add to list of alternates */
728 if (!in_array($address, $this->gosaMailAlternateAddress)){
729 $this->gosaMailAlternateAddress[]= $address;
730 }
732 sort ($this->gosaMailAlternateAddress);
733 reset ($this->gosaMailAlternateAddress);
734 $this->is_modified= TRUE;
736 return ("");
737 }
740 function delAlternate($addresses)
741 {
742 $this->gosaMailAlternateAddress= array_remove_entries ($addresses,
743 $this->gosaMailAlternateAddress);
744 $this->is_modified= TRUE;
745 }
748 function make_name($attrs)
749 {
750 $name= "";
751 if (isset($attrs['sn'][0])){
752 $name= $attrs['sn'][0];
753 }
754 if (isset($attrs['givenName'][0])){
755 if ($name != ""){
756 $name.= ", ".$attrs['givenName'][0];
757 } else {
758 $name.= $attrs['givenName'][0];
759 }
760 }
761 if ($name != ""){
762 $name.= " ";
763 }
765 return ($name);
766 }
768 }
770 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
771 ?>