/**
** addressbook.php
**
+ ** Copyright (c) 1999-2000 The SquirrelMail development team
+ ** Licensed under the GNU GPL. For full terms see the file COPYING.
+ **
** Manage personal address book.
**
+ ** $Id$
**/
session_start();
- if(!isset($logged_in)) {
- echo _("You must login first.");
- exit;
- }
- if(!isset($username) || !isset($key)) {
- echo _("You need a valid user and password to access this page!");
- exit;
- }
-
+ if (!isset($strings_php))
+ include("../functions/strings.php");
if (!isset($config_php))
include("../config/config.php");
if (!isset($array_php))
include("../functions/array.php");
- if (!isset($strings_php))
- include("../functions/strings.php");
- if (!isset($imap_php))
- include("../functions/imap.php");
+ if (!isset($auth_php))
+ include("../functions/auth.php");
if (!isset($page_header_php))
include("../functions/page_header.php");
if (!isset($display_messages_php))
if (!isset($addressbook_php))
include("../functions/addressbook.php");
+ is_logged_in();
// Sort array by the key "name"
function alistcmp($a,$b) {
printf("<TD BGCOLOR=\"%s\" ALIGN=left>".
"<INPUT NAME=\"%s[nickname]\" SIZE=15 VALUE=\"%s\">".
" <SMALL>%s</SMALL></TD></TR>\n",
- $color[4], $name, htmlspecialchars($values["nickname"]),
+ $color[4], $name,
+ (isset($values["nickname"]))?
+ htmlspecialchars($values["nickname"]):"",
_("Must be unique"));
printf("<TR><TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>%s:</TD>",
_("E-mail address"));
printf("<TD BGCOLOR=\"%s\" ALIGN=left>".
"<INPUT NAME=\"%s[email]\" SIZE=45 VALUE=\"%s\"></TD></TR>\n",
- $color[4], $name, htmlspecialchars($values["email"]));
+ $color[4], $name,
+ (isset($values["email"]))?
+ htmlspecialchars($values["email"]):"");
printf("<TR><TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>%s:</TD>",
_("First name"));
printf("<TD BGCOLOR=\"%s\" ALIGN=left>".
"<INPUT NAME=\"%s[firstname]\" SIZE=45 VALUE=\"%s\"></TD></TR>\n",
- $color[4], $name, htmlspecialchars($values["firstname"]));
+ $color[4], $name,
+ (isset($values["firstname"]))?
+ htmlspecialchars($values["firstname"]):"");
printf("<TR><TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>%s:</TD>",
_("Last name"));
printf("<TD BGCOLOR=\"%s\" ALIGN=left>".
"<INPUT NAME=\"%s[lastname]\" SIZE=45 VALUE=\"%s\"></TD></TR>\n",
- $color[4], $name, htmlspecialchars($values["lastname"]));
+ $color[4], $name,
+ (isset($values["lastname"]))?
+ htmlspecialchars($values["lastname"]):"");
printf("<TR><TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>%s:</TD>",
_("Additional info"));
printf("<TD BGCOLOR=\"%s\" ALIGN=left>".
"<INPUT NAME=\"%s[label]\" SIZE=45 VALUE=\"%s\"></TD></TR>\n",
- $color[4], $name, htmlspecialchars($values["label"]));
+ $color[4], $name,
+ (isset($values["label"]))?
+ htmlspecialchars($values["label"]):"");
printf("<TR><TD COLSPAN=2 BGCOLOR=\"%s\" ALIGN=center>\n".
"<INPUT TYPE=submit NAME=\"%s[SUBMIT]\" VALUE=\"%s\"></TD></TR>\n",
}
- // IMAP Login
- $imapConnection = sqimap_login ($username, $key,
- $imapServerAddress, $imapPort, 10);
include("../src/load_prefs.php");
- sqimap_logout ($imapConnection);
-
// Open addressbook, with error messages on but without LDAP (the
// second "true"). Don't need LDAP here anyway
printf("<INPUT TYPE=hidden NAME=backend VALUE=\"%s\">\n",
htmlspecialchars($olddata["backend"]));
print "<INPUT TYPE=hidden NAME=doedit VALUE=1>\n";
- print "</FORM>";
+ print "</FORM>";
}
}
print "</TABLE>\n";
address_form("editaddr", _("Update address"), $newdata);
printf("<INPUT TYPE=hidden NAME=oldnick VALUE=\"%s\">\n",
- htmlspecialchars($newdata["nickname"]));
+ htmlspecialchars($oldnick));
printf("<INPUT TYPE=hidden NAME=backend VALUE=\"%s\">\n",
- htmlspecialchars($newdata["backend"]));
+ htmlspecialchars($backend));
print "<INPUT TYPE=hidden NAME=doedit VALUE=1>\n";
print "</FORM>";
// Display the address management part
if($showaddrlist) {
- printf("<FORM ACTION=\"%s\" METHOD=\"POST\">\n", $PHP_SELF);
-
// Get and sort address list
$alist = $abook->list_addr();
+ if(!is_array($alist)) {
+ plain_error_message($abook->error, $color);
+ exit;
+ }
+
usort($alist,'alistcmp');
$prevbackend = -1;
$headerprinted = false;
// List addresses
- while(list($key,$row) = each($alist)) {
+ printf("<FORM ACTION=\"%s\" METHOD=\"POST\">\n", $PHP_SELF);
+ while(list($undef,$row) = each($alist)) {
// New table header for each backend
if($prevbackend != $row["backend"]) {
// Display the "new address" form
- printf("<FORM ACTION=\"%s\" METHOD=\"POST\">\n", $PHP_SELF);
+ printf("<FORM ACTION=\"%s\" NAME=f_add METHOD=\"POST\">\n", $PHP_SELF);
print "<TABLE WIDTH=100% COLS=1 ALIGN=CENTER>\n";
print "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>\n<STRONG>";
printf(_("Add to %s"), $abook->localbackendname);
address_form("addaddr", _("Add address"), $defdata);
print "</FORM>";
+ // Add hook for anything that wants on the bottom
+ do_hook("addressbook_bottom");
?>
</BODY></HTML>