drop very old and very obsolete function
[squirrelmail.git] / src / addressbook.php
index 68d852447563e71807af773edc16b78564e66bec..7b9339231f57ea07ce734e8a63f1f55abb63cccb 100644 (file)
@@ -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 */
@@ -311,22 +314,25 @@ if ($showaddrlist) {
             }
             echo html_tag( 'tr', '', '', $tr_bgcolor);
             if ($abook->backends[$row['backend']]->writeable) {
+                $id = $row['backend'].':'.$row['nickname'];
                 echo html_tag( 'td',
                                '<small>' .
-                               addCheckBox('sel[]', $selected, $row['backend'].':'.$row['nickname']).
+                               addCheckBox("sel[$id]", $selected, $id).
                                '</small>' ,
                                'center', '', 'valign="top" width="1%"' );
+                $label1 = '<label for="sel_'.$id.'_">'; $label2='</label>';
             } else {
                 echo html_tag( 'td',
                                '&nbsp;' ,
                                'center', '', 'valign="top" width="1%"' );
+                $label1 = $label2 = '';
             }
             echo html_tag( 'td',
-                           '&nbsp;' . htmlspecialchars($row['nickname']) . '&nbsp;',
+                           '&nbsp;' . $label1 . htmlspecialchars($row['nickname']) . $label2 . '&nbsp;',
                            'left', '', 'valign="top" width="1%" style="white-space: nowrap;"' );
 
             echo html_tag( 'td',
-                           '&nbsp;' . htmlspecialchars($row['name']) . '&nbsp;',
+                           '&nbsp;' . $label1 . htmlspecialchars($row['name']) . $label2 . '&nbsp;',
                            'left', '', 'valign="top" width="1%" style="white-space: nowrap;"' );
 
             // email address column
@@ -377,4 +383,4 @@ echo "<!-- start of addressbook_bottom hook-->\n";
 do_hook('addressbook_bottom');
 echo "\n<!-- end of addressbook_bottom hook-->\n";
 $oTemplate->display('footer.tpl');
-?>
\ No newline at end of file
+?>