4 * functions/addressbook.php - Functions and classes for the addressbook system
6 * Functions require SM_PATH and support of forms.php functions
8 * @copyright © 1999-2006 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
12 * @subpackage addressbook
15 /** required includes */
16 // FIXME, NO display code in functions files
17 include_once(SM_PATH
. 'templates/util_global.php');
20 * Create and initialize an addressbook object.
21 * @param boolean $showerr display any address book init errors. html page header
22 * must be created before calling addressbook_init() with $showerr enabled.
23 * @param boolean $onlylocal enable only local address book backends. Should
24 * be used when code does not need access to remote backends. Backends
25 * that provide read only address books with limited listing options can be
27 * @return object address book object.
29 function addressbook_init($showerr = true, $onlylocal = false) {
30 global $data_dir, $username, $ldap_server, $address_book_global_filename;
31 global $addrbook_dsn, $addrbook_table;
32 global $abook_global_file, $abook_global_file_writeable, $abook_global_file_listing;
33 global $addrbook_global_dsn, $addrbook_global_table, $addrbook_global_writeable, $addrbook_global_listing;
34 global $abook_file_line_length;
36 /* Create a new addressbook object */
37 $abook = new AddressBook
;
39 /* Create empty error message */
43 Always add a local backend. We use *either* file-based *or* a
44 database addressbook. If $addrbook_dsn is set, the database
45 backend is used. If not, addressbooks are stores in files.
47 if (isset($addrbook_dsn) && !empty($addrbook_dsn)) {
49 if (!isset($addrbook_table) ||
empty($addrbook_table)) {
50 $addrbook_table = 'address';
52 $r = $abook->add_backend('database', Array('dsn' => $addrbook_dsn,
54 'table' => $addrbook_table));
55 if (!$r && $showerr) {
56 $abook_init_error.=_("Error initializing address book database.") . "\n" . $abook->error
;
60 $filename = getHashedFile($username, $data_dir, "$username.abook");
61 $r = $abook->add_backend('local_file', Array('filename' => $filename,
62 'line_length' => $abook_file_line_length,
65 // no need to use $abook->error, because message explains error.
66 $abook_init_error.=sprintf( _("Error opening file %s"), $filename );
70 /* Global file based addressbook */
71 if (isset($abook_global_file) &&
72 isset($abook_global_file_writeable) &&
73 isset($abook_global_file_listing) &&
74 trim($abook_global_file)!=''){
76 // Detect place of address book
77 if (! preg_match("/[\/\\\]/",$abook_global_file)) {
78 /* no path chars, address book stored in data directory
79 * make sure that there is a slash between data directory
80 * and address book file name
82 $abook_global_filename=$data_dir
83 . ((substr($data_dir, -1) != '/') ?
'/' : '')
85 } elseif (preg_match("/^\/|\w:/",$abook_global_file)) {
86 // full path is set in options (starts with slash or x:)
87 $abook_global_filename=$abook_global_file;
89 $abook_global_filename=SM_PATH
. $abook_global_file;
92 $r = $abook->add_backend('local_file',array('filename'=>$abook_global_filename,
93 'name' => _("Global address book"),
94 'detect_writeable' => false,
95 'line_length' => $abook_file_line_length,
96 'writeable'=> $abook_global_file_writeable,
97 'listing' => $abook_global_file_listing));
99 /* global abook init error is not fatal. add error message and continue */
100 if (!$r && $showerr) {
101 if ($abook_init_error!='') $abook_init_error.="\n";
102 $abook_init_error.=_("Error initializing global address book.") . "\n" . $abook->error
;
106 /* Load global addressbook from SQL if configured */
107 if (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn)) {
108 /* Database configured */
109 if (!isset($addrbook_global_table) ||
empty($addrbook_global_table)) {
110 $addrbook_global_table = 'global_abook';
112 $r = $abook->add_backend('database',
113 Array('dsn' => $addrbook_global_dsn,
115 'name' => _("Global address book"),
116 'writeable' => $addrbook_global_writeable,
117 'listing' => $addrbook_global_listing,
118 'table' => $addrbook_global_table));
119 /* global abook init error is not fatal. add error message and continue */
120 if (!$r && $showerr) {
121 if ($abook_init_error!='') $abook_init_error.="\n";
122 $abook_init_error.=_("Error initializing global address book.") . "\n" . $abook->error
;
127 * hook allows to include different address book backends.
128 * plugins should extract $abook and $r from arguments
129 * and use same add_backend commands as above functions.
130 * Since 1.5.2 hook sends third ($onlylocal) argument to address book
131 * plugins in order to allow detection of local address book init.
132 * @since 1.5.1 and 1.4.5
134 $hookReturn = do_hook('abook_init', $abook, $r, $onlylocal);
135 $abook = $hookReturn[1];
137 if (!$r && $showerr) {
138 if ($abook_init_error!='') $abook_init_error.="\n";
139 $abook_init_error.=_("Error initializing other address books.") . "\n" . $abook->error
;
142 /* Load configured LDAP servers (if PHP has LDAP support) */
143 if (isset($ldap_server) && is_array($ldap_server)) {
145 while (list($undef,$param) = each($ldap_server)) {
146 if (!is_array($param))
149 /* if onlylocal is true, we only add writeable ldap servers */
150 if ($onlylocal && (!isset($param['writeable']) ||
$param['writeable'] != true))
153 $r = $abook->add_backend('ldap_server', $param);
154 if (!$r && $showerr) {
155 if ($abook_init_error!='') $abook_init_error.="\n";
156 $abook_init_error.=sprintf(_("Error initializing LDAP server %s:"), $param['host'])."\n";
157 $abook_init_error.= $abook->error
;
160 } // end of ldap server init
163 * display address book init errors.
165 if ($abook_init_error!='' && $showerr) {
166 error_box(nl2br(htmlspecialchars($abook_init_error)));
169 /* Return the initialized object */
174 * Display the "new address" form
176 * Form is not closed and you must add closing form tag.
178 * @param string $form_url form action url
179 * @param string $name form name
180 * @param string $title form title
181 * @param string $button form button name
182 * @param array $defdata values of form fields
184 function abook_create_form($form_url,$name,$title,$button,$defdata=array()) {
186 echo addForm($form_url, 'post', 'f_add').
189 html_tag( 'td', "\n". '<strong>' . $title . '</strong>' . "\n",
193 , 'center', '', 'width="90%"' ) ."\n";
194 address_form($name, $button, $defdata);
199 * Had to move this function outside of the Addressbook Class
200 * PHP 4.0.4 Seemed to be having problems with inline functions.
201 * Note: this can return now since we don't support 4.0.4 anymore.
203 function addressbook_cmp($a,$b) {
205 if($a['backend'] > $b['backend']) {
207 } else if($a['backend'] < $b['backend']) {
211 return (strtolower($a['name']) > strtolower($b['name'])) ?
1 : -1;
216 * Make an input field
217 * @param string $label
218 * @param string $field
219 * @param string $name
220 * @param string $size
221 * @param array $values
224 function addressbook_inp_field($label, $field, $name, $size, $values, $add='') {
226 $value = ( isset($values[$field]) ?
$values[$field] : '');
228 if (is_array($value)) {
229 $td_str = addSelect($name.'['.$field.']', $value);
231 $td_str = addInput($name.'['.$field.']', $value, $size);
235 return html_tag( 'tr' ,
236 html_tag( 'td', '<label for="'.$name.'_'.$field.'_'.'">' .
237 $label . '</label>:', 'right', $color[4]) .
238 html_tag( 'td', $td_str, 'left', $color[4])
244 * Output form to add and modify address data
246 function address_form($name, $submittext, $values = array()) {
247 global $color, $squirrelmail_language;
249 if ($squirrelmail_language == 'ja_JP') {
250 echo html_tag( 'table',
251 addressbook_inp_field(_("Nickname"), 'nickname', $name, 15, $values,
252 ' <small>' . _("Must be unique") . '</small>') .
253 addressbook_inp_field(_("E-mail address"), 'email', $name, 45, $values, '') .
254 addressbook_inp_field(_("Last name"), 'lastname', $name, 45, $values, '') .
255 addressbook_inp_field(_("First name"), 'firstname', $name, 45, $values, '') .
256 addressbook_inp_field(_("Additional info"), 'label', $name, 45, $values, '') .
257 list_writable_backends($name) .
260 addSubmit($submittext, $name.'[SUBMIT]'),
261 'center', $color[4], 'colspan="2"')
263 , 'center', '', 'border="0" cellpadding="1" width="90%"') ."\n";
265 echo html_tag( 'table',
266 addressbook_inp_field(_("Nickname"), 'nickname', $name, 15, $values,
267 ' <small>' . _("Must be unique") . '</small>') .
268 addressbook_inp_field(_("E-mail address"), 'email', $name, 45, $values, '') .
269 addressbook_inp_field(_("First name"), 'firstname', $name, 45, $values, '') .
270 addressbook_inp_field(_("Last name"), 'lastname', $name, 45, $values, '') .
271 addressbook_inp_field(_("Additional info"), 'label', $name, 45, $values, '') .
272 list_writable_backends($name) .
275 addSubmit($submittext, $name.'[SUBMIT]') ,
276 'center', $color[4], 'colspan="2"')
278 , 'center', '', 'border="0" cellpadding="1" width="90%"') ."\n";
283 * Provides list of writeable backends.
284 * Works only when address is added ($name='addaddr')
285 * @param string $name name of form
286 * @return string html formated backend field (select or hidden)
288 function list_writable_backends($name) {
289 global $color, $abook;
290 if ( $name != 'addaddr' ) { return; }
291 $writeable_abook = 1;
292 if ( $abook->numbackends
> 1 ) {
293 $backends = $abook->get_backend_list();
294 $writeable_abooks=array();
295 while (list($undef,$v) = each($backends)) {
297 // add each backend to array
298 $writeable_abooks[$v->bnum
]=$v->sname
;
299 // save backend number
300 $writeable_abook=$v->bnum
;
303 if (count($writeable_abooks)>1) {
304 // we have more than one writeable backend
305 $ret=addSelect('backend',$writeable_abooks,null,true);
306 return html_tag( 'tr',
307 html_tag( 'td', _("Add to:"),'right', $color[4] ) .
308 html_tag( 'td', $ret, 'left', $color[4] )) . "\n";
311 // Only one backend exists or is writeable.
312 return html_tag( 'tr',
314 addHidden('backend', $writeable_abook),
315 'center', $color[4], 'colspan="2"')) . "\n";
319 * Sort array by the key "name"
321 function alistcmp($a,$b) {
322 $abook_sort_order=get_abook_sort();
324 switch ($abook_sort_order) {
327 $abook_sort='nickname';
344 if ($a['backend'] > $b['backend']) {
347 if ($a['backend'] < $b['backend']) {
352 if( (($abook_sort_order+
2) %
2) == 1) {
353 return (strtolower($a[$abook_sort]) < strtolower($b[$abook_sort])) ?
1 : -1;
355 return (strtolower($a[$abook_sort]) > strtolower($b[$abook_sort])) ?
1 : -1;
360 * Address book sorting options
362 * returns address book sorting order
363 * @return integer book sorting options order
365 function get_abook_sort() {
366 global $data_dir, $username;
368 /* get sorting order */
369 if(sqgetGlobalVar('abook_sort_order', $temp, SQ_GET
)) {
370 $abook_sort_order = (int) $temp;
372 if ($abook_sort_order < 0 or $abook_sort_order > 8)
375 setPref($data_dir, $username, 'abook_sort_order', $abook_sort_order);
377 /* get previous sorting options. default to unsorted */
378 $abook_sort_order = getPref($data_dir, $username, 'abook_sort_order', 8);
381 return $abook_sort_order;
385 * This function shows the address book sort button.
387 * @param integer $abook_sort_order current sort value
388 * @param string $alt_tag alt tag value (string visible to text only browsers)
389 * @param integer $Down sort value when list is sorted ascending
390 * @param integer $Up sort value when list is sorted descending
391 * @return string html code with sorting images and urls
393 function show_abook_sort_button($abook_sort_order, $alt_tag, $Down, $Up ) {
394 global $form_url, $icon_theme_path;
396 /* Figure out which image we want to use. */
397 if ($abook_sort_order != $Up && $abook_sort_order != $Down) {
398 $img = 'sort_none.png';
399 $text_icon = '◻'; // U+25FB WHITE MEDIUM SQUARE
401 } elseif ($abook_sort_order == $Up) {
402 $img = 'up_pointer.png';
403 $text_icon = '⇧'; // U+21E7 UPWARDS WHITE ARROW
406 $img = 'down_pointer.png';
407 $text_icon = '⇩'; // U+21E9 DOWNWARDS WHITE ARROW
411 /* Now that we have everything figured out, show the actual button. */
412 return ' <a href="' . $form_url .'?abook_sort_order=' . $which .
413 '" style="text-decoration:none" title="'.$alt_tag.'">' .
414 getIcon($icon_theme_path, $img, $text_icon, $alt_tag) .
420 * This is the main address book class that connect all the
421 * backends and provide services to the functions above.
422 * @package squirrelmail
423 * @subpackage addressbook
427 * Enabled address book backends
430 var $backends = array();
432 * Number of enabled backends
435 var $numbackends = 0;
442 * id of backend with personal address book
445 var $localbackend = 0;
447 * Name of backend with personal address book
450 var $localbackendname = '';
452 * Controls use of 'extra' field
454 * Extra field can be used to add link to form, which allows
455 * to modify all fields supported by backend. This is the only field
456 * that is not sanitized with htmlspecialchars. Backends MUST make
457 * sure that field data is sanitized and displayed correctly inside
458 * table cell. Use of html formating in other address book fields is
459 * not allowed. Backends that don't return 'extra' row in address book
460 * data should not modify this object property.
464 var $add_extra_field = false;
467 * Constructor function.
469 function AddressBook() {
470 $this->localbackendname
= _("Personal address book");
474 * Return an array of backends of a given type,
475 * or all backends if no type is specified.
476 * @param string $type backend type
477 * @return array list of backends
479 function get_backend_list($type = '') {
481 for ($i = 1 ; $i <= $this->numbackends
; $i++
) {
482 if (empty($type) ||
$type == $this->backends
[$i]->btype
) {
483 $ret[] = &$this->backends
[$i];
490 /* ========================== Public ======================== */
495 * @param string $backend backend name (without the abook_ prefix)
496 * @param mixed optional variable that is passed to the backend constructor.
497 * See each of the backend classes for valid parameters
498 * @return integer number of backends
500 function add_backend($backend, $param = '') {
501 static $backend_classes;
502 if (!isset($backend_classes)) {
503 $backend_classes = array();
505 if (!isset($backend_classes[$backend])) {
507 * Support backend provided by plugins. Plugin function must
508 * return an associative array with as key the backend name ($backend)
509 * and as value the file including the path containing the backend class.
510 * i.e.: $aBackend = array('backend_template' => SM_PATH . 'plugins/abook_backend_template/functions.php')
512 * NB: Because the backend files are included from within this function they DO NOT have access to
513 * vars in the global scope. This function is the global scope for the included backend !!!
515 $aBackend = do_hook('abook_add_class');
516 if (isset($aBackend) && is_array($aBackend) && isset($aBackend[$backend])) {
517 require_once($aBackend[$backend]);
519 require_once(SM_PATH
. 'functions/abook_'.$backend.'.php');
521 $backend_classes[$backend] = true;
523 $backend_name = 'abook_' . $backend;
524 $newback = new $backend_name($param);
525 //eval('$newback = new ' . $backend_name . '($param);');
526 if(!empty($newback->error
)) {
527 $this->error
= $newback->error
;
531 $this->numbackends++
;
533 $newback->bnum
= $this->numbackends
;
534 $this->backends
[$this->numbackends
] = $newback;
536 /* Store ID of first local backend added */
537 if ($this->localbackend
== 0 && $newback->btype
== 'local') {
538 $this->localbackend
= $this->numbackends
;
539 $this->localbackendname
= $newback->sname
;
542 return $this->numbackends
;
547 * create string with name and email address
549 * This function takes a $row array as returned by the addressbook
550 * search and returns an e-mail address with the full name or
551 * nickname optionally prepended.
552 * @param array $row address book entry
553 * @return string email address with real name prepended
555 function full_address($row) {
556 global $addrsrch_fullname, $data_dir, $username;
557 $prefix = getPref($data_dir, $username, 'addrsrch_fullname');
558 if (($prefix != "" ||
(isset($addrsrch_fullname) &&
559 $prefix == $addrsrch_fullname)) && $prefix != 'noprefix') {
560 $name = ($prefix == 'nickname' ?
$row['nickname'] : $row['name']);
561 return $name . ' <' . trim($row['email']) . '>';
563 return trim($row['email']);
568 * Search for entries in address books
570 * Return a list of addresses matching expression in
571 * all backends of a given type.
572 * @param string $expression search expression
573 * @param integer $bnum backend number. default to search in all backends
574 * @return array search results
576 function search($expression, $bnum = -1) {
580 /* Search all backends */
582 $sel = $this->get_backend_list('');
584 for ($i = 0 ; $i < sizeof($sel) ; $i++
) {
585 $backend = &$sel[$i];
586 $backend->error
= '';
587 $res = $backend->search($expression);
588 if (is_array($res)) {
589 $ret = array_merge($ret, $res);
591 $this->error
.= "\n" . $backend->error
;
596 /* Only fail if all backends failed */
597 if( $failed >= sizeof( $sel ) ) {
601 } elseif (! isset($this->backends
[$bnum])) {
602 /* make sure that backend exists */
603 $this->error
= _("Unknown address book backend");
607 /* Search only one backend */
609 $ret = $this->backends
[$bnum]->search($expression);
610 if (!is_array($ret)) {
611 $this->error
.= "\n" . $this->backends
[$bnum]->error
;
622 * @param string $expression search expression
623 * @param integer $bnum backend number. default to search in all backends
624 * @return array search results
626 function s_search($expression, $bnum = -1) {
628 $ret = $this->search($expression, $bnum);
629 if ( is_array( $ret ) ) {
630 usort($ret, 'addressbook_cmp');
637 * Lookup an address by alias.
638 * Only possible in local backends.
639 * @param string $alias
640 * @param integer backend number
641 * @return array lookup results. False, if not found.
643 function lookup($alias, $bnum = -1) {
648 if (!isset($this->backends
[$bnum])) {
649 $this->error
= _("Unknown address book backend");
652 $res = $this->backends
[$bnum]->lookup($alias);
653 if (is_array($res)) {
656 $this->error
= $this->backends
[$bnum]->error
;
661 $sel = $this->get_backend_list('local');
662 for ($i = 0 ; $i < sizeof($sel) ; $i++
) {
663 $backend = &$sel[$i];
664 $backend->error
= '';
665 $res = $backend->lookup($alias);
666 if (is_array($res)) {
670 $this->error
= $backend->error
;
680 * Return all addresses
681 * @param integer $bnum backend number
682 * @return mixed array with search results or boolean false on error.
684 function list_addr($bnum = -1) {
688 $sel = $this->get_backend_list('');
689 } elseif (! isset($this->backends
[$bnum])) {
690 /* make sure that backend exists */
691 $this->error
= _("Unknown address book backend");
694 $sel = array(0 => &$this->backends
[$bnum]);
697 for ($i = 0 ; $i < sizeof($sel) ; $i++
) {
698 $backend = &$sel[$i];
699 $backend->error
= '';
700 $res = $backend->list_addr();
701 if (is_array($res)) {
702 $ret = array_merge($ret, $res);
704 $this->error
= $backend->error
;
713 * Create a new address
714 * @param array $userdata added address record
715 * @param integer $bnum backend number
716 * @return integer the backend number that the/ address was added
717 * to, or false if it failed.
719 function add($userdata, $bnum) {
722 if (!is_array($userdata)) {
723 $this->error
= _("Invalid input data");
726 if (empty($userdata['firstname']) && empty($userdata['lastname'])) {
727 $this->error
= _("Name is missing");
730 if (empty($userdata['email'])) {
731 $this->error
= _("E-mail address is missing");
734 if (empty($userdata['nickname'])) {
735 $userdata['nickname'] = $userdata['email'];
738 /* Blocks use of space, :, |, #, " and ! in nickname */
739 if (eregi('[ \\:\\|\\#\\"\\!]', $userdata['nickname'])) {
740 $this->error
= _("Nickname contains illegal characters");
744 /* make sure that backend exists */
745 if (! isset($this->backends
[$bnum])) {
746 $this->error
= _("Unknown address book backend");
750 /* Check that specified backend accept new entries */
751 if (!$this->backends
[$bnum]->writeable
) {
752 $this->error
= _("Address book is read-only");
756 /* Add address to backend */
757 $res = $this->backends
[$bnum]->add($userdata);
761 $this->error
= $this->backends
[$bnum]->error
;
765 return false; // Not reached
770 * Remove the entries from address book
771 * @param mixed $alias entries that have to be removed. Can be string with nickname or array with list of nicknames
772 * @param integer $bnum backend number
773 * @return bool true if removed successfully. false if there s an error. $this->error contains error message
775 function remove($alias, $bnum) {
782 /* Convert string to single element array */
783 if (!is_array($alias)) {
784 $alias = array(0 => $alias);
787 /* make sure that backend exists */
788 if (! isset($this->backends
[$bnum])) {
789 $this->error
= _("Unknown address book backend");
793 /* Check that specified backend is writable */
794 if (!$this->backends
[$bnum]->writeable
) {
795 $this->error
= _("Address book is read-only");
799 /* Remove user from backend */
800 $res = $this->backends
[$bnum]->remove($alias);
804 $this->error
= $this->backends
[$bnum]->error
;
808 return FALSE; /* Not reached */
809 } /* end of remove() */
813 * Modify entry in address book
814 * @param string $alias nickname
815 * @param array $userdata newdata
816 * @param integer $bnum backend number
818 function modify($alias, $userdata, $bnum) {
821 if (empty($alias) ||
!is_string($alias)) {
826 if(!is_array($userdata)) {
827 $this->error
= _("Invalid input data");
830 if (empty($userdata['firstname']) && empty($userdata['lastname'])) {
831 $this->error
= _("Name is missing");
834 if (empty($userdata['email'])) {
835 $this->error
= _("E-mail address is missing");
839 if (eregi('[\\: \\|\\#"\\!]', $userdata['nickname'])) {
840 $this->error
= _("Nickname contains illegal characters");
844 if (empty($userdata['nickname'])) {
845 $userdata['nickname'] = $userdata['email'];
848 /* make sure that backend exists */
849 if (! isset($this->backends
[$bnum])) {
850 $this->error
= _("Unknown address book backend");
854 /* Check that specified backend is writable */
855 if (!$this->backends
[$bnum]->writeable
) {
856 $this->error
= _("Address book is read-only");;
860 /* Modify user in backend */
861 $res = $this->backends
[$bnum]->modify($alias, $userdata);
865 $this->error
= $this->backends
[$bnum]->error
;
869 return FALSE; /* Not reached */
870 } /* end of modify() */
873 } /* End of class Addressbook */
876 * Generic backend that all other backends extend
877 * @package squirrelmail
878 * @subpackage addressbook
880 class addressbook_backend
{
882 /* Variables that all backends must provide. */
886 * Can be 'local' or 'remote'
887 * @var string backend type
889 var $btype = 'dummy';
891 * Internal backend name
894 var $bname = 'dummy';
896 * Displayed backend name
899 var $sname = 'Dummy backend';
902 * Variables common for all backends, but that
903 * should not be changed by the backends.
919 var $writeable = false;
923 * @param string $string error message
926 function set_error($string) {
927 $this->error
= '[' . $this->sname
. '] ' . $string;
932 /* ========================== Public ======================== */
935 * Search for entries in backend
937 * Working backend should support use of wildcards. * symbol
938 * should match one or more symbols. ? symbol should match any
940 * @param string $expression
943 function search($expression) {
944 $this->set_error('search is not implemented');
949 * Find entry in backend by alias
950 * @param string $alias name used for id
953 function lookup($alias) {
954 $this->set_error('lookup is not implemented');
959 * List all entries in backend
961 * Working backend should provide this function or at least
962 * dummy function that returns empty array.
965 function list_addr() {
966 $this->set_error('list_addr is not implemented');
971 * Add entry to backend
972 * @param array userdata
975 function add($userdata) {
976 $this->set_error('add is not implemented');
981 * Remove entry from backend
982 * @param string $alias name used for id
985 function remove($alias) {
986 $this->set_error('delete is not implemented');
991 * Modify entry in backend
992 * @param string $alias name used for id
993 * @param array $newuserdata new data
996 function modify($alias, $newuserdata) {
997 $this->set_error('modify is not implemented');
1002 * Creates full name from given name and surname
1004 * Handles name order differences. Function always runs in SquirrelMail gettext domain.
1005 * Plugins don't have to switch domains before calling this function.
1006 * @param string $firstname given name
1007 * @param string $lastname surname
1008 * @return string full name
1011 function fullname($firstname,$lastname) {
1013 * i18n: allows to control fullname layout in address book listing
1014 * first %s is for first name, second %s is for last name.
1015 * Translate it to '%2$s %1$s', if surname must be displayed first in your language.
1016 * Please note that variables can be set to empty string and extra formating
1017 * (for example '%2$s, %1$s' as in 'Smith, John') might break. Use it only for
1018 * setting name and surname order. scripts will remove all prepended and appended
1021 return trim(sprintf(dgettext('squirrelmail',"%s %s"),$firstname,$lastname));