+ } else {
+
+ // ***********************************************
+ // Update/modify address
+ // ***********************************************
+ if(!empty($editaddr)) {
+
+ // Stage one: Copy data into form
+ 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) = explode(':', $sel[0]);
+ $olddata = $abook->lookup($enick, $ebackend);
+
+ // Display the "new address" form
+ print "<FORM ACTION=\"$PHP_SELF\" METHOD=\"POST\">\n";
+ print "<TABLE WIDTH=100% COLS=1 ALIGN=CENTER>\n";
+ print "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>\n<STRONG>";
+ print _("Update address");
+ print "<STRONG>\n</TD></TR>\n";
+ print "</TABLE>\n";
+ address_form("editaddr", _("Update address"), $olddata);
+ printf("<INPUT TYPE=hidden NAME=oldnick VALUE=\"%s\">\n",
+ htmlspecialchars($olddata["nickname"]));
+ printf("<INPUT TYPE=hidden NAME=backend VALUE=\"%s\">\n",
+ htmlspecialchars($olddata["backend"]));
+ print "<INPUT TYPE=hidden NAME=doedit VALUE=1>\n";
+ print '</FORM>';
+ }
+ } else {
+
+ // Stage two: Write new data
+ if($doedit = 1) {
+ $newdata = $editaddr;
+ $r = $abook->modify($oldnick, $newdata, $backend);
+
+ // Handle error messages
+ if(!$r) {
+ // Display error
+ print "<TABLE WIDTH=100% COLS=1 ALIGN=CENTER>\n";
+ print "<TR><TD ALIGN=CENTER>\n<br><STRONG>";
+ print "<FONT COLOR=\"$color[2]\">"._("ERROR").": ".
+ $abook->error."</FONT>";
+ print "<STRONG>\n</TD></TR>\n";
+ print "</TABLE>\n";
+
+ // Display the "new address" form again
+ printf("<FORM ACTION=\"%s\" METHOD=\"POST\">\n", $PHP_SELF);
+ print "<TABLE WIDTH=100% COLS=1 ALIGN=CENTER>\n";
+ print "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>\n<STRONG>";
+ print _("Update address");
+ print "<STRONG>\n</TD></TR>\n";
+ print "</TABLE>\n";
+ address_form("editaddr", _("Update address"), $newdata);
+ printf("<INPUT TYPE=hidden NAME=oldnick VALUE=\"%s\">\n",
+ htmlspecialchars($oldnick));
+ printf("<INPUT TYPE=hidden NAME=backend VALUE=\"%s\">\n",
+ htmlspecialchars($backend));
+ print "<INPUT TYPE=hidden NAME=doedit VALUE=1>\n";
+ print '</FORM>';
+
+ $abortform = true;
+ }
+ } else {
+
+ // Should not get here...
+ plain_error_message(_("Unknown error"), $color);
+ $abortform = true;
+ }
+ }
+ } /* !empty($editaddr) - Update/modify address */
+ } /* (!empty($deladdr)) && sizeof($sel) > 0 - Delete address(es) */
+ } /* !empty($addaddr['nickname']) - Add new address */
+
+ // Some times we end output before forms are printed
+ if($abortform) {
+ print "</BODY></HTML>\n";
+ exit();