Skip to content

Commit

Permalink
lots more work on PGP support
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmunro committed Oct 10, 2018
1 parent d0736af commit b339b2b
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 60 deletions.
26 changes: 16 additions & 10 deletions modules/pgp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ protected function output() {
$res = '<script type="text/javascript" src="modules/pgp/assets/openpgp.min.js"></script>';
$res .= '<div class="pgp_section">';

$res .= '<div class="pgp_sign"><label for="pgp_sign">'.$this->trans('PGP Sign').'</label>';
$res .= '<select id="pgp_sign" size="1"></select></div>';
$res .= '<span class="pgp_sign"><label for="pgp_sign">'.$this->trans('PGP Sign as:').'</label>';
$res .= '<select id="pgp_sign" size="1"></select></span>';

if (count($pub_keys) > 0) {
$res .= '<label for="pgp_encrypt">'.$this->trans('Encrypt for:').
$res .= '<label for="pgp_encrypt">'.$this->trans('PGP Encrypt for:').
'</label><select id="pgp_encrypt" size="1"><option disabled selected value=""></option>';
foreach ($pub_keys as $vals) {
$res .= '<option value="'.$vals['key'].'">'.$vals['email'].'</option>';
}
$res .= '</select>';
}
$res .= '</div>';
$res .= '<input type="button" class="pgp_apply" value="'.$this->trans('Apply').'" /></div>'.prompt_for_passhrase($this);
return $res;
}
}
Expand Down Expand Up @@ -173,13 +173,11 @@ protected function output() {
class Hm_Output_pgp_settings_private_key extends Hm_Output_Module {
protected function output() {
$res = '<div class="priv_title settings_subtitle">'.$this->trans('Private Keys');
$res .= '<span class="key_count">'.sprintf($this->trans('%s imported'), 0).'</span></div>';
$res .= '<span class="private_key_count">'.sprintf($this->trans('%s imported'), 0).'</span></div>';
$res .= '<div class="priv_keys pgp_block"><div class="pgp_subblock">';
$res .= $this->trans('Private keys never leave your browser, and are deleted when you logout');
$res .= '<br /><br /><input id="priv_key" type="file"> for <input id="priv_email" placeholder="'.$this->trans('E-mail Address');
$res .= '" type="email"> <input type="button" value="'.$this->trans('Import').'">';
$res .= '</div>'.$this->trans('Existing Keys').'<table class="pgp_keys"><thead><tr><th>'.$this->trans('Key').'</th>';
$res .= '<th>'.$this->trans('E-mail').'</th></tr>';
$res .= '<br /><br /><input id="priv_key" type="file">';
$res .= '</div>'.$this->trans('Existing Keys').'<table class="pgp_keys private_key_list"><thead><tr><th>'.$this->trans('Identity').'</th><th></th></tr>';
$res .= '</thead><tbody></tbody></table>';
$res .= '</div>';
return $res;
Expand All @@ -200,7 +198,8 @@ protected function output() {
*/
class Hm_Output_pgp_msg_controls extends Hm_Output_Module {
protected function output() {
return '<div class="pgp_msg_controls"><select class="pgp_private_keys"></select> <input type="button" class="pgp_btn" value="Decrypt" /></div>';
return '<script type="text/javascript" src="modules/pgp/assets/openpgp.min.js"></script>'.
'<div class="pgp_msg_controls"><select class="pgp_private_keys"></select> <input type="button" class="pgp_btn" value="Decrypt" /></div>'.prompt_for_passhrase($this);
}
}

Expand Down Expand Up @@ -247,3 +246,10 @@ function validate_public_key($file_location) {
}
return false;
}

/**
* @subpackage pgp/functions
*/
function prompt_for_passhrase($mod) {
return '<div class="passphrase_prompt"><div class="title">'.$mod->trans('Please enter your passphrase').'</div><input type="password" value="" id="pgp_pass" /> <input id="submit_pgp_pass" type="button" value="'.$mod->trans('Submit').'" /></div>';
}
2 changes: 1 addition & 1 deletion modules/pgp/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
add_output('ajax_hm_folders', 'pgp_settings_link', true, 'pgp', 'settings_menu_end', 'before');

add_handler('compose', 'pgp_compose_data', true, 'pgp', 'load_user_data', 'after');
add_output('compose', 'pgp_compose_controls', true, 'pgp', 'compose_form_end', 'before');
add_output('compose', 'pgp_compose_controls', true, 'pgp', 'compose_form_end', 'after');

return array(
'allowed_pages' => array('pgp'),
Expand Down
7 changes: 4 additions & 3 deletions modules/pgp/site.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
.pgp_section { float: right; margin-right: 10px; margin-top: 10px; }
.pgp_section { width: 80%; margin-left: 50px; text-align: right; }
.pgp_section input, .pgp_section label, .pgp_section select { margin-right: 10px; }
.pgp_section select { overflow-y: auto; }
.pgp_block { margin-bottom: 30px; margin-left: 40px; padding-top: 20px; }
.pgp_keys { padding-left: 30px; margin-top: 20px; }
.pgp_keys { width: 50%; padding-left: 30px; margin-top: 20px; }
.pgp_keys th { color: #666; padding: 5px; padding-bottom: 2px; border-bottom: solid 1px #eee; font-weight: normal; text-align: left; }
.pgp_keys td { padding: 10px; }
.pgp_keys td img { opacity: .6; }
.pgp_subblock { margin-bottom: 40px; }
.priv_keys, .public_keys { display: none; }
.key_count { float: right; margin-right: 120px; font-size: 90%; }
.private_key_count, .key_count { float: right; margin-right: 120px; font-size: 90%; }
.pgp_msg_controls { display: none; position: absolute; right: 20px; top: 70px; }
.pgp_sign { display: none; }
.delete_pgp_key { border: none !important; width: 16px; height: 16px; cursor: pointer; opacity: .7}
.passphrase_prompt { display: none; text-align: center; top: 0px; padding: 20px; background-color: #fff; position: absolute; z-index: 101; left: 0; right: 0; margin: auto; width: 300px; border: solid 1px #ccc; border-top: none; }
Loading

0 comments on commit b339b2b

Please sign in to comment.