| | |
| | | $now = time(); |
| | | $date_format = $this->rc->config->get('date_format', 'Y-m-d'); |
| | | $usage_map = array( |
| | | enigma_key::CAN_ENCRYPT => $this->enigma->gettext('typeencrypt'), |
| | | enigma_key::CAN_SIGN => $this->enigma->gettext('typesign'), |
| | | enigma_key::CAN_CERTIFY => $this->enigma->gettext('typecert'), |
| | | enigma_key::CAN_AUTH => $this->enigma->gettext('typeauth'), |
| | | enigma_key::CAN_ENCRYPT => $this->enigma->gettext('typeencrypt'), |
| | | enigma_key::CAN_SIGN => $this->enigma->gettext('typesign'), |
| | | enigma_key::CAN_CERTIFY => $this->enigma->gettext('typecert'), |
| | | enigma_key::CAN_AUTHENTICATE => $this->enigma->gettext('typeauth'), |
| | | ); |
| | | |
| | | foreach ($this->data->subkeys as $subkey) { |
| | |
| | | */ |
| | | private function key_export() |
| | | { |
| | | $this->rc->request_security_check(rcube_utils::INPUT_GET); |
| | | |
| | | $keys = rcube_utils::get_input_value('_keys', rcube_utils::INPUT_GPC); |
| | | $engine = $this->enigma->load_engine(); |
| | | $list = $keys == '*' ? $engine->list_keys() : explode(',', $keys); |
| | |
| | | $part_id = $p['part']->mime_id; |
| | | |
| | | // Decryption status |
| | | if (isset($engine->decryptions[$part_id])) { |
| | | if (($found = $this->find_part_id($part_id, $engine->decryptions)) !== null |
| | | && ($status = $engine->decryptions[$found]) |
| | | ) { |
| | | $attach_scripts = true; |
| | | |
| | | // get decryption status |
| | | $status = $engine->decryptions[$part_id]; |
| | | // show the message only once |
| | | unset($engine->decryptions[$found]); |
| | | |
| | | // display status info |
| | | $attrib['id'] = 'enigma-message'; |
| | |
| | | $this->enigma->gettext('decryptnokey'))); |
| | | } |
| | | else if ($code == enigma_error::BADPASS) { |
| | | $msg = rcube::Q($this->enigma->gettext('decryptbadpass')); |
| | | $missing = $status->getData('missing'); |
| | | $label = 'decrypt' . (!empty($missing) ? 'no' : 'bad') . 'pass'; |
| | | $msg = rcube::Q($this->enigma->gettext($label)); |
| | | $this->password_prompt($status); |
| | | } |
| | | else { |
| | | $msg = rcube::Q($this->enigma->gettext('decrypterror')); |
| | | } |
| | | } |
| | | else if ($status === enigma_engine::ENCRYPTED_PARTIALLY) { |
| | | $attrib['class'] = 'enigmawarning'; |
| | | $msg = rcube::Q($this->enigma->gettext('decryptpartial')); |
| | | } |
| | | else { |
| | | $attrib['class'] = 'enigmanotice'; |
| | |
| | | } |
| | | |
| | | // Signature verification status |
| | | if (isset($engine->signed_parts[$part_id]) |
| | | && ($sig = $engine->signatures[$engine->signed_parts[$part_id]]) |
| | | if (($found = $this->find_part_id($part_id, $engine->signatures)) !== null |
| | | && ($sig = $engine->signatures[$found]) |
| | | ) { |
| | | $attach_scripts = true; |
| | | |
| | | // show the message only once |
| | | unset($engine->signatures[$found]); |
| | | |
| | | // display status info |
| | | $attrib['id'] = 'enigma-message'; |
| | |
| | | $msg = rcube::Q($msg); |
| | | } |
| | | else if ($sig->valid) { |
| | | $attrib['class'] = 'enigmanotice'; |
| | | $msg = rcube::Q(str_replace('$sender', $sender, $this->enigma->gettext('sigvalid'))); |
| | | $attrib['class'] = $sig->partial ? 'enigmawarning' : 'enigmanotice'; |
| | | $label = 'sigvalid' . ($sig->partial ? 'partial' : ''); |
| | | $msg = rcube::Q(str_replace('$sender', $sender, $this->enigma->gettext($label))); |
| | | } |
| | | else { |
| | | $attrib['class'] = 'enigmawarning'; |
| | |
| | | // $msg .= '<br /><pre>'.$sig->body.'</pre>'; |
| | | |
| | | $p['prefix'] .= html::div($attrib, $msg); |
| | | |
| | | // Display each signature message only once |
| | | unset($engine->signatures[$engine->signed_parts[$part_id]]); |
| | | } |
| | | |
| | | if ($attach_scripts) { |
| | |
| | | $msg = 'enigma.' . $mode . 'nokey'; |
| | | } |
| | | else if ($code == enigma_error::BADPASS) { |
| | | $msg = 'enigma.' . $mode . 'badpass'; |
| | | $type = 'warning'; |
| | | |
| | | $this->password_prompt($status); |
| | | } |
| | | else { |
| | | $msg = 'enigma.' . $mode . 'error'; |
| | | } |
| | | |
| | | $this->rc->output->show_message($msg, $type ?: 'error', $vars); |
| | | if ($msg) { |
| | | $this->rc->output->show_message($msg, $type ?: 'error', $vars); |
| | | } |
| | | |
| | | $this->rc->output->send('iframe'); |
| | | } |
| | | |
| | |
| | | $this->rc->output->show_message($msg, 'error'); |
| | | } |
| | | |
| | | // Check sign/ecrypt options for signed/encrypted drafts |
| | | $this->rc->output->set_env('enigma_force_encrypt', !empty($engine->decryptions)); |
| | | $this->rc->output->set_env('enigma_force_sign', !empty($engine->signatures)); |
| | | |
| | | return $p; |
| | | } |
| | | |
| | | /** |
| | | * Check if the part or its parent exists in the array |
| | | * of decryptions/signatures. Returns found ID. |
| | | */ |
| | | private function find_part_id($part_id, $data) |
| | | { |
| | | $ids = explode('.', $part_id); |
| | | $i = 0; |
| | | $count = count($ids); |
| | | |
| | | while ($i < $count && strlen($part = implode('.', array_slice($ids, 0, ++$i)))) { |
| | | if (array_key_exists($part, $data)) { |
| | | return $part; |
| | | } |
| | | } |
| | | } |
| | | } |