Skip to content

Commit

Permalink
Use separate templates for personal and public certs.
Browse files Browse the repository at this point in the history
We use "public" vs. "private" in the S/MIME stuff like preference names etc. This is very confusing because we don't talk about public vs. private keys, but personal (user's) vs. public (address book's) keys.
  • Loading branch information
yunosh committed Dec 7, 2016
1 parent 675e595 commit b7d8fe3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 33 deletions.
20 changes: 11 additions & 9 deletions imp/lib/Basic/Smime.php
Expand Up @@ -39,7 +39,7 @@ protected function _init()
/* Run through the action handlers */
switch ($this->vars->actionID) {
case 'import_public_key':
$this->_importKeyDialog('process_import_public_key');
$this->_importKeyDialog('public');
break;

case 'process_import_public_key':
Expand All @@ -57,7 +57,7 @@ protected function _init()
}

$this->vars->actionID = 'import_public_key';
$this->_importKeyDialog('process_import_public_key');
$this->_importKeyDialog('public');
break;

case 'view_public_key':
Expand Down Expand Up @@ -86,7 +86,7 @@ protected function _init()
break;

case 'import_personal_certs':
$this->_importKeyDialog('process_import_personal_certs');
$this->_importKeyDialog('personal');
break;

case 'process_import_personal_certs':
Expand All @@ -102,7 +102,7 @@ protected function _init()
}

$this->vars->actionID = 'import_personal_certs';
$this->_importKeyDialog('process_import_personal_certs');
$this->_importKeyDialog('personal');
break;
}
}
Expand All @@ -115,9 +115,10 @@ public static function url(array $opts = array())
}

/**
* Generate import key dialog.
* Generates import key dialog.
*
* @param string $target Action ID for the UI screen.
* @param string $target Which dialog to generate, either 'personal' or
* 'public'.
*/
protected function _importKeyDialog($target)
{
Expand All @@ -132,7 +133,9 @@ protected function _importKeyDialog($target)
$p_css = new Horde_Themes_Element('prefs.css');
$page_output->addStylesheet($p_css->fs, $p_css->uri);

$this->title = _("Import Personal S/MIME Certificate");
$this->title = $target == 'personal'
? _("Import Personal S/MIME Certificate")
: _("Import Public S/MIME Key");

/* Need to use regular status notification - AJAX notifications won't
* show in popup windows. */
Expand All @@ -148,9 +151,8 @@ protected function _importKeyDialog($target)

$view->reload = $this->vars->reload;
$view->selfurl = self::url();
$view->target = $target;

$this->output = $view->render('import_key');
$this->output = $view->render('import_' . $target . '_key');
}

/**
Expand Down
10 changes: 6 additions & 4 deletions imp/package.xml
Expand Up @@ -22,7 +22,7 @@
<email>chuck@horde.org</email>
<active>no</active>
</lead>
<date>2016-07-11</date>
<date>2016-12-05</date>
<version>
<release>7.0.0</release>
<api>7.0.0</api>
Expand Down Expand Up @@ -1002,7 +1002,8 @@
<file name="search.html.php" role="horde" />
</dir> <!-- /templates/smartmobile -->
<dir name="smime">
<file name="import_key.html.php" role="horde" />
<file name="import_personal_key.html.php" role="horde" />
<file name="import_public_key.html.php" role="horde" />
</dir> <!-- /templates/smime -->
<dir name="subinfo">
<file name="subinfo.html.php" role="horde" />
Expand Down Expand Up @@ -2088,7 +2089,8 @@
<install as="imp/templates/smartmobile/mailbox.html.php" name="templates/smartmobile/mailbox.html.php" />
<install as="imp/templates/smartmobile/message.html.php" name="templates/smartmobile/message.html.php" />
<install as="imp/templates/smartmobile/search.html.php" name="templates/smartmobile/search.html.php" />
<install as="imp/templates/smime/import_key.html.php" name="templates/smime/import_key.html.php" />
<install as="imp/templates/smime/import_personal_key.html.php" name="templates/smime/import_personal_key.html.php" />
<install as="imp/templates/smime/import_public_key.html.php" name="templates/smime/import_public_key.html.php" />
<install as="imp/templates/subinfo/subinfo.html.php" name="templates/subinfo/subinfo.html.php" />
<install as="imp/templates/test/mailserver.inc" name="templates/test/mailserver.inc" />
<install as="imp/templates/thread/thread.html.php" name="templates/thread/thread.html.php" />
Expand Down Expand Up @@ -3963,7 +3965,7 @@
</notes>
</release>
<release>
<date>2016-07-11</date>
<date>2016-12-05</date>
<version>
<release>7.0.0</release>
<api>7.0.0</api>
Expand Down
@@ -1,36 +1,18 @@
<form enctype="multipart/form-data" method="post" name="import_smime_key" action="<?php echo $this->selfurl ?>">
<input type="hidden" name="reload" value="<?php echo $this->h($this->reload) ?>" />
<input type="hidden" name="actionID" value="<?php echo $this->target ?>" />
<input type="hidden" name="actionID" value="process_import_personal_certs" />

<h1 class="header">
<?php if ($this->target == 'process_import_public_key'): ?>
<?php echo _("Import Public S/MIME Key") ?>
<?php else: ?>
<?php echo _("Import Personal S/MIME Certificate") ?>
<?php endif ?>
</h1>

<?php if ($this->target == 'process_import_public_key'): ?>
<p class="horde-content">
<label class="importKeyText">
<?php echo _("Insert Certificate Here") ?>:<br />
<textarea id="import_key" name="import_key" rows="6" cols="80" class="fixed"></textarea>
</label>
</p>

<span class="horde-content importKeyOr">
--<?php echo _("OR") ?>--
</span>
<?php endif ?>

<div class="horde-content">
<label class="importKeyUpload">
<?php echo _("Upload") ?>:
<input id="upload_key" name="upload_key" type="file" size="40" />
</label>
</div>

<?php if ($this->target == 'process_import_personal_certs'): ?>
<div class="horde-content">
<label class="importKeyText">
<?php echo _("Password of Uploaded Certificate") ?>:<br />
Expand All @@ -43,7 +25,6 @@
<input id="upload_key_pk_pass" name="upload_key_pk_pass" type="password" size="30" />
</label>
</div>
<?php endif ?>

<p class="horde-form-buttons">
<input type="submit" name="import" class="horde-default" value="<?php echo _("Import") ?>" />
Expand Down
31 changes: 31 additions & 0 deletions imp/templates/smime/import_public_key.html.php
@@ -0,0 +1,31 @@
<form enctype="multipart/form-data" method="post" name="import_smime_key" action="<?php echo $this->selfurl ?>">
<input type="hidden" name="reload" value="<?php echo $this->h($this->reload) ?>" />
<input type="hidden" name="actionID" value="process_import_public_key" />

<h1 class="header">
<?php echo _("Import Public S/MIME Key") ?>
</h1>

<p class="horde-content">
<label class="importKeyText">
<?php echo _("Insert Certificate Here") ?>:<br />
<textarea id="import_key" name="import_key" rows="6" cols="80" class="fixed"></textarea>
</label>
</p>

<span class="horde-content importKeyOr">
--<?php echo _("OR") ?>--
</span>

<div class="horde-content">
<label class="importKeyUpload">
<?php echo _("Upload") ?>:
<input id="upload_key" name="upload_key" type="file" size="40" />
</label>
</div>

<p class="horde-form-buttons">
<input type="submit" name="import" class="horde-default" value="<?php echo _("Import") ?>" />
<input type="submit" name="cancel" class="horde-cancel" value="<?php echo _("Cancel") ?>" />
</p>
</form>

0 comments on commit b7d8fe3

Please sign in to comment.