From 0c2ab2ada56399c5e6fcfd87e32c76aed51fb0d0 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 13 Jan 2014 17:40:36 +0000 Subject: [PATCH] Fix send mail to business or private mail from addressbook mail context menu --- addressbook/inc/class.addressbook_ui.inc.php | 28 +++++++++----- addressbook/js/app.js | 40 ++++++++++++++------ 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 9150806d88..3e2a7dc20a 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -557,27 +557,37 @@ class addressbook_ui extends addressbook_bo 'icon' => 'mail/navbar', 'group' => $group, 'children' => array( - 'add_to_cc' => array( - 'caption' => lang('Add to %1',lang('CC')), + 'add_to_to' => array( + 'caption' => lang('Add to %1',lang('To')), 'no_lang' => true, - 'checkbox' => true, - 'group' => $group, + 'onExecute' => 'javaScript:app.addressbook.addEmail', + + ), + 'add_to_cc' => array( + 'caption' => lang('Add to %1',lang('Cc')), + 'no_lang' => true, + 'onExecute' => 'javaScript:app.addressbook.addEmail', + ), 'add_to_bcc' => array( - 'caption' => lang('Add to %1',lang('BCC')), + 'caption' => lang('Add to %1',lang('BCc')), 'no_lang' => true, - 'checkbox' => true, - 'group' => $group, + 'onExecute' => 'javaScript:app.addressbook.addEmail', + ), 'email_business' => array( 'caption' => lang('Add %1',lang('business email')), 'no_lang' => true, - 'onExecute' => 'javaScript:app.addressbook.addEmail', + 'checkbox' => true, + 'group' => $group, + 'onExecute' => 'javaScript:app.addressbook.mailCheckMenu', ), 'email_home' => array( 'caption' => lang('Add %1',lang('home email')), 'no_lang' => true, - 'onExecute' => 'javaScript:app.addressbook.addEmail', + 'checkbox' => true, + 'group' => $group, + 'onExecute' => 'javaScript:app.addressbook.mailCheckMenu', ), ), diff --git a/addressbook/js/app.js b/addressbook/js/app.js index 266dc90931..fb403879ea 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -413,6 +413,15 @@ app.classes.addressbook = AppJS.extend( return false; }, + /** + * + * + */ + mailCheckMenu: function(action, selected) + { + + }, + /** * Action function to add the email address (business or home) of the selected * contacts to a compose email popup window. @@ -427,29 +436,36 @@ app.classes.addressbook = AppJS.extend( { // Go through selected & pull email addresses from data var emails = []; - var cc ='', bcc =''; for(var i = 0; i < selected.length; i++) { // Pull data from global cache var data = egw.dataGetUIDdata(selected[i].id) || {data:{}}; - var email = data.data[action.id == 'email_business' ? 'email' : 'email_home'] || ''; + + var email_business = data.data[action.parent.children[3].checked ? 'email_business' : '']; + var email = data.data[action.parent.children[4].checked ? 'email' : '']; + if(email_business) + { + emails.push(email_business); + } if(email) { emails.push(email); } } - // Add to Cc - if (action.parent.children[0].checked) + switch (action.id) { - cc = '&cc=' + emails.join(','); + case "add_to_to": + egw.open_link('mailto:' + emails.join(',')); + break; + case "add_to_cc": + egw.open_link('mailto:' + '?cc=' + emails.join(',')); + //egw.mailto('mailto:'); + break; + case "add_to_bcc": + egw.open_link('mailto:' + '?bcc=' + emails.join(',')); + break; } - // Add to Bcc - if (action.parent.children[1].checked) - { - bcc = '&bcc=' + emails.join(','); - } - // Always open a compose, even if no emails, so user knows it worked - egw.open_link('mailto:' + emails.join(',') + cc + bcc ); + return false; },