X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Faddressbook.php;h=b31a71f82b28106a67c4c2ac97a6525b7c5836a5;hb=6b6c2e0605175300c0b4597f7e62348bb8bbf3b2;hp=4432751b2fa0ba4a2b61e43fa1353a13e007c878;hpb=a10110a50f284e8afdef868cab40e07e7deeea44;p=squirrelmail.git diff --git a/functions/addressbook.php b/functions/addressbook.php index 4432751b..b31a71f8 100644 --- a/functions/addressbook.php +++ b/functions/addressbook.php @@ -3,7 +3,7 @@ /** * addressbook.php * - * Copyright (c) 1999-2002 The SquirrelMail Project Team + * Copyright (c) 1999-2003 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * * Functions and classes for the addressbook system. @@ -30,19 +30,19 @@ Include backends here. */ -require_once('../functions/abook_local_file.php'); -require_once('../functions/abook_ldap_server.php'); +require_once(SM_PATH . 'functions/abook_local_file.php'); +require_once(SM_PATH . 'functions/abook_ldap_server.php'); global $addrbook_dsn; /* Use this if you wanna have a global address book */ if (isset($address_book_global_filename)) { - include_once('../functions/abook_global_file.php'); + include_once(SM_PATH . 'functions/abook_global_file.php'); } /* Only load database backend if database is configured */ -if(isset($addrbook_dsn)) { - include_once('../functions/abook_database.php'); +if(isset($addrbook_dsn) && !empty($addrbook_dsn)) { + include_once(SM_PATH . 'functions/abook_database.php'); } /* @@ -51,7 +51,7 @@ if(isset($addrbook_dsn)) { */ function addressbook_init($showerr = true, $onlylocal = false) { global $data_dir, $username, $ldap_server, $address_book_global_filename; - global $addrbook_dsn; + global $addrbook_dsn, $addrbook_table; /* Create a new addressbook object */ $abook = new AddressBook; @@ -63,9 +63,12 @@ function addressbook_init($showerr = true, $onlylocal = false) { */ if (isset($addrbook_dsn) && !empty($addrbook_dsn)) { /* Database */ + if (!isset($addrbook_table) || empty($addrbook_table)) { + $addrbook_table = 'address'; + } $r = $abook->add_backend('database', Array('dsn' => $addrbook_dsn, 'owner' => $username, - 'table' => 'address')); + 'table' => $addrbook_table)); if (!$r && $showerr) { echo _("Error initializing addressbook database."); exit; @@ -198,6 +201,26 @@ class AddressBook { } + /* + * This function takes a $row array as returned by the addressbook + * search and returns an e-mail address with the full name or + * nickname optionally prepended. + */ + + function full_address($row) { + global $addrsrch_fullname, $data_dir, $username; + + if (($prefix = getPref($data_dir, $username, 'addrsrch_fullname') or + isset($addrsrch_fullname) and $prefix = $addrsrch_fullname) + and $prefix !== 'noprefix') { + $name = ($prefix === 'nickname') ? $row['nickname'] + : $row['name']; + return $name . ' <' . trim($row['email']) . '>'; + } else { + return trim($row['email']); + } + } + /* Return a list of addresses matching expression in all backends of a given type.