1: <?php
2: /**
3: * Copyright 2010-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2010-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Attach the passphrase dialog to the page.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2010-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Ajax_Imple_PassphraseDialog extends Horde_Core_Ajax_Imple
24: {
25: /**
26: * @param array $params Configuration parameters.
27: * - onload: (boolean) [OPTIONAL] If set, will trigger action on page
28: * load.
29: * - params: (array) [OPTIONAL] Any additional parameters to pass to
30: * AJAX action.
31: * - type: (string) The dialog type.
32: */
33: public function __construct(array $params = array())
34: {
35: parent::__construct($params);
36: }
37:
38: /**
39: */
40: protected function _attach($init)
41: {
42: global $page_output;
43:
44: if ($init) {
45: $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog');
46: $page_output->addScriptFile('passphrase.js', 'imp');
47: }
48:
49: $params = isset($this->_params['params'])
50: ? $this->_params['params']
51: : array();
52: if (isset($params['reload'])) {
53: $params['reload'] = strval($params['reload']);
54: }
55:
56: switch ($this->_params['type']) {
57: case 'pgpPersonal':
58: $text = _("Enter your personal PGP passphrase.");
59: break;
60:
61: case 'pgpSymmetric':
62: $text = _("Enter the passphrase used to encrypt this message.");
63: break;
64:
65: case 'smimePersonal':
66: $text = _("Enter your personal S/MIME passphrase.");
67: break;
68: }
69:
70: $js_params = array(
71: 'hidden' => array_merge($params, array('type' => $this->_params['type'])),
72: 'text' => $text
73: );
74:
75: $js = 'ImpPassphraseDialog.display(' . Horde::escapeJson($js_params, array('nodelimit' => true)) . ')';
76:
77: if (!empty($this->_params['onload'])) {
78: $page_output->addInlineScript(array($js), true);
79: return false;
80: }
81:
82: return $js;
83: }
84:
85: /**
86: */
87: protected function _handle(Horde_Variables $vars)
88: {
89: return false;
90: }
91:
92: }
93: