-echo '</table>' .
- '<br>' .
- '</td></tr></table>' .
- '<table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
- 'align="center">' .
- '<tr>' .
- '<td bgcolor="' . $color[0] . '">' .
- '<b><center>' .
- _("Add to Addressbook") .
- '</td></tr>' .
- '<tr><td align=center>' .
- '<FORM ACTION="../src/addressbook.php" METHOD="POST" NAME=f_add>' .
- '<table border=0 cellpadding=2 cellspacing=0 align=center>' .
- '<tr><td align=right><b>Nickname:</b></td>' .
- '<td><input type=text name="addaddr[nickname]" size=20 value="' .
- $vcard_safe['firstname'] . '-' . $vcard_safe['lastname'] .
- '"></td></tr>' .
- '<tr><td align=right><b>Note Field Contains:</b></td><td>' .
- '<select name="addaddr[label]">';
+?>
+</table>
+<br />
+</td></tr></table>
+<table width="100%" border="0" cellspacing="0" cellpadding="2" align="center">
+<tr><td bgcolor="<?php echo $color[0]; ?>">
+<div style="text-align: center;"><b><?php echo _("Add to address book"); ?></b></div>
+</td></tr>
+<tr><td align="center">
+<?php echo addForm('../src/addressbook.php', 'post', 'f_add'); ?><br />
+<table border="0" cellpadding="2" cellspacing="0" align="center">
+<tr><td align="right"><b><?php echo _("Nickname"); ?>:</b></td>
+<td>
+<?php
+
+echo addInput('addaddr[nickname]', $vcard_safe['firstname'] .
+ '-' . $vcard_safe['lastname'], '20');
+
+/*
+ * If the vCard comes with an e-mail address it should be added to the
+ * address book, otherwise the user must add one manually to avoid an
+ * error message in src/addressbook.php. SquirrelMail is nice enough to
+ * suggest the e-mail address of the sender though.
+ */
+if (isset($vcard_nice['email;internet'])) {
+ echo addHidden('addaddr[email]', $vcard_nice['email;internet']);
+} else {
+ $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
+ $header = $message->rfc822_header;
+ $from_name = $header->getAddr_s('from');
+
+ echo '</td></tr>' .
+ '<tr><td align="right"><b>' . _("E-mail address") . ':</b></td><td>' .
+ addInput('addaddr[email]',
+ getEmail(decodeHeader($from_name)), '20');
+}
+
+echo '</td></tr>' .
+ '<tr><td align="right"><b>' . _("Additional info") . ':</b></td><td>';