From 69f1fc46963601947e30fc10df73d13142d8bb86 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 19 May 2015 19:24:02 +0000 Subject: [PATCH] Fix some problems with merging into email files: - Use correct merge sub-class when merging multiple entries - Accept merge placeholders in to/cc/bcc fields (displayed as invalid, but still accepted) - Use merge placeholders to pull addresses from associated entry --- etemplate/inc/class.bo_merge.inc.php | 2 +- etemplate/inc/class.etemplate_widget_taglist.inc.php | 5 ++++- mail/inc/class.mail_compose.inc.php | 12 ++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index 340966d3f9..9c29deb131 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -1883,7 +1883,7 @@ abstract class bo_merge $action['nm_action'] = 'long_task'; $action['popup'] = egw_link::get_registry('mail', 'edit_popup'); $action['message'] = lang('insert in %1',egw_vfs::decodePath($file['name'])); - $action['menuaction'] = 'mail.mail_compose.ajax_merge&document='.$file['path']; + $action['menuaction'] = 'mail.mail_compose.ajax_merge&document='.$file['path'].'&merge='. get_called_class(); } /** diff --git a/etemplate/inc/class.etemplate_widget_taglist.inc.php b/etemplate/inc/class.etemplate_widget_taglist.inc.php index b55ef2a6a6..535f374b1b 100644 --- a/etemplate/inc/class.etemplate_widget_taglist.inc.php +++ b/etemplate/inc/class.etemplate_widget_taglist.inc.php @@ -120,7 +120,10 @@ class etemplate_widget_taglist extends etemplate_widget self::set_validation_error($form_name,lang("'%1' is NOT allowed ('%2')!",$val,implode("','",array_keys($lists))),''); } } - else if($this->type == 'taglist-email' && !preg_match(etemplate_widget_url::EMAIL_PREG, $val)) + else if($this->type == 'taglist-email' && !preg_match(etemplate_widget_url::EMAIL_PREG, $val) && + // Allow merge placeholders. Might be a better way to do this though. + !preg_match('/{{.+}}|\$\$.+\$\$/',$val) + ) { self::set_validation_error($form_name,lang("'%1' has an invalid format",$val),''); } diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 291b3c02c8..8c7e8d3cc7 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -3382,7 +3382,14 @@ class mail_compose public function ajax_merge($contact_id) { $response = egw_json_response::get(); - $document_merge = new addressbook_merge(); + if(class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'],'bo_merge')) + { + $document_merge = new $_REQUEST['merge'](); + } + else + { + $document_merge = new addressbook_merge(); + } $this->mail_bo->openConnection(); if(($error = $document_merge->check_document($_REQUEST['document'],''))) @@ -3391,9 +3398,6 @@ class mail_compose return; } - // Merge does not work correctly (missing to) if current app is not addressbook - //$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook'; - // Actually do the merge $folder = $merged_mail_id = null; $results = $this->mail_bo->importMessageToMergeAndSend(