/**
* addressbook.php
*
- * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Copyright (c) 1999-2004 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* Functions and classes for the addressbook system.
*
* $Id$
+ * @package squirrelmail
*/
-/*
+/**
This is the path to the global site-wide addressbook.
It looks and feels just like a user's .abook file
If this is in the data directory, use "$data_dir/global.abook"
*/
-global $addrbook_dsn;
+global $addrbook_dsn, $addrbook_global_dsn;
-/*
+/**
Create and initialize an addressbook object.
Returns the created object
*/
function addressbook_init($showerr = true, $onlylocal = false) {
global $data_dir, $username, $ldap_server, $address_book_global_filename;
global $addrbook_dsn, $addrbook_table;
+ global $addrbook_global_dsn, $addrbook_global_table, $addrbook_global_writeable, $addrbook_global_listing;
/* Create a new addressbook object */
$abook = new AddressBook;
}
}
+ /* Load global addressbook from SQL if configured */
+ if (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn)) {
+ /* Database configured */
+ if (!isset($addrbook_global_table) || empty($addrbook_global_table)) {
+ $addrbook_global_table = 'global_abook';
+ }
+ $r = $abook->add_backend('database',
+ Array('dsn' => $addrbook_global_dsn,
+ 'owner' => 'global',
+ 'name' => _("Global address book"),
+ 'writeable' => $addrbook_global_writeable,
+ 'listing' => $addrbook_global_listing,
+ 'table' => $addrbook_global_table));
+ }
+
if ($onlylocal) {
return $abook;
}
}
-/*
+/**
* This is the main address book class that connect all the
* backends and provide services to the functions above.
- *
+ * @package squirrelmail
*/
class AddressBook {
$alias = array(0 => $alias);
}
- /* Check that specified backend is writable */
+ /* Check that specified backend is writeable */
if (!$this->backends[$bnum]->writeable) {
$this->error = _("Addressbook is read-only");
return false;
$userdata['nickname'] = $userdata['email'];
}
- /* Check that specified backend is writable */
+ /* Check that specified backend is writeable */
if (!$this->backends[$bnum]->writeable) {
$this->error = _("Addressbook is read-only");;
return false;
} /* End of class Addressbook */
-/*
+/**
* Generic backend that all other backends extend
+ * @package squirrelmail
*/
class addressbook_backend {
}
/* Only load database backend if database is configured */
-if(isset($addrbook_dsn) && !empty($addrbook_dsn)) {
+if((isset($addrbook_dsn) && !empty($addrbook_dsn)) ||
+ (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn)) ) {
include_once(SM_PATH . 'functions/abook_database.php');
}