X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Faddressbook.php;h=e769db09bada5a444dbb70959b2a598304e6f3d2;hp=78eefe635a9c9236490c6a5527641798a7727e3f;hb=853b543dbd57499c467ed029bbf33ea25d306c55;hpb=959f43e3e76aa374b2191f23a322c1cf50ddeed7 diff --git a/src/addressbook.php b/src/addressbook.php index 78eefe63..e769db09 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -2,37 +2,27 @@ /** ** 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($config_php)) - include("../config/config.php"); - if (!isset($array_php)) - include("../functions/array.php"); - if (!isset($auth_php)) - include("../functions/auth.php"); - if (!isset($strings_php)) - include("../functions/strings.php"); - if (!isset($page_header_php)) - include("../functions/page_header.php"); - if (!isset($display_messages_php)) - include("../functions/display_messages.php"); - if (!isset($addressbook_php)) - include("../functions/addressbook.php"); - - is_logged_in(); + require_once('../src/validate.php'); + require_once('../functions/array.php'); + require_once('../functions/display_messages.php'); + require_once('../functions/addressbook.php'); // 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 +34,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,8 +75,6 @@ } - include("../src/load_prefs.php"); - // Open addressbook, with error messages on but without LDAP (the // second "true"). Don't need LDAP here anyway $abook = addressbook_init(true, true); @@ -85,23 +83,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 +107,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 +132,7 @@ $delfailed = false; for($i = 0 ; (($i < sizeof($sel)) && !$delfailed) ; $i++) { - list($sbackend, $snick) = split(":", $sel[$i]); + list($sbackend, $snick) = explode(':', $sel[$i]); // When we get to a new backend, process addresses in // previous one. @@ -176,18 +174,18 @@ else if(!empty($editaddr)) { // Stage one: Copy data into form - if(sizeof($sel) > 0) { + if (isset($sel) && sizeof($sel) > 0) { if(sizeof($sel) > 1) { $formerror = _("You can only edit one address at the time"); $showaddrlist = true; $defselected = $sel; } else { $abortform = true; - list($ebackend, $enick) = split(":", $sel[0]); + list($ebackend, $enick) = explode(':', $sel[0]); $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 +197,7 @@ printf("\n", htmlspecialchars($olddata["backend"])); print "\n"; - print ""; + print ''; } } @@ -227,11 +225,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 +269,34 @@ // 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; + echo "

" . + _("Add address") . "

\n"; + // 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 "\n"; + printf("\n", + _("Edit selected")); + printf("\n", + _("Delete selected")); + echo "\n"; + print ''; print " 
\n"; } @@ -295,7 +306,7 @@ print "\n\n"; print "\n"; - print ''; + print '
'; printf('
 '. '%s%s'. '%s%s'. @@ -308,13 +319,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,15 +358,18 @@ // Display the "new address" form - printf("\n", $PHP_SELF); + echo "\n"; + 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"); ?>