*
* 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
/** SquirrelMail required files. */
/* address book functions */
require_once(SM_PATH . 'functions/addressbook.php');
+include_once(SM_PATH . 'templates/util_addressbook.php');
+
/* form functions */
require_once(SM_PATH . 'functions/forms.php');
/** lets get the global vars we may need */
/* From the address form */
-//sqgetGlobalVar('change_abook', $change_abook, SQ_POST);
sqgetGlobalVar('addaddr', $addaddr, SQ_POST);
sqgetGlobalVar('editaddr', $editaddr, SQ_POST);
sqgetGlobalVar('deladdr', $deladdr, 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)
$form_url = 'addressbook.php';
/* Handle user's actions */
-//if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'POST' && !isset($change_abook)) {
if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'POST') {
/**************************************************
$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. */
$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) {
/* 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( nl2br(htmlspecialchars($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)));
+ }
}
$oTemplate->assign('addresses', $addresses);
$oTemplate->assign('current_backend', $current_backend);
$oTemplate->assign('backends', $list_backends);
+ $oTemplate->assign('abook_has_extra_field', $abook->add_extra_field);
$oTemplate->display('addressbook_list.tpl');
+//FIXME: Remove HTML from here!
echo "</form>\n";
}
/* Display the "new address" form */
+//FIXME: Remove HTML from here!
echo '<a name="AddAddress"></a>' . "\n";
abook_create_form($form_url,'addaddr',_("Add to address book"),_("Add address"),$defdata);
echo "</form>\n";
/* Hook for extra address book blocks */
-echo "<!-- start of addressbook_bottom hook-->\n";
-do_hook('addressbook_bottom');
-echo "\n<!-- end of addressbook_bottom hook-->\n";
+do_hook('addressbook_bottom', $null);
$oTemplate->display('footer.tpl');
-?>
\ No newline at end of file
+?>