X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddressbook.php;h=2ad610ea4bcbe5e95fd65487305680e6fa96a158;hb=31ac7db819a9a223e7b71f0e901265abe4019a34;hp=13d10424466a77822d6b38f59d269a980dc6d3f7;hpb=db1bbe47e677edb1b5355b15c6493fccedabf245;p=squirrelmail.git diff --git a/src/addressbook.php b/src/addressbook.php index 13d10424..2ad610ea 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -2,37 +2,41 @@ /** ** 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($strings_php)) + include('../functions/strings.php'); if (!isset($config_php)) - include("../config/config.php"); + include('../config/config.php'); if (!isset($array_php)) - include("../functions/array.php"); + include('../functions/array.php'); if (!isset($auth_php)) - include("../functions/auth.php"); - if (!isset($strings_php)) - include("../functions/strings.php"); + include('../functions/auth.php'); if (!isset($page_header_php)) - include("../functions/page_header.php"); + include('../functions/page_header.php'); if (!isset($display_messages_php)) - include("../functions/display_messages.php"); + include('../functions/display_messages.php'); if (!isset($addressbook_php)) - include("../functions/addressbook.php"); + include('../functions/addressbook.php'); is_logged_in(); // Sort array by the key "name" function alistcmp($a,$b) { - if($a["backend"] > $b["backend"]) + if($a['backend'] > $b['backend']) return 1; - else if($a["backend"] < $b["backend"]) + else if($a['backend'] < $b['backend']) return -1; - return (strtolower($a["name"]) > strtolower($b["name"])) ? 1 : -1; + return (strtolower($a['name']) > strtolower($b['name'])) ? 1 : -1; } // Output form to add and modify address data @@ -44,28 +48,38 @@ printf("". "". " %s\n", - $color[4], $name, htmlspecialchars($values["nickname"]), + $color[4], $name, + (isset($values['nickname']))? + htmlspecialchars($values['nickname']):"", _("Must be unique")); printf("%s:", _("E-mail address")); printf("". "\n", - $color[4], $name, htmlspecialchars($values["email"])); + $color[4], $name, + (isset($values["email"]))? + htmlspecialchars($values["email"]):""); printf("%s:", _("First name")); printf("". "\n", - $color[4], $name, htmlspecialchars($values["firstname"])); + $color[4], $name, + (isset($values["firstname"]))? + htmlspecialchars($values["firstname"]):""); printf("%s:", _("Last name")); printf("". "\n", - $color[4], $name, htmlspecialchars($values["lastname"])); + $color[4], $name, + (isset($values["lastname"]))? + htmlspecialchars($values["lastname"]):""); printf("%s:", _("Additional info")); printf("". "\n", - $color[4], $name, htmlspecialchars($values["label"])); + $color[4], $name, + (isset($values["label"]))? + htmlspecialchars($values["label"]):""); printf("\n". "\n", @@ -75,7 +89,7 @@ } - include("../src/load_prefs.php"); + include('../src/load_prefs.php'); // Open addressbook, with error messages on but without LDAP (the // second "true"). Don't need LDAP here anyway @@ -85,23 +99,23 @@ exit(); } - displayPageHeader($color, "None"); + displayPageHeader($color, 'None'); $defdata = array(); - $formerror = ""; + $formerror = ''; $abortform = false; $showaddrlist = true; $defselected = array(); // Handle user's actions - if($REQUEST_METHOD == "POST") { + if($REQUEST_METHOD == 'POST') { // *********************************************** // Add new address // *********************************************** - if(!empty($addaddr["nickname"])) { + if(!empty($addaddr['nickname'])) { $r = $abook->add($addaddr, $abook->localbackend); @@ -109,7 +123,7 @@ if(!$r) { // Remove backend name from error string $errstr = $abook->error; - $errstr = ereg_replace("^\[.*\] *", "", $errstr); + $errstr = ereg_replace('^\[.*\] *', '', $errstr); $formerror = $errstr; $showaddrlist = false; @@ -134,7 +148,7 @@ $delfailed = false; for($i = 0 ; (($i < sizeof($sel)) && !$delfailed) ; $i++) { - list($sbackend, $snick) = split(":", $sel[$i]); + list($sbackend, $snick) = split(':', $sel[$i]); // When we get to a new backend, process addresses in // previous one. @@ -187,7 +201,7 @@ $olddata = $abook->lookup($enick, $ebackend); // Display the "new address" form - printf("
\n", $PHP_SELF); + print "\n"; print "\n"; print "
\n"; print _("Update address"); @@ -199,7 +213,7 @@ printf("\n", htmlspecialchars($olddata["backend"])); print "\n"; - print ""; + print ''; } } @@ -227,11 +241,11 @@ print "
\n"; address_form("editaddr", _("Update address"), $newdata); printf("\n", - htmlspecialchars($newdata["nickname"])); + htmlspecialchars($oldnick)); printf("\n", - htmlspecialchars($newdata["backend"])); + htmlspecialchars($backend)); print "\n"; - print ""; + print ''; $abortform = true; } @@ -271,21 +285,25 @@ // Display the address management part if($showaddrlist) { - printf("
\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("\n", $PHP_SELF); + while(list($undef,$row) = each($alist)) { // New table header for each backend if($prevbackend != $row["backend"]) { if($prevbackend >= 0) { - print ""; + print ''; print " 
\n"; } @@ -295,7 +313,7 @@ print "\n\n"; print "\n"; - print ''; + print '
'; printf('
 '. '%s%s'. '%s%s'. @@ -308,13 +326,13 @@ $headerprinted = true; } // End of header - $prevbackend = $row["backend"]; + $prevbackend = $row['backend']; // Check if this user is selected - if(in_array($row["backend"].":".$row["nickname"], $defselected)) - $selected = "CHECKED"; + if(in_array($row['backend'].':'.$row['nickname'], $defselected)) + $selected = 'CHECKED'; else - $selected = ""; + $selected = ''; // Print one row printf("", @@ -347,22 +365,17 @@ // Display the "new address" form - printf("\n", $PHP_SELF); + printf("\n", $PHP_SELF); print "\n"; print "\n"; print "
\n"; printf(_("Add to %s"), $abook->localbackendname); print "\n
\n"; - address_form("addaddr", _("Add address"), $defdata); - print ""; + address_form('addaddr', _("Add address"), $defdata); + print ''; + // Add hook for anything that wants on the bottom + do_hook("addressbook_bottom"); ?> - - -
- -Import CSV File: - -