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