1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Prefs_Special_SmimePublicKey implements Horde_Core_Prefs_Ui_Special
24: {
25: 26:
27: public function init(Horde_Core_Prefs_Ui $ui)
28: {
29: }
30:
31: 32:
33: public function display(Horde_Core_Prefs_Ui $ui)
34: {
35: global $injector, $page_output, $prefs, $session;
36:
37: $page_output->addScriptPackage('IMP_Script_Package_Imp');
38:
39: $imp_smime = $injector->getInstance('IMP_Crypt_Smime');
40:
41:
42: try {
43: $pubkey_list = $imp_smime->listPublicKeys();
44: } catch (Horde_Exception $e) {
45: $pubkey_list = array();
46: }
47:
48: $smime_url = IMP_Basic_Smime::url();
49:
50: $view = new Horde_View(array(
51: 'templatePath' => IMP_TEMPLATES . '/prefs'
52: ));
53: $view->addHelper('Horde_Core_View_Helper_Help');
54: $view->addHelper('Text');
55:
56: if (!empty($pubkey_list)) {
57: $plist = array();
58: $self_url = $ui->selfUrl(array('special' => true, 'token' => true));
59:
60: foreach ($pubkey_list as $val) {
61: $plist[] = array(
62: 'name' => $val['name'],
63: 'email' => $val['email'],
64: 'view' => Horde::link($smime_url->copy()->add(array('actionID' => 'view_public_key', 'email' => $val['email'])), sprintf(_("View %s Public Key"), $val['name']), null, 'view_key'),
65: 'info' => Horde::link($smime_url->copy()->add(array('actionID' => 'info_public_key', 'email' => $val['email'])), sprintf(_("Information on %s Public Key"), $val['name']), null, 'info_key'),
66: 'delete' => Horde::link($self_url->copy()->add(array('delete_smime_pubkey' => 1, 'email' => $val['email'])), sprintf(_("Delete %s Public Key"), $val['name']), null, null, "window.confirm('" . addslashes(_("Are you sure you want to delete this public key?")) . "')")
67: );
68: }
69: $view->pubkey_list = $plist;
70: }
71:
72: if ($session->get('imp', 'file_upload')) {
73: $view->can_import = true;
74: $view->no_source = !$prefs->getValue('add_source');
75: if (!$view->no_source) {
76: $page_output->addInlineScript(array(
77: '$("import_smime_public").observe("click", function(e) { ' . Horde::popupJs($smime_url, array('params' => array('actionID' => 'import_public_key', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 275, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'
78: ), true);
79: }
80: }
81:
82: return $view->render('smimepublickey');
83: }
84:
85: 86:
87: public function update(Horde_Core_Prefs_Ui $ui)
88: {
89: global $injector, $notification;
90:
91: if (isset($ui->vars->delete_smime_pubkey)) {
92: try {
93: $injector->getInstance('IMP_Crypt_Smime')->deletePublicKey($ui->vars->email);
94: $notification->push(sprintf(_("S/MIME Public Key for \"%s\" was successfully deleted."), $ui->vars->email), 'horde.success');
95: } catch (Horde_Exception $e) {
96: $notification->push($e);
97: }
98: }
99:
100: return false;
101: }
102:
103: }
104: