<form method="post" name="smime" action="<?php echo $selfURL ?>">
<input type="hidden" name="smimeActionID" value="" />

<table border="0" align="center" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td align="left" class="header" nowrap="nowrap"><b><?php echo _("S/MIME Options") ?></b></td>
    <?php PrefsUI::generateNavigationCell('smime') ?>
  </tr>

  <tr>
    <td class="item" align="left" colspan="2">
      <table border="0" cellpadding="0" width="100%">
        <tr>
          <td class="item" align="left">&nbsp;
            <input id="use_smime" type="checkbox" name="use_smime" <?php echo ($prefs->getValue('use_smime')) ? "checked=\"checked\"" : "" ?> /><?php echo Horde::label('use_smime', _("Enable S/MIME functionality?")) ?>
          </td>
          <td class="item" align="right"><?php echo Help::link('imp', 'smime-overview') ?></td>
        </tr>
      </table>
    </td>
  </tr>

  <tr>
    <td colspan="3" nowrap="nowrap" align="left" class="header" valign="middle">
      <input type="submit" name="save" class="button" onclick="document.smime.smimeActionID.value='save_options';return true;" value="<?php echo _("Save Options") ?>" />
    </td>
  </tr>

  <tr rowspan="2"><td>&nbsp;</td></tr>

  <tr>
    <td align="left" class="header" nowrap="nowrap"><b><?php echo _("Your S/MIME Public/Private Keys") ?></b></td>
    <td class="header" align="right"><?php echo Help::link('imp', 'smime-overview-personalkey') ?></td>
  </tr>

  <tr>
    <td class="item" align="left" colspan="2">
      <table border="0" cellpadding="0" width="100%">
<?php if (is_a($secure_check, 'PEAR_Error')): ?>
        <tr>
          <td class="item" align="left">&nbsp;<b><?php echo _("S/MIME Personal Keypair support requires a secure web connection.") ?></b></td>
        </tr>
      </table>
    </td>
  </tr>
<?php elseif ($prefs->getValue('smime_public_key') && $prefs->getValue('smime_private_key')): ?>
<?php $unload_url = Horde::addParameter($selfURL, 'smimeActionID', 'unset_passphrase'); ?>
        <tr nowrap="nowrap">
          <td class="item" align="left" colspan="2"><b>&nbsp;<?php echo _("Your Public Key") ?>:</b></td>
          <td class="item" align="right"><?php echo Help::link('imp', 'smime-personalkey-public') ?></td>
        </tr>
        <tr>
          <td class="item" align="left"><b>&nbsp;<?php echo _("Your Private Key") ?>:</b></td>
          <td class="item" align="left">&nbsp;&nbsp;[<?php echo (empty($passphrase)) ? Horde::link('', _("Enter Passphrase"), null, null, $opensmimewin . ' return false;') . _("Enter Passphrase") : Horde::link($unload_url, _("Unload Passphrase")) . _("Unload Passphrase") ?></a>]</td>
          <td class="item" align="right"><?php echo Help::link('imp', 'smime-personalkey-private') ?></td>
        </tr>
        <tr nowrap="nowrap">
          <td class="item" align="left" colspan="2"><b>&nbsp;<?php echo _("Any Additional Signing Certificate") ?>:</b></td>
          <td class="item" align="left"></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="header" align="left" colspan="2">
      <table border="0" cellspacing="0" cellpadding="0" width="100%">
        <tr nowrap="nowrap">
          <td align="left" valign="middle">
            <input type="submit" name="delete" class="button" onclick="if (confirm('<?php echo addslashes(_("Are you sure you want to delete your keypair? (This is NOT recommended!)")) ?>')) { document.smime.smimeActionID.value='delete_key'; return true; } else { return false; }" value="<?php echo _("Delete Current Keys") ?>" />
          </td>
          <td align="right"><?php echo Help::link('imp', 'smime-personalkey-delete') ?></td>
        </tr>
      </table>
    </td>
  </tr>
<?php else: ?>
<?php
    require_once HORDE_BASE . '/lib/Identity.php';
    $imp_identity = &Identity::singleton(array('imp', 'imp'));
    $personal_import_url = Horde::addParameter($selfURL, 'smimeActionID', 'import_personal_public_key');
?>
<?php if ($imp['file_upload']): ?>
        <tr nowrap="nowrap">
          <td align="left" valign="middle">
            <input type="submit" name="save" class="button" onclick="open_smime_import('<?php echo $personal_import_url ?>');return false;" value="<?php echo _("Import Keypair") ?>" />
          </td>
          <td align="right"><?php echo Help::link('imp', 'smime-personalkey-create-actions') ?></td>
        </tr>
      </table>
    </td>
  </tr>
<?php endif; ?>
<?php endif; ?>
  <tr rowspan="2"><td>&nbsp;</td></tr>

  <tr>
    <td class="header" align="left" nowrap="nowrap">
      <input type="button" name="back" class="button" onclick="document.location.href='<?php echo Horde::applicationUrl('prefs.php', true) ?>'" value="<?php echo _("Return to Main Preferences Screen") ?>" />
    </td>
    <td class="header">&nbsp;</td>
  </tr>
</table>

</form>
