summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-08-08 15:49:11 +0200
committerAleksander Machniak <alec@alec.pl>2013-08-08 15:49:11 +0200
commit1391f17a521a19382c59ef9d4e93a8ced2f1a9e5 (patch)
treee8c489356c3da2f13471063c54dfdeb009b8c542 /program/steps
parent8799df8ccdb09114b14742e0493a8ba401688fdf (diff)
Fix issue where uploaded photo was lost when contact form did not validate (#1489274)
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/addressbook/func.inc20
1 files changed, 18 insertions, 2 deletions
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index 034f033c9..f94d15338 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -751,12 +751,28 @@ function rcmail_contact_photo($attrib)
$plugin = $RCMAIL->plugins->exec_hook('contact_photo', array('record' => $record, 'data' => $record['photo']));
+ // check if we have photo data from contact form
+ if ($GLOBALS['EDIT_RECORD']) {
+ $rec = $GLOBALS['EDIT_RECORD'];
+ if ($rec['photo'] == '-del-') {
+ $record['photo'] = '';
+ }
+ else if ($_SESSION['contacts']['files'][$rec['photo']]) {
+ $record['photo'] = $file_id = $rec['photo'];
+ }
+ }
+
if ($plugin['url'])
$photo_img = $plugin['url'];
else if (preg_match('!^https?://!i', $record['photo']))
$photo_img = $record['photo'];
- else if ($record['photo'])
- $photo_img = $RCMAIL->url(array('_action' => 'photo', '_cid' => $record['ID'], '_source' => $SOURCE_ID));
+ else if ($record['photo']) {
+ $url = array('_action' => 'photo', '_cid' => $record['ID'], '_source' => $SOURCE_ID);
+ if ($file_id) {
+ $url['_photo'] = $ff_value = $file_id;
+ }
+ $photo_img = $RCMAIL->url($url);
+ }
else
$ff_value = '-del-'; // will disable delete-photo action