sqsession_register fix
[squirrelmail.git] / functions / addressbook.php
index f0f4def4ede464d763ddab7ea9585539dfbddd61..9b98f61bf386d2f1ee6a3e0a3763326eaddf4a84 100644 (file)
   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) && !empty($addrbook_dsn)) {
-  include_once('../functions/abook_database.php');
+  include_once(SM_PATH . 'functions/abook_database.php');
 }
 
 /*
@@ -63,7 +63,7 @@ function addressbook_init($showerr = true, $onlylocal = false) {
     */
     if (isset($addrbook_dsn) && !empty($addrbook_dsn)) {
         /* Database */
-        if (!isset($addrbook_table) || isempty($addrbook_table)) {
+        if (!isset($addrbook_table) || empty($addrbook_table)) {
             $addrbook_table = 'address';
         }
         $r = $abook->add_backend('database', Array('dsn' => $addrbook_dsn,
@@ -201,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, $datadir, $user;
+
+        if (($prefix = getPref($datadir, $user, '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.