From 04875ae02a9614998d8c1cde217ae57d0c20ea72 Mon Sep 17 00:00:00 2001 From: tokul Date: Wed, 9 Feb 2005 16:45:11 +0000 Subject: [PATCH] display error box with more details. todo. do same thing with ldap books. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@8832 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/addressbook.php | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/functions/addressbook.php b/functions/addressbook.php index b4a31a36..c33e2240 100644 --- a/functions/addressbook.php +++ b/functions/addressbook.php @@ -12,6 +12,17 @@ * @subpackage addressbook */ +/** + * If SM_PATH isn't defined, define it. Required to include files. + * @ignore + */ +if (!defined('SM_PATH')) { + define('SM_PATH','../'); +} + +/* make sure that display_messages.php is loaded */ +include_once(SM_PATH . 'functions/display_messages.php'); + global $addrbook_dsn, $addrbook_global_dsn; /** @@ -19,7 +30,7 @@ global $addrbook_dsn, $addrbook_global_dsn; Returns the created object */ function addressbook_init($showerr = true, $onlylocal = false) { - global $data_dir, $username, $ldap_server, $address_book_global_filename; + global $data_dir, $username, $color, $ldap_server, $address_book_global_filename; global $addrbook_dsn, $addrbook_table; global $abook_global_file, $abook_global_file_writeable; global $addrbook_global_dsn, $addrbook_global_table, $addrbook_global_writeable, $addrbook_global_listing; @@ -27,6 +38,9 @@ function addressbook_init($showerr = true, $onlylocal = false) { /* Create a new addressbook object */ $abook = new AddressBook; + /* Create empty error message */ + $abook_init_error=''; + /* Always add a local backend. We use *either* file-based *or* a database addressbook. If $addrbook_dsn is set, the database @@ -78,9 +92,10 @@ function addressbook_init($showerr = true, $onlylocal = false) { 'name' => _("Global address book"), 'detect_writeable' => false, 'writeable'=> $abook_global_file_writeable)); + + /* global abook init error is not fatal. add error message and continue */ if (!$r && $showerr) { - echo _("Error initializing global addressbook."); - exit; + $abook_init_error.=_("Error initializing global addressbook.") . "
" . $abook->error; } } @@ -110,6 +125,10 @@ function addressbook_init($showerr = true, $onlylocal = false) { $r = $hookReturn[2]; if ($onlylocal) { + /* display error message, if present */ + if ($abook_init_error!='' && $showerr) { + error_box($abook_init_error,$color); + } return $abook; } @@ -129,6 +148,12 @@ function addressbook_init($showerr = true, $onlylocal = false) { } } + /** + * display address book init errors. + */ + if ($abook_init_error!='' && $showerr) { + error_box($abook_init_error,$color); + } /* Return the initialized object */ return $abook; } -- 2.25.1