forked from extern/egroupware
Use long task UI to merge contacts into email templates
This commit is contained in:
parent
6b86050e4e
commit
05f0e486e3
@ -1771,13 +1771,15 @@ abstract class bo_merge
|
||||
'group' => 2,
|
||||
'children' => array(),
|
||||
);
|
||||
}
|
||||
$documents[$file['mime']]['children'][$prefix.$file['name']] = array(
|
||||
'caption' => egw_vfs::decodePath($file['name'])
|
||||
);
|
||||
if ($file['mime'] == 'message/rfc822')
|
||||
{
|
||||
self::document_mail_action($documents[$prefix.$file['name']], $file);
|
||||
self::document_mail_action($documents[$file['mime']]['children'][$prefix.$file['name']], $file);
|
||||
}
|
||||
}
|
||||
$documents[$file['mime']]['children'][$prefix.$file['name']] = egw_vfs::decodePath($file['name']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$documents[$prefix.$file['name']] = array(
|
||||
@ -1819,26 +1821,24 @@ abstract class bo_merge
|
||||
{
|
||||
unset($action['postSubmit']);
|
||||
|
||||
// These parameters trigger compose + merge
|
||||
$extra = array(
|
||||
'from' => 'merge',
|
||||
'document' => $file['path'],
|
||||
);
|
||||
$action['confirm_multiple'] = lang('Do you want to send the message to all selected entries, WITHOUT further editing?') .
|
||||
lang('Popup will close when finished');
|
||||
// Lots takes a while, confirm
|
||||
$action['confirm_multiple'] = lang('Do you want to send the message to all selected entries, WITHOUT further editing?');
|
||||
|
||||
// egw.open() would work, but nextmatch actions only passes 1 ID through
|
||||
//$action['egw_open'] = 'edit-mail--'.implode('&',$extra);
|
||||
//
|
||||
// We use location and send the popup info anyway instead
|
||||
$action['nm_action'] = 'location';
|
||||
$action['popup'] = egw_link::get_registry('mail', 'edit_popup');
|
||||
$action['url'] = egw_link::get_registry('mail', 'edit') + $extra + array(
|
||||
// Mail edit requires ID to have a value before it will look at the other variables
|
||||
egw_link::get_registry('mail', 'edit_id') => 'true',
|
||||
'preset[mailtocontactbyid]' => '$id',
|
||||
// These parameters trigger compose + merge - only if 1 row
|
||||
$extra = array(
|
||||
'from=merge',
|
||||
'document='.$file['path'],
|
||||
);
|
||||
|
||||
// egw.open() used if only 1 row selected
|
||||
$action['egw_open'] = 'edit-mail--'.implode('&',$extra);
|
||||
$action['target'] = 'compose_' .$file['path'];
|
||||
|
||||
// long_task runs menuaction once for each selected row
|
||||
$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'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5362,7 +5362,7 @@ class mail_bo
|
||||
}
|
||||
else
|
||||
{
|
||||
$errorInfo = $mailObject->ErrorInfo;
|
||||
$errorInfo = 'Send Failed for '.$mailObject->Subject.' to '.$nfn.'<'.$email.'> Error:'.$mailObject->ErrorInfo;
|
||||
}
|
||||
}
|
||||
//error_log(__METHOD__.__LINE__.array2string($errorInfo));
|
||||
|
@ -1318,9 +1318,9 @@ class mail_compose
|
||||
else if ($from == 'merge' && $_REQUEST['document'])
|
||||
{
|
||||
/*
|
||||
* Special merge from everywhere else becase all other apps merge gives
|
||||
* a document to be downloaded, this either opens a compose dialog or
|
||||
* just sends emails
|
||||
* Special merge from everywhere else because all other apps merge gives
|
||||
* a document to be downloaded, this opens a compose dialog.
|
||||
* Use ajax_merge to merge & send multiple
|
||||
*/
|
||||
// Merge selected ID (in mailtocontactbyid or $mail_id) into given document
|
||||
$document_merge = new addressbook_merge();
|
||||
@ -1341,11 +1341,13 @@ class mail_compose
|
||||
$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
|
||||
|
||||
// Actually do the merge
|
||||
$results = $this->mail_bo->importMessageToMergeAndSend($document_merge, egw_vfs::PREFIX . $_REQUEST['document'], $merge_ids, $folder, $merged_mail_id);
|
||||
|
||||
// Handle results - one email open compose, more than one just sent
|
||||
if(count($merge_ids) <= 1)
|
||||
{
|
||||
$results = $this->mail_bo->importMessageToMergeAndSend(
|
||||
$document_merge, egw_vfs::PREFIX . $_REQUEST['document'], $merge_ids, $folder, $merged_mail_id
|
||||
);
|
||||
|
||||
// Open compose
|
||||
$merged_mail_id = trim($GLOBALS['egw_info']['user']['account_id']).mail_ui::$delimiter.
|
||||
$this->mail_bo->profileID.mail_ui::$delimiter.
|
||||
base64_encode($folder).mail_ui::$delimiter.$merged_mail_id;
|
||||
@ -2718,4 +2720,43 @@ class mail_compose
|
||||
common::egw_exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the selected contact ID into the document given in $_REQUEST['document']
|
||||
* and send it.
|
||||
*
|
||||
* @param int $contact_id
|
||||
*/
|
||||
public function ajax_merge($contact_id)
|
||||
{
|
||||
$response = egw_json_response::get();
|
||||
$document_merge = new addressbook_merge();
|
||||
$this->mail_bo->openConnection();
|
||||
|
||||
if($error = $document_merge->check_document($_REQUEST['document'],''))
|
||||
{
|
||||
$response->error($error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Merge does not work correctly (missing to) if current app is not addressbook
|
||||
$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
|
||||
|
||||
// Actually do the merge
|
||||
$results = $this->mail_bo->importMessageToMergeAndSend(
|
||||
$document_merge, egw_vfs::PREFIX . $_REQUEST['document'],
|
||||
// Send an extra non-numeric ID to force actual send of document
|
||||
// instead of save as draft
|
||||
array((int)$contact_id, ''),
|
||||
$folder,$merged_mail_id
|
||||
);
|
||||
|
||||
if($results['success'])
|
||||
{
|
||||
$response->data(implode(',',$results['success']));
|
||||
}
|
||||
if($results['failed'])
|
||||
{
|
||||
$response->error(implode(',',$results['failed']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user