/** SquirrelMail required files. */
/* address book functions */
require_once(SM_PATH . 'functions/addressbook.php');
+include_once(SM_PATH . 'templates/util_addressbook.php');
+include_once(SM_PATH . 'templates/util_global.php');
+
/* form functions */
require_once(SM_PATH . 'functions/forms.php');
/* Handle error messages */
if (!$r) {
/* Display error */
- echo html_tag( 'table',
- html_tag( 'tr',
- html_tag( 'td',
- "\n". '<strong><font color="' . $color[2] .
- '">' . _("ERROR") . ': ' . $abook->error . '</font></strong>' ."\n",
- 'center' )
- ),
- 'center', '', 'width="100%"' );
+ plain_error_message( _("ERROR") .': '. $abook->error);
/* Display the "new address" form again */
abook_create_form($form_url,'editaddr',_("Update address"),_("Update address"),$newdata);
$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);
-
- while(list($undef,$row) = each($alist)) {
- $contact = array (
- 'FirstName' => htmlspecialchars($row['firstname']),
- 'LastName' => htmlspecialchars($row['lastname']),
- 'FullName' => htmlspecialchars($row['name']),
- 'NickName' => htmlspecialchars($row['nickname']),
- 'Email' => htmlspecialchars($row['email']),
- 'FullAddress' => htmlspecialchars($abook->full_address($row)),
- 'Info' => htmlspecialchars($row['label']),
- 'Extra' => (isset($row['extra']) ? $row['extra'] : NULL),
- );
- $a['Addresses'][] = $contact;
- }
+
+ /* 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)));
+ }
}