update files bitfield, for keys added via edit popup vfs-upload widgets

This commit is contained in:
Ralf Becker 2017-09-21 11:32:55 +02:00
parent a6ec69169d
commit 9879e02766
2 changed files with 32 additions and 2 deletions

View File

@ -3115,6 +3115,36 @@ window.egw_LAB.wait(function() {
}
}
/**
* Callback for vfs-upload widgets for PGP and S/Mime pubkey
*
* @param array $file
* @param string $widget_id
* @param Api\Etemplate\Request $request eT2 request eg. to access attribute $content
* @param Api\Json\Response $response
*/
public function pubkey_uploaded(array $file, $widget_id, Api\Etemplate\Request $request, Api\Json\Response $response)
{
//error_log(__METHOD__."(".array2string($file).", ...) widget_id=$widget_id, id=".$request->content['id'].", files=".$request->content['files']);
unset($file, $response); // not used, but required by function signature
list(,,$path) = explode(':', $widget_id);
$bit = $path === Api\Contacts::FILES_PGP_PUBKEY ? Api\Contacts::FILES_BIT_PGP_PUBKEY : Api\Contacts::FILES_BIT_SMIME_PUBKEY;
if (!($request->content['files'] & $bit) && $this->check_perms(Acl::EDIT, $request->content))
{
$content = $request->content;
$content['files'] |= $bit;
$content['photo_unchanged'] = true; // hint no need to store photo
if ($this->save($content))
{
$changed = array_diff_assoc($content, $request->content);
//error_log(__METHOD__."() changed=".array2string($changed));
$request->content = $content;
// need to update preserv, as edit stores content there too and we would get eg. an contact modified error when trying to store
$request->preserv = array_merge($request->preserv, $changed);
}
}
}
/**
* download photo of the given ($_GET['contact_id'] or $_GET['account_id']) contact
*/

View File

@ -178,11 +178,11 @@
</row>
<row valign="top">
<description value="SMIME key"/>
<vfs-upload id="addressbook:$cont[id]:.files/smime-pubkey.crt" accept=".crt,.pem,application/x-x509-ca-cert,application/x-x509-user-cert" mime="/application\/x-x509-(ca|user)-cert/"/>
<vfs-upload id="addressbook:$cont[id]:.files/smime-pubkey.crt" accept=".crt,.pem,application/x-x509-ca-cert,application/x-x509-user-cert" mime="/application\/x-x509-(ca|user)-cert/" callback="addressbook.addressbook_ui.pubkey_uploaded"/>
</row>
<row valign="top">
<description value="PGP key"/>
<vfs-upload id="addressbook:$cont[id]:.files/pgp-pubkey.asc" accept=".asc,application/pgp-keys" mime="application/pgp-keys"/>
<vfs-upload id="addressbook:$cont[id]:.files/pgp-pubkey.asc" accept=".asc,application/pgp-keys" mime="application/pgp-keys" callback="addressbook.addressbook_ui.pubkey_uploaded"/>
</row>
<row valign="top">
<description for="pubkey" value="Public key"/>