X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddressbook.php;h=9a1ced25a9d4966cec17b26bef9a70adedd2a352;hb=823d08e55104565e7d94d879c3a3244d6719a5c4;hp=4edf5a72436c14c131e87a669d386bf22e2a66ec;hpb=3f92c0c765f985bbdf09b511f2e6289b5a506d1f;p=squirrelmail.git diff --git a/src/addressbook.php b/src/addressbook.php index 4edf5a72..9a1ced25 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -5,13 +5,16 @@ * * Manage personal address book. * - * @copyright © 1999-2006 The SquirrelMail Project Team + * @copyright © 1999-2007 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail * @subpackage addressbook */ +/** This is the addressbook page */ +define('PAGE_NAME', 'addressbook'); + /** * Include the SquirrelMail initialization file. */ @@ -40,7 +43,7 @@ sqgetGlobalVar('doedit', $doedit, SQ_POST); $abook_sort_order = get_abook_sort(); /* Create page header before addressbook_init in order to display error messages correctly. */ -displayPageHeader($color, 'None'); +displayPageHeader($color); /* Open addressbook with error messages on. remote backends (LDAP) are enabled because they can be used. (list_addr function) @@ -111,14 +114,14 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P $orig_sel = $sel; sort($sel); - /* The selected addresses are identidied by "backend:nickname". * + /* The selected addresses are identidied by "nickname_backend". * * Sort the list and process one backend at the time */ $prevback = -1; $subsel = array(); $delfailed = false; for ($i = 0 ; (($i < sizeof($sel)) && !$delfailed) ; $i++) { - list($sbackend, $snick) = explode(':', $sel[$i]); + list($snick, $sbackend) = explode('_', $sel[$i]); /* When we get to a new backend, process addresses in * * previous one. */ @@ -166,7 +169,7 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P $defselected = $sel; } else { $abortform = true; - list($ebackend, $enick) = explode(':', current($sel)); + list($enick, $ebackend) = explode('_', current($sel)); $olddata = $abook->lookup($enick, $ebackend); // Test if $olddata really contains anything and return an error message if it doesn't if (!$olddata) { @@ -188,14 +191,7 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P /* Handle error messages */ if (!$r) { /* Display error */ - echo html_tag( 'table', - html_tag( 'tr', - html_tag( 'td', - "\n". '' . _("ERROR") . ': ' . $abook->error . '' ."\n", - 'center' ) - ), - 'center', '', 'width="100%"' ); + plain_error_message( nl2br(htmlspecialchars($abook->error))); /* Display the "new address" form again */ abook_create_form($form_url,'editaddr',_("Update address"),_("Update address"),$newdata); @@ -247,20 +243,23 @@ while (list($k, $backend) = each ($abook->backends)) { $a['Addresses'] = array(); $alist = $abook->list_addr($backend->bnum); - usort($alist,'alistcmp'); - $start = 200; - $count = count($alist); - if ($start >= $count) $start = 0; - $alist = array_slice($alist,$start,15); - - $a['Addresses'] = formatAddressList($alist); + + /* check return (array with data or boolean false) */ + if (is_array($alist)) { + usort($alist,'alistcmp'); + + $a['Addresses'] = formatAddressList($alist); - $addresses[$backend->bnum] = $a; + $addresses[$backend->bnum] = $a; + } else { + // list_addr() returns boolean + plain_error_message(nl2br(htmlspecialchars($abook->error))); + } } if ($showaddrlist) { - echo addForm($form_url, 'post'); + echo addForm($form_url, 'post', 'address_book_form'); $oTemplate->assign('addresses', $addresses); $oTemplate->assign('current_backend', $current_backend); @@ -269,18 +268,17 @@ if ($showaddrlist) { $oTemplate->display('addressbook_list.tpl'); +//FIXME: Remove HTML from here! echo "\n"; } /* Display the "new address" form */ +//FIXME: Remove HTML from here! echo '' . "\n"; abook_create_form($form_url,'addaddr',_("Add to address book"),_("Add address"),$defdata); echo "\n"; /* Hook for extra address book blocks */ -echo "\n"; -do_hook('addressbook_bottom'); -echo "\n\n"; +do_hook('addressbook_bottom', $null); $oTemplate->display('footer.tpl'); -?> \ No newline at end of file