| | |
| | | function tpl_key_data($attrib) |
| | | { |
| | | $out = ''; |
| | | $table = new html_table(array('cols' => 2)); |
| | | $table = new html_table(array('cols' => 2)); |
| | | |
| | | // Key user ID |
| | | $table->add('title', $this->enigma->gettext('keyuserid')); |
| | |
| | | $out .= html::tag('fieldset', null, |
| | | html::tag('legend', null, |
| | | $this->enigma->gettext('basicinfo')) . $table->show($attrib)); |
| | | /* |
| | | |
| | | // Subkeys |
| | | $table = new html_table(array('cols' => 6)); |
| | | // Columns: Type, ID, Algorithm, Size, Created, Expires |
| | | $table = new html_table(array('cols' => 5, 'id' => 'enigmasubkeytable', 'class' => 'records-table')); |
| | | |
| | | $table->add_header('id', $this->enigma->gettext('subkeyid')); |
| | | $table->add_header('algo', $this->enigma->gettext('subkeyalgo')); |
| | | $table->add_header('created', $this->enigma->gettext('subkeycreated')); |
| | | $table->add_header('expires', $this->enigma->gettext('subkeyexpires')); |
| | | $table->add_header('usage', $this->enigma->gettext('subkeyusage')); |
| | | |
| | | $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_AUTHENTICATE => $this->enigma->gettext('typeauth'), |
| | | ); |
| | | |
| | | foreach ($this->data->subkeys as $subkey) { |
| | | $algo = $subkey->get_algorithm(); |
| | | if ($algo && $subkey->length) { |
| | | $algo .= ' (' . $subkey->length . ')'; |
| | | } |
| | | |
| | | $usage = array(); |
| | | foreach ($usage_map as $key => $text) { |
| | | if ($subkey->usage & $key) { |
| | | $usage[] = $text; |
| | | } |
| | | } |
| | | |
| | | $table->add('id', $subkey->get_short_id()); |
| | | $table->add('algo', $algo); |
| | | $table->add('created', $subkey->created ? $this->rc->format_date($subkey->created, $date_format, false) : ''); |
| | | $table->add('expires', $subkey->expires ? $this->rc->format_date($subkey->expires, $date_format, false) : $this->enigma->gettext('expiresnever')); |
| | | $table->add('usage', implode(',', $usage)); |
| | | $table->set_row_attribs($subkey->revoked || ($subkey->expires && $subkey->expires < $now) ? 'deleted' : ''); |
| | | } |
| | | |
| | | $out .= html::tag('fieldset', null, |
| | | html::tag('legend', null, |
| | | $this->enigma->gettext('subkeys')) . $table->show($attrib)); |
| | | html::tag('legend', null, |
| | | $this->enigma->gettext('subkeys')) . $table->show()); |
| | | |
| | | // Additional user IDs |
| | | $table = new html_table(array('cols' => 2)); |
| | | // Columns: User ID, Validity |
| | | $table = new html_table(array('cols' => 2, 'id' => 'enigmausertable', 'class' => 'records-table')); |
| | | |
| | | $table->add_header('id', $this->enigma->gettext('userid')); |
| | | $table->add_header('valid', $this->enigma->gettext('uservalid')); |
| | | |
| | | foreach ($this->data->users as $user) { |
| | | $username = $user->name; |
| | | if ($user->comment) { |
| | | $username .= ' (' . $user->comment . ')'; |
| | | } |
| | | $username .= ' <' . $user->email . '>'; |
| | | |
| | | $table->add('id', rcube::Q(trim($username))); |
| | | $table->add('valid', $this->enigma->gettext($user->valid ? 'valid' : 'unknown')); |
| | | $table->set_row_attribs($user->revoked || !$user->valid ? 'deleted' : ''); |
| | | } |
| | | |
| | | $out .= html::tag('fieldset', null, |
| | | html::tag('legend', null, |
| | | $this->enigma->gettext('userids')) . $table->show($attrib)); |
| | | */ |
| | | html::tag('legend', null, |
| | | $this->enigma->gettext('userids')) . $table->show()); |
| | | |
| | | return $out; |
| | | } |
| | | |
| | |
| | | $attrib['class'] = 'enigmaerror'; |
| | | $code = $status->getCode(); |
| | | |
| | | if ($code == enigma_error::E_KEYNOTFOUND) { |
| | | if ($code == enigma_error::KEYNOTFOUND) { |
| | | $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')), |
| | | $this->enigma->gettext('decryptnokey'))); |
| | | } |
| | | else if ($code == enigma_error::E_BADPASS) { |
| | | else if ($code == enigma_error::BADPASS) { |
| | | $msg = rcube::Q($this->enigma->gettext('decryptbadpass')); |
| | | $this->password_prompt($status); |
| | | } |
| | |
| | | if ($sig instanceof enigma_signature) { |
| | | $sender = ($sig->name ? $sig->name . ' ' : '') . '<' . $sig->email . '>'; |
| | | |
| | | if ($sig->valid === enigma_error::E_UNVERIFIED) { |
| | | if ($sig->valid === enigma_error::UNVERIFIED) { |
| | | $attrib['class'] = 'enigmawarning'; |
| | | $msg = str_replace('$sender', $sender, $this->enigma->gettext('sigunverified')); |
| | | $msg = str_replace('$keyid', $sig->id, $msg); |
| | |
| | | $msg = rcube::Q(str_replace('$sender', $sender, $this->enigma->gettext('siginvalid'))); |
| | | } |
| | | } |
| | | else if ($sig && $sig->getCode() == enigma_error::E_KEYNOTFOUND) { |
| | | else if ($sig && $sig->getCode() == enigma_error::KEYNOTFOUND) { |
| | | $attrib['class'] = 'enigmawarning'; |
| | | $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($sig->getData('id')), |
| | | $this->enigma->gettext('signokey'))); |
| | |
| | | if ($mode && ($status instanceof enigma_error)) { |
| | | $code = $status->getCode(); |
| | | |
| | | if ($code == enigma_error::E_KEYNOTFOUND) { |
| | | if ($code == enigma_error::KEYNOTFOUND) { |
| | | $vars = array('email' => $status->getData('missing')); |
| | | $msg = 'enigma.' . $mode . 'nokey'; |
| | | } |
| | | else if ($code == enigma_error::E_BADPASS) { |
| | | else if ($code == enigma_error::BADPASS) { |
| | | $msg = 'enigma.' . $mode . 'badpass'; |
| | | $type = 'warning'; |
| | | |
| | |
| | | if ($status instanceof enigma_error) { |
| | | $code = $status->getCode(); |
| | | |
| | | if ($code == enigma_error::E_KEYNOTFOUND) { |
| | | if ($code == enigma_error::KEYNOTFOUND) { |
| | | $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')), |
| | | $this->enigma->gettext('decryptnokey'))); |
| | | } |
| | | else if ($code == enigma_error::E_BADPASS) { |
| | | else if ($code == enigma_error::BADPASS) { |
| | | $this->password_prompt($status, array('compose-init' => true)); |
| | | return $p; |
| | | } |