forked from extern/egroupware
Add selected contacts to new distribution list when you create it via context menu
This commit is contained in:
parent
fb17c19161
commit
123f902f43
@ -937,9 +937,10 @@ window.egw_LAB.wait(function() {
|
||||
* @param int $list_id ID of existing list, or 0 for a new one
|
||||
* @param string $new_name List name
|
||||
* @param int $_owner List owner, or empty for current user
|
||||
* @param string[] [$contacts] List of contacts to add to the array
|
||||
* @return boolean|string
|
||||
*/
|
||||
function ajax_set_list($list_id, $new_name, $_owner = false)
|
||||
function ajax_set_list($list_id, $new_name, $_owner = false, $contacts = array())
|
||||
{
|
||||
// Set owner to current user, if not set
|
||||
$owner = $_owner ? $_owner : $GLOBALS['egw_info']['user']['account_id'];
|
||||
@ -974,6 +975,10 @@ window.egw_LAB.wait(function() {
|
||||
|
||||
$new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'],array(),$list);
|
||||
|
||||
if($contacts)
|
||||
{
|
||||
$this->add2list($contacts,$new_id);
|
||||
}
|
||||
Api\Json\Response::get()->apply('egw.message', array(
|
||||
$new_id == $list_id ? lang('Distribution list renamed') : lang('List created'),
|
||||
'success'
|
||||
|
@ -556,7 +556,13 @@ app.classes.addressbook = AppJS.extend(
|
||||
}
|
||||
},
|
||||
|
||||
add_new_list: function(owner)
|
||||
/**
|
||||
* Add a new mailing list. If any contacts are selected, they will be added.
|
||||
*
|
||||
* @param {egwAction} owner
|
||||
* @param {egwActionObject[]} selected
|
||||
*/
|
||||
add_new_list: function(owner, selected)
|
||||
{
|
||||
if(!owner || typeof owner == 'object')
|
||||
{
|
||||
@ -564,11 +570,23 @@ app.classes.addressbook = AppJS.extend(
|
||||
owner = filter.getValue()||egw.preference('add_default','addressbook');
|
||||
}
|
||||
var lists = this.et2.getWidgetById('filter2');
|
||||
var contacts = [];
|
||||
if(selected && selected.length)
|
||||
{
|
||||
for(var i = 0; i < selected.length; i++)
|
||||
{
|
||||
// Remove UID prefix for just contact_id
|
||||
var ids = selected[i].id.split('::');
|
||||
ids.shift();
|
||||
ids = ids.join('::');
|
||||
contacts.push(ids);
|
||||
}
|
||||
}
|
||||
et2_dialog.show_prompt(
|
||||
function(button, name) {
|
||||
if(button == et2_dialog.OK_BUTTON)
|
||||
{
|
||||
egw.json('addressbook.addressbook_ui.ajax_set_list',[0, name, owner],
|
||||
egw.json('addressbook.addressbook_ui.ajax_set_list',[0, name, owner, contacts],
|
||||
function(result)
|
||||
{
|
||||
if(typeof result == 'object') return; // This response not for us
|
||||
|
Loading…
Reference in New Issue
Block a user