X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Faddressbook.php;h=e769db09bada5a444dbb70959b2a598304e6f3d2;hp=f8a0e49a522b05356e4ff2a1ed22345c1267e04a;hb=0ee3f2af4a1f7063145da73dcbb0f2b54dcbbfe3;hpb=245a6892bf5c780904ef9677f24d624ea17e0749 diff --git a/src/addressbook.php b/src/addressbook.php index f8a0e49a..e769db09 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -10,33 +10,19 @@ ** $Id$ **/ - session_start(); - - 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($auth_php)) - include("../functions/auth.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 @@ -49,8 +35,8 @@ "". " %s\n", $color[4], $name, - (isset($values["nickname"]))? - htmlspecialchars($values["nickname"]):"", + (isset($values['nickname']))? + htmlspecialchars($values['nickname']):"", _("Must be unique")); printf("%s:", _("E-mail address")); @@ -89,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); @@ -99,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); @@ -123,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; @@ -148,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. @@ -190,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 '
\n"; print _("Update address"); @@ -213,7 +197,7 @@ printf("\n", htmlspecialchars($olddata["backend"])); print "\n"; - print ""; + print ''; } } @@ -245,7 +229,7 @@ printf("\n", htmlspecialchars($backend)); print "\n"; - print ""; + print ''; $abortform = true; } @@ -296,6 +280,9 @@ $prevbackend = -1; $headerprinted = false; + echo "

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

\n"; + // List addresses printf("
\n", $PHP_SELF); while(list($undef,$row) = each($alist)) { @@ -303,7 +290,13 @@ // 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 "
'; print " 
\n"; } @@ -313,7 +306,7 @@ print "\n\n"; print "\n"; - print ''; + print '
'; printf('
 '. '%s%s'. '%s%s'. @@ -326,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("", @@ -365,14 +358,15 @@ // Display the "new address" form + 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");