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