Author: Michael Slusarz (slusarz@horde.org)
Inheritance: extends IMP_Basic_Base
Example #1
0
 /**
  */
 public function display(Horde_Core_Prefs_Ui $ui)
 {
     global $injector, $page_output, $prefs, $session;
     $page_output->addScriptPackage('IMP_Script_Package_Imp');
     $imp_pgp = $injector->getInstance('IMP_Crypt_Pgp');
     /* Get list of Public Keys on keyring. */
     try {
         $pubkey_list = $imp_pgp->listPublicKeys();
     } catch (Horde_Exception $e) {
         $pubkey_list = array();
     }
     $pgp_url = IMP_Basic_Pgp::url();
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs'));
     $view->addHelper('Horde_Core_View_Helper_Help');
     $view->addHelper('Text');
     if (!empty($pubkey_list)) {
         $plist = array();
         $self_url = $ui->selfUrl(array('special' => true, 'token' => true));
         foreach ($pubkey_list as $val) {
             $plist[] = array('name' => $val['name'], 'email' => $val['email'], 'view' => Horde::link($pgp_url->copy()->add(array('actionID' => 'view_public_key', 'email' => $val['email'])), sprintf(_("View %s Public Key"), $val['name']), null, 'view_key'), 'info' => Horde::link($pgp_url->copy()->add(array('actionID' => 'info_public_key', 'email' => $val['email'])), sprintf(_("Information on %s Public Key"), $val['name']), null, 'info_key'), 'delete' => Horde::link($self_url->copy()->add(array('delete_pgp_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?")) . "')"));
         }
         $view->pubkey_list = $plist;
     }
     if ($session->get('imp', 'file_upload')) {
         $view->can_import = true;
         $view->no_source = !$prefs->getValue('add_source');
         if (!$view->no_source) {
             $page_output->addInlineScript(array('$("import_pgp_public").observe("click", function(e) { ' . Horde::popupJs($pgp_url, array('params' => array('actionID' => 'import_public_key', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 275, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'), true);
         }
     }
     return $view->render('pgppublickey');
 }
Example #2
0
 /**
  */
 public function display(Horde_Core_Prefs_Ui $ui)
 {
     global $browser, $conf, $injector, $page_output, $prefs;
     $page_output->addScriptPackage('IMP_Script_Package_Imp');
     $p_css = new Horde_Themes_Element('prefs.css');
     $page_output->addStylesheet($p_css->fs, $p_css->uri);
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs'));
     $view->addHelper('Horde_Core_View_Helper_Help');
     if (!Horde::isConnectionSecure()) {
         $view->notsecure = true;
     } else {
         $pgp_url = IMP_Basic_Pgp::url();
         $view->has_key = $prefs->getValue('pgp_public_key') && $prefs->getValue('pgp_private_key');
         if ($view->has_key) {
             $view->viewpublic = Horde::link($pgp_url->copy()->add('actionID', 'view_personal_public_key'), _("View Personal Public Key"), null, 'view_key');
             $view->infopublic = Horde::link($pgp_url->copy()->add('actionID', 'info_personal_public_key'), _("Information on Personal Public Key"), null, 'info_key');
             $view->sendkey = Horde::link($ui->selfUrl(array('special' => true, 'token' => true))->add('send_pgp_key', 1), _("Send Key to Public Keyserver"));
             if ($injector->getInstance('IMP_Pgp')->getPassphrase('personal')) {
                 $view->passphrase = Horde::link($ui->selfUrl(array('special' => true, 'token' => true))->add('unset_pgp_passphrase', 1), _("Unload Passphrase")) . _("Unload Passphrase");
             } else {
                 $imple = $injector->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_PassphraseDialog', array('params' => array('reload' => $ui->selfUrl()->setRaw(true)), 'type' => 'pgpPersonal'));
                 $view->passphrase = Horde::link('#', _("Enter Passphrase"), null, null, null, null, null, array('id' => $imple->getDomId())) . _("Enter Passphrase");
             }
             $view->viewprivate = Horde::link($pgp_url->copy()->add('actionID', 'view_personal_private_key'), _("View Personal Private Key"), null, 'view_key');
             $view->infoprivate = Horde::link($pgp_url->copy()->add('actionID', 'info_personal_private_key'), _("Information on Personal Private Key"), null, 'info_key');
             $page_output->addInlineScript(array('$("delete_pgp_privkey").observe("click", function(e) { if (!window.confirm(' . json_encode(_("Are you sure you want to delete your keypair? (This is NOT recommended!)")) . ')) { e.stop(); } })'), true);
         } else {
             $page_output->addScriptFile('prefs/pgp.js');
             Horde_Core_Ui_JsCalendar::init();
             $page_output->addInlineJsVars(array('ImpPgp.months' => Horde_Core_Ui_JsCalendar::months()));
             $imp_identity = $injector->getInstance('IMP_Identity');
             $view->fullname = $imp_identity->getFullname();
             $view->fromaddr = $imp_identity->getFromAddress()->bare_address;
             if (!empty($conf['pgp']['keylength'])) {
                 $view->create_pgp_keypair = true;
                 $page_output->addInlineScript(array('$("create_pgp_key").observe("click", function(e) { if (!window.confirm(' . json_encode(_("Key generation may take a long time to complete.  Continue with key generation?")) . ')) { e.stop(); } })'), true);
             }
             if ($browser->allowFileUploads()) {
                 $view->import_pgp_private = true;
                 $page_output->addInlineScript(array('$("import_pgp_personal").observe("click", function(e) { ' . Horde::popupJs($pgp_url, array('params' => array('actionID' => 'import_personal_key', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 300, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'), true);
             }
         }
     }
     return $view->render('pgpprivatekey');
 }