W.I.P. of S/MIME:

- Offer to add sender's certificate into addressbook
This commit is contained in:
Hadi Nategh 2017-08-21 10:59:02 +02:00
parent a40659f6aa
commit 57d515bfc6
2 changed files with 33 additions and 2 deletions

View File

@ -2233,6 +2233,17 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
$response->data(true); $response->data(true);
} }
/**
* Adds certificate to relevant contact
* @param array $_metadata data of sender's certificate
*/
function ajax_smimeAddCertToContact ($_metadata)
{
$response = Api\Json\Response::get();
$ab = new addressbook_bo();
$response->data($ab->set_smime_keys(array($_metadata['email'] => $_metadata['cert'])));
}
/** /**
* Build actions for display toolbar * Build actions for display toolbar
*/ */
@ -3065,9 +3076,9 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false); $structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
if (($smime = $structure->getMetadata('X-EGroupware-Smime'))) if (($smime = $structure->getMetadata('X-EGroupware-Smime')))
{ {
$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, $structure,true,false,true, $mailbox); $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, $structure,true,false,true, $mailbox);
$push = new Api\Json\Push(); $push = new Api\Json\Push();
if (!empty($smime['addtocontact'])) $push->call('app.mail.smime_certAddToContact', $smime);
if (is_array($attachments)) if (is_array($attachments))
{ {
$push->call('app.mail.set_smimeAttachments', $this->createAttachmentBlock($attachments, $_GET['_messageID'], $uid, $mailbox)); $push->call('app.mail.set_smimeAttachments', $this->createAttachmentBlock($attachments, $_GET['_messageID'], $uid, $mailbox));

View File

@ -5853,6 +5853,26 @@ app.classes.mail = AppJS.extend(
var smime_classes = 'smime_cert_verified smime_cert_notverified smime_cert_notvalid'; var smime_classes = 'smime_cert_verified smime_cert_notverified smime_cert_notvalid';
_nodes[i].removeClass(smime_classes); _nodes[i].removeClass(smime_classes);
} }
},
/**
* Inform user about sender's certificate and offers to add it into
* relevant contact in addressbook.
*
* @param {type} _metadata
*/
smime_certAddToContact: function (_metadata)
{
if (!_metadata || _metadata.length < 1) return;
var self = this;
et2_dialog.show_dialog(function(_button){
if (_button == 2)
{
self.egw.json('mail.mail_ui.ajax_smimeAddCertToContact',
_metadata,null,function(_message){egw.message(_message);}).sendRequest(true);
}
},
this.egw.lang("There's a new certificate information for email %1. Would you like to update/add this certificate?\n %2",_metadata.email,_metadata.certHtml),
this.egw.lang('Update cert for user %1', _metadata.email),{},et2_dialog.BUTTON_YES_NO, et2_dialog.WARNING_MESSAGE, undefined, egw);
} }
}); });