Jelajahi Sumber

older code used sel[] name in list form. Label code added backend id and
nickname. extracting array value with current() instead of using index.
$sel is also used when address book entry is deleted, but array is
reindexed there.

tokul 19 tahun lalu
induk
melakukan
34e888f970
1 mengubah file dengan 12 tambahan dan 9 penghapusan
  1. 12 9
      src/addressbook.php

+ 12 - 9
src/addressbook.php

@@ -147,16 +147,19 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P
                         $defselected = $sel;
                     } else {
                         $abortform = true;
-                        list($ebackend, $enick) = explode(':', $sel[0]);
+                        list($ebackend, $enick) = explode(':', current($sel));
                         $olddata = $abook->lookup($enick, $ebackend);
-                        // FIXME: Test if $olddata really contains anything and return an error message if it doesn't
-
-                        /* Display the "new address" form */
-                        abook_create_form($form_url,'editaddr',_("Update address"),_("Update address"),$olddata);
-                        echo addHidden('oldnick', $olddata['nickname']).
-                            addHidden('backend', $olddata['backend']).
-                            addHidden('doedit', '1').
-                            '</form>';
+                        // Test if $olddata really contains anything and return an error message if it doesn't
+                        if (!$olddata) {
+                            error_box(nl2br(htmlspecialchars($abook->error)));
+                        } else {
+                            /* Display the "new address" form */
+                            abook_create_form($form_url,'editaddr',_("Update address"),_("Update address"),$olddata);
+                            echo addHidden('oldnick', $olddata['nickname']).
+                                addHidden('backend', $olddata['backend']).
+                                addHidden('doedit', '1').
+                                '</form>';
+                        }
                     }
                 } elseif ($doedit == 1) {
                     /* Stage two: Write new data */