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