mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 04:29:28 +01:00
* Addressbook: fix lost picture in upload
This commit is contained in:
parent
dd4ae60fa2
commit
546606141e
@ -2026,23 +2026,11 @@ window.egw_LAB.wait(function() {
|
|||||||
// unset the duplicate_filed after submit because we don't need to warn user for second time about contact duplication
|
// unset the duplicate_filed after submit because we don't need to warn user for second time about contact duplication
|
||||||
unset($content['presets_fields']);
|
unset($content['presets_fields']);
|
||||||
}
|
}
|
||||||
$content['photo_unchanged'] = true; // hint no need to store photo
|
// photo might be changed by ajax_upload_photo
|
||||||
/* seems not to be used any more in favor or ajax_update_photo
|
if (!array_key_exists('jpegphoto', $content))
|
||||||
if ($content['delete_photo'])
|
|
||||||
{
|
{
|
||||||
$content['jpegphoto'] = null;
|
$content['photo_unchanged'] = true; // hint no need to store photo
|
||||||
unset($content['delete_photo']);
|
|
||||||
$content['photo_unchanged'] = false;
|
|
||||||
}
|
}
|
||||||
if (is_array($content['upload_photo']) && !empty($content['upload_photo']['tmp_name']) &&
|
|
||||||
$content['upload_photo']['tmp_name'] != 'none' &&
|
|
||||||
($f = fopen($content['upload_photo']['tmp_name'],'r')))
|
|
||||||
{
|
|
||||||
$content['jpegphoto'] = $this->resize_photo($f);
|
|
||||||
fclose($f);
|
|
||||||
unset($content['upload_photo']);
|
|
||||||
$content['photo_unchanged'] = false;
|
|
||||||
}*/
|
|
||||||
$links = false;
|
$links = false;
|
||||||
if (!$content['id'] && is_array($content['link_to']['to_id']))
|
if (!$content['id'] && is_array($content['link_to']['to_id']))
|
||||||
{
|
{
|
||||||
@ -2091,6 +2079,8 @@ window.egw_LAB.wait(function() {
|
|||||||
{
|
{
|
||||||
$content['msg'] .= ($content['msg'] ? ', ' : '').lang('Contact saved');
|
$content['msg'] .= ($content['msg'] ? ', ' : '').lang('Contact saved');
|
||||||
|
|
||||||
|
unset($content['jpegphoto'], $content['photo_unchanged']);
|
||||||
|
|
||||||
foreach((array)$content['post_save_callbacks'] as $callback)
|
foreach((array)$content['post_save_callbacks'] as $callback)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -3108,36 +3098,25 @@ window.egw_LAB.wait(function() {
|
|||||||
/**
|
/**
|
||||||
* Ajax method to update edited avatar photo via avatar widget
|
* Ajax method to update edited avatar photo via avatar widget
|
||||||
*
|
*
|
||||||
* @param int $contact_id
|
|
||||||
* @param file string $file null means to delete
|
|
||||||
* @param string $etemplate_exec_id to update id, files, etag, ...
|
* @param string $etemplate_exec_id to update id, files, etag, ...
|
||||||
|
* @param file string $file null means to delete
|
||||||
*/
|
*/
|
||||||
function ajax_update_photo ($contact_id, $file, $etemplate_exec_id)
|
function ajax_update_photo ($etemplate_exec_id, $file)
|
||||||
{
|
{
|
||||||
$et_request = Api\Etemplate\Request::read($etemplate_exec_id);
|
$et_request = Api\Etemplate\Request::read($etemplate_exec_id);
|
||||||
$response = Api\Json\Response::get();
|
$response = Api\Json\Response::get();
|
||||||
$contact = $this->read($contact_id);
|
|
||||||
if ($file)
|
if ($file)
|
||||||
{
|
{
|
||||||
$filteredFile = substr($file, strpos($file, ",")+1);
|
$filteredFile = substr($file, strpos($file, ",")+1);
|
||||||
// resize photo if wider then default width of 240pixel (keeping aspect ratio)
|
// resize photo if wider then default width of 240pixel (keeping aspect ratio)
|
||||||
$decoded = $this->resize_photo(base64_decode($filteredFile));
|
$decoded = $this->resize_photo(base64_decode($filteredFile));
|
||||||
}
|
}
|
||||||
$contact['jpegphoto'] = is_null($file) ? $file : $decoded;
|
$response->data(true);
|
||||||
$contact['photo_unchanged'] = false; // hint photo is changed
|
// add photo into current eT2 request
|
||||||
|
$et_request->preserv = array_merge($et_request->preserv, array(
|
||||||
$success = $this->save($contact);
|
'jpegphoto' => is_null($file) ? $file : $decoded,
|
||||||
if (!$success)
|
'photo_unchanged' => false, // hint photo is changed
|
||||||
{
|
));
|
||||||
$response->alert($this->error);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$response->data(true);
|
|
||||||
// merge changes (files, id, ...) into current eT request
|
|
||||||
unset($contact['jpegphoto'], $contact['photo_unchanged']);
|
|
||||||
$et_request->preserv = array_merge($et_request->preserv, $contact);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,13 +458,12 @@ var et2_avatar = (function(){ "use strict"; return et2_image.extend(
|
|||||||
var canvas = jQuery('#_cropper_image').cropper('getCroppedCanvas');
|
var canvas = jQuery('#_cropper_image').cropper('getCroppedCanvas');
|
||||||
self.image.attr('src', canvas.toDataURL("image/jpeg", 1.0));
|
self.image.attr('src', canvas.toDataURL("image/jpeg", 1.0));
|
||||||
self.egw().json('addressbook.addressbook_ui.ajax_update_photo',
|
self.egw().json('addressbook.addressbook_ui.ajax_update_photo',
|
||||||
[self.options.contact_id, canvas.toDataURL('image/jpeg',1.0), self.getInstanceManager().etemplate_exec_id],
|
[self.getInstanceManager().etemplate_exec_id, canvas.toDataURL('image/jpeg',1.0)],
|
||||||
function(res)
|
function(res)
|
||||||
{
|
{
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
del.show();
|
del.show();
|
||||||
self.egw().refresh('Avatar updated.', egw.app_name());
|
|
||||||
}
|
}
|
||||||
}).sendRequest();
|
}).sendRequest();
|
||||||
}
|
}
|
||||||
@ -494,7 +493,7 @@ var et2_avatar = (function(){ "use strict"; return et2_image.extend(
|
|||||||
if (_btn == et2_dialog.YES_BUTTON)
|
if (_btn == et2_dialog.YES_BUTTON)
|
||||||
{
|
{
|
||||||
self.egw().json('addressbook.addressbook_ui.ajax_update_photo',
|
self.egw().json('addressbook.addressbook_ui.ajax_update_photo',
|
||||||
[self.options.contact_id, null, self.getInstanceManager().etemplate_exec_id],
|
[self.getInstanceManager().etemplate_exec_id, null],
|
||||||
function(res)
|
function(res)
|
||||||
{
|
{
|
||||||
if (res)
|
if (res)
|
||||||
|
Loading…
Reference in New Issue
Block a user