fixed $doedit check in order to be able to get to "Should not get here"
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 3 Mar 2005 16:42:31 +0000 (16:42 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 3 Mar 2005 16:42:31 +0000 (16:42 +0000)
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

index de712e846d9665d98e4a0a612ac4c0dce4b2584c..9f4c08b8af3a7d32f87c4529bcf345a0105a5456 100644 (file)
@@ -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').
                             '</form>';
                     }
-                } 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". '<strong><font color="' . $color[2] .
-                                            '">' . _("ERROR") . ': ' . $abook->error . '</font></strong>' ."\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" . '</form>';
-                            $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". '<strong><font color="' . $color[2] .
+                                                           '">' . _("ERROR") . ': ' . $abook->error . '</font></strong>' ."\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" . '</form>';
                         $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 */