From 3e87f87092b40b8ad2c3a3508b6a8ddcea1563f5 Mon Sep 17 00:00:00 2001 From: tokul Date: Thu, 3 Mar 2005 16:42:31 +0000 Subject: [PATCH] fixed $doedit check in order to be able to get to "Should not get here" simplified if structure. added simple error message instead of unknown error. $doedit fix should recreate #1124018 situation and changed error message should fix it. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@8932 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/addressbook.php | 61 ++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/src/addressbook.php b/src/addressbook.php index de712e84..9f4c08b8 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -148,7 +148,6 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P * Update/modify address * ***********************************************/ if (!empty($editaddr)) { - /* Stage one: Copy data into form */ if (isset($sel) && sizeof($sel) > 0) { if(sizeof($sel) > 1) { @@ -167,40 +166,40 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P addHidden('doedit', '1'). ''; } - } else { - + } elseif ($doedit == 1) { /* Stage two: Write new data */ - if ($doedit = 1) { - $newdata = $editaddr; - $r = $abook->modify($oldnick, $newdata, $backend); - - /* Handle error messages */ - if (!$r) { - /* Display error */ - echo html_tag( 'table', - html_tag( 'tr', - html_tag( 'td', - "\n". '' . _("ERROR") . ': ' . $abook->error . '' ."\n", - 'center' ) - ), - 'center', '', 'width="100%"' ); - - /* Display the "new address" form again */ - abook_create_form($form_url,'editaddr',_("Update address"),_("Update address"),$newdata); - echo addHidden('oldnick', $oldnick). - addHidden('backend', $backend). - addHidden('doedit', '1'). - "\n" . ''; - $abortform = true; - } - } else { + $newdata = $editaddr; + $r = $abook->modify($oldnick, $newdata, $backend); - /* Should not get here... */ - plain_error_message(_("Unknown error"), $color); + /* Handle error messages */ + if (!$r) { + /* Display error */ + echo html_tag( 'table', + html_tag( 'tr', + html_tag( 'td', + "\n". '' . _("ERROR") . ': ' . $abook->error . '' ."\n", + 'center' ) + ), + 'center', '', 'width="100%"' ); + + /* Display the "new address" form again */ + abook_create_form($form_url,'editaddr',_("Update address"),_("Update address"),$newdata); + echo addHidden('oldnick', $oldnick). + addHidden('backend', $backend). + addHidden('doedit', '1'). + "\n" . ''; $abortform = true; } - } + } else { + /** + * $editaddr is set, but $sel (address selection in address listing) + * and $doedit (address edit form) are not set. + * Assume that user clicked on "Edit address" without selecting any address. + */ + $formerror = _("Please select address that you want to edit"); + $showaddrlist = true; + } /* end of edit stage detection */ } /* !empty($editaddr) - Update/modify address */ } /* (!empty($deladdr)) && sizeof($sel) > 0 - Delete address(es) */ } /* !empty($addaddr['nickname']) - Add new address */ -- 2.25.1