2011-04-26 18:22:10 +02:00
|
|
|
/**
|
2013-09-20 12:50:48 +02:00
|
|
|
* EGroupware - Addressbook - Javascript UI
|
2011-04-26 18:22:10 +02:00
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
2013-09-20 12:50:48 +02:00
|
|
|
* @package addressbook
|
|
|
|
* @author Hadi Nategh <hn-AT-stylite.de>
|
|
|
|
* @copyright (c) 2008-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
2013-11-04 21:54:23 +01:00
|
|
|
* @version $Id$
|
2011-04-26 18:22:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-09-20 12:50:48 +02:00
|
|
|
* UI for Addressbook
|
|
|
|
*
|
|
|
|
* @augments AppJS
|
2011-04-26 18:22:10 +02:00
|
|
|
*/
|
2013-11-04 21:54:23 +01:00
|
|
|
app.classes.addressbook = AppJS.extend(
|
2011-04-26 18:22:10 +02:00
|
|
|
{
|
2013-09-20 12:50:48 +02:00
|
|
|
appname: 'addressbook',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @memberOf app.addressbook
|
|
|
|
*/
|
|
|
|
init: function()
|
|
|
|
{
|
|
|
|
// call parent
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
destroy: function()
|
2011-04-26 18:22:10 +02:00
|
|
|
{
|
2013-09-20 12:50:48 +02:00
|
|
|
// call parent
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function is called when the etemplate2 object is loaded
|
|
|
|
* and ready. If you must store a reference to the et2 object,
|
|
|
|
* make sure to clean it up in destroy().
|
|
|
|
*
|
2014-03-07 10:29:01 +01:00
|
|
|
* @param {etemplate2} et2 newly ready object
|
|
|
|
* @param {string} name
|
2013-09-20 12:50:48 +02:00
|
|
|
*/
|
2014-03-07 10:29:01 +01:00
|
|
|
et2_ready: function(et2, name)
|
2011-04-26 18:22:10 +02:00
|
|
|
{
|
2014-12-09 14:46:27 +01:00
|
|
|
// r49769 let's CRM view run under currentapp == "addressbook", which causes
|
|
|
|
// app.addressbook.et2_ready called before app.infolog.et2_ready and therefore
|
|
|
|
// app.addressbook.et2 would point to infolog template, if we not stop here
|
2015-09-28 19:05:35 +02:00
|
|
|
if (name.match(/^infolog|tracker\./)) return;
|
2014-12-09 14:46:27 +01:00
|
|
|
|
2013-09-20 12:50:48 +02:00
|
|
|
// call parent
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
|
2014-03-07 10:29:01 +01:00
|
|
|
switch (name)
|
2011-04-26 18:22:10 +02:00
|
|
|
{
|
2014-03-07 10:29:01 +01:00
|
|
|
case 'addressbook.edit':
|
|
|
|
var content = this.et2.getArrayMgr('content').data;
|
|
|
|
if (typeof content.showsearchbuttons == 'undefined' || !content.showsearchbuttons)
|
2014-01-31 17:04:05 +01:00
|
|
|
{
|
2014-03-07 10:29:01 +01:00
|
|
|
this.show_custom_country($j('select[id*="adr_one_countrycode"]').get(0));
|
|
|
|
this.show_custom_country($j('select[id*="adr_two_countrycode"]').get(0));
|
|
|
|
|
|
|
|
// Instanciate infolog JS too - wrong app, so it won't be done automatically
|
|
|
|
if(typeof window.app.infolog != 'object' && typeof window.app.classes['infolog'] == 'function')
|
|
|
|
{
|
|
|
|
window.app.infolog = new window.app.classes.infolog();
|
|
|
|
}
|
2014-01-31 17:04:05 +01:00
|
|
|
}
|
2014-10-13 15:33:10 +02:00
|
|
|
// Call check value if the AB got opened with presets
|
|
|
|
if (window.location.href.match(/&presets\[email\]/g) && content.presets_fields)
|
|
|
|
{
|
|
|
|
for(var i=0;i< content.presets_fields.length;i++)
|
|
|
|
{
|
|
|
|
this.check_value(this.et2.getWidgetById(content.presets_fields),0);
|
|
|
|
}
|
|
|
|
}
|
2014-03-07 10:29:01 +01:00
|
|
|
break;
|
2011-04-26 18:22:10 +02:00
|
|
|
}
|
|
|
|
|
2013-09-20 12:50:48 +02:00
|
|
|
jQuery('select[id*="adr_one_countrycode"]').each(function() {
|
|
|
|
app.addressbook.show_custom_country(this);
|
|
|
|
});
|
|
|
|
jQuery('select[id*="adr_two_countrycode"]').each(function() {
|
|
|
|
app.addressbook.show_custom_country(this);
|
|
|
|
});
|
|
|
|
},
|
2011-04-26 18:22:10 +02:00
|
|
|
|
2016-04-11 22:38:12 +02:00
|
|
|
/**
|
|
|
|
* Observer method receives update notifications from all applications
|
|
|
|
*
|
|
|
|
* App is responsible for only reacting to "messages" it is interested in!
|
|
|
|
*
|
|
|
|
* Addressbook checks for CRM view to update the displayed data if you edit
|
|
|
|
* that contact
|
|
|
|
*
|
|
|
|
* @param {string} _msg message (already translated) to show, eg. 'Entry deleted'
|
|
|
|
* @param {string} _app application name
|
|
|
|
* @param {(string|number)} _id id of entry to refresh or null
|
|
|
|
* @param {string} _type either 'update', 'edit', 'delete', 'add' or null
|
|
|
|
* - update: request just modified data from given rows. Sorting is not considered,
|
|
|
|
* so if the sort field is changed, the row will not be moved.
|
|
|
|
* - edit: rows changed, but sorting may be affected. Requires full reload.
|
|
|
|
* - delete: just delete the given rows clientside (no server interaction neccessary)
|
|
|
|
* - add: requires full reload for proper sorting
|
|
|
|
* @param {string} _msg_type 'error', 'warning' or 'success' (default)
|
|
|
|
* @param {object|null} _links app => array of ids of linked entries
|
|
|
|
* or null, if not triggered on server-side, which adds that info
|
|
|
|
* @return {false|*} false to stop regular refresh, thought all observers are run
|
|
|
|
*/
|
|
|
|
observer: function(_msg, _app, _id, _type, _msg_type, _links)
|
|
|
|
{
|
|
|
|
// Edit to the current entry
|
|
|
|
var state = this.getState();
|
|
|
|
if(_app === 'addressbook' && state && state.type && state.type === 'view' && state.id === _id)
|
|
|
|
{
|
|
|
|
var content = egw.dataGetUIDdata('addressbook::'+_id);
|
|
|
|
if (content.data)
|
|
|
|
{
|
|
|
|
var view = etemplate2.getById('addressbook-view');
|
|
|
|
if(view)
|
|
|
|
{
|
|
|
|
view.widgetContainer._children[0].set_value({content:content.data});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
2014-03-12 14:29:52 +01:00
|
|
|
/**
|
|
|
|
* Open CRM view
|
|
|
|
*
|
|
|
|
* @param _action
|
|
|
|
* @param _senders
|
|
|
|
*/
|
|
|
|
view: function(_action, _senders)
|
|
|
|
{
|
|
|
|
var index = _senders[0]._index;
|
|
|
|
var id = _senders[0].id.split('::').pop();
|
2014-03-25 17:53:36 +01:00
|
|
|
var extras = {
|
|
|
|
index: index
|
|
|
|
};
|
2014-03-12 14:29:52 +01:00
|
|
|
|
2014-03-25 17:53:36 +01:00
|
|
|
// CRM list
|
|
|
|
if(_action.id != 'view')
|
|
|
|
{
|
|
|
|
extras.crm_list = _action.id.replace('view-','');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.egw.open(id, 'addressbook', 'view', extras, '_self', 'addressbook');
|
2014-03-12 14:29:52 +01:00
|
|
|
},
|
|
|
|
|
2014-03-12 16:21:01 +01:00
|
|
|
/**
|
2014-03-12 23:42:06 +01:00
|
|
|
* Set link filter for the already open & rendered list
|
2014-03-12 16:32:58 +01:00
|
|
|
*
|
2014-08-06 01:27:06 +02:00
|
|
|
* @param {Object} filter Object with key / value pairs of filters to set
|
2014-03-12 16:21:01 +01:00
|
|
|
*/
|
2014-08-06 01:27:06 +02:00
|
|
|
view_set_list: function(filter)
|
2014-03-12 16:21:01 +01:00
|
|
|
{
|
|
|
|
// Find the infolog list
|
2014-03-12 23:42:06 +01:00
|
|
|
var list = etemplate2.getById(
|
2014-03-12 16:32:58 +01:00
|
|
|
$j(this.et2.getInstanceManager().DOMContainer).nextAll('.et2_container').attr('id')
|
2014-03-12 16:21:01 +01:00
|
|
|
);
|
2014-03-28 17:56:35 +01:00
|
|
|
var nm = list ? list.widgetContainer.getWidgetById('nm') : null;
|
|
|
|
if(nm)
|
2014-03-12 16:21:01 +01:00
|
|
|
{
|
2014-03-12 23:42:06 +01:00
|
|
|
nm.applyFilters(filter);
|
2014-03-12 16:21:01 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-03-07 10:29:01 +01:00
|
|
|
/**
|
|
|
|
* Run an action from CRM view toolbar
|
|
|
|
*
|
|
|
|
* @param {object} _action
|
|
|
|
*/
|
|
|
|
view_actions: function(_action)
|
|
|
|
{
|
|
|
|
var id = this.et2.getArrayMgr('content').data.id;
|
|
|
|
|
|
|
|
switch(_action.id)
|
|
|
|
{
|
2014-03-12 16:44:06 +01:00
|
|
|
case 'open':
|
2014-03-07 10:29:01 +01:00
|
|
|
this.egw.open(id, 'addressbook', 'edit');
|
|
|
|
break;
|
|
|
|
case 'copy':
|
|
|
|
this.egw.open(id, 'addressbook', 'edit', { makecp: 1});
|
|
|
|
break;
|
|
|
|
case 'cancel':
|
|
|
|
this.egw.open(null, 'addressbook', 'list', null, '_self', 'addressbook');
|
|
|
|
break;
|
2014-03-10 22:15:23 +01:00
|
|
|
default: // submit all other buttons back to server
|
|
|
|
this.et2._inst.submit();
|
2014-03-07 10:29:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-03-17 20:14:00 +01:00
|
|
|
/**
|
|
|
|
* Open the calender to view the selected contacts
|
|
|
|
* @param {egwAction} _action
|
|
|
|
* @param {egwActionObject[]} _senders
|
|
|
|
*/
|
|
|
|
view_calendar: function(_action, _senders)
|
|
|
|
{
|
|
|
|
var extras = {
|
|
|
|
filter: 'all',
|
2015-12-15 16:21:38 +01:00
|
|
|
cat_id: '',
|
2015-03-17 20:14:00 +01:00
|
|
|
owner: []
|
|
|
|
};
|
|
|
|
var orgs = [];
|
|
|
|
for(var i = 0; i < _senders.length; i++)
|
|
|
|
{
|
|
|
|
// Remove UID prefix for just contact_id
|
|
|
|
var ids = _senders[i].id.split('::');
|
|
|
|
ids.shift();
|
|
|
|
ids = ids.join('::');
|
|
|
|
|
|
|
|
// Orgs need to get all the contact IDs first
|
|
|
|
if (ids.substr(0,9) == 'org_name:')
|
|
|
|
{
|
|
|
|
orgs.push(ids);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
extras.owner.push('c'+ids);
|
|
|
|
}
|
|
|
|
}
|
2016-04-29 09:51:13 +02:00
|
|
|
|
2015-03-17 20:14:00 +01:00
|
|
|
if(orgs.length > 0)
|
|
|
|
{
|
|
|
|
// Get organisation contacts, then show infolog list
|
|
|
|
this.egw.json('addressbook.addressbook_ui.ajax_organisation_contacts',
|
|
|
|
[orgs],
|
|
|
|
function(contacts) {
|
|
|
|
for(var i = 0; i < contacts.length; i++)
|
|
|
|
{
|
|
|
|
extras.owner.push('c'+contacts[i]);
|
|
|
|
}
|
|
|
|
extras.owner = extras.owner.join(',');
|
|
|
|
this.egw.open('','calendar','list',extras,'calendar');
|
|
|
|
},this,true,this
|
|
|
|
).sendRequest();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
extras.owner = extras.owner.join(',');
|
|
|
|
egw.open('', 'calendar', 'list', extras, 'calendar');
|
|
|
|
}
|
|
|
|
},
|
2013-09-20 12:50:48 +02:00
|
|
|
/**
|
|
|
|
* Add appointment or show calendar for selected contacts, call default nm_action after some checks
|
|
|
|
*
|
|
|
|
* @param _action
|
|
|
|
* @param _senders
|
|
|
|
*/
|
|
|
|
add_cal: function(_action, _senders)
|
|
|
|
{
|
2014-01-14 16:43:06 +01:00
|
|
|
if (!_senders[0].id.match(/^(?:addressbook::)?[0-9]+$/))
|
2013-09-20 12:50:48 +02:00
|
|
|
{
|
|
|
|
// send org-view requests to server
|
|
|
|
_action.data.nm_action = "submit";
|
2014-01-14 16:43:06 +01:00
|
|
|
nm_action(_action, _senders);
|
2013-09-20 12:50:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var ids = "";
|
|
|
|
for (var i = 0; i < _senders.length; i++)
|
|
|
|
{
|
2014-01-14 16:43:06 +01:00
|
|
|
// Remove UID prefix for just contact_id
|
|
|
|
var id = _senders[i].id.split('::');
|
|
|
|
ids += "c" + id[1] + ((i < _senders.length - 1) ? "," : "");
|
2011-04-26 18:22:10 +02:00
|
|
|
}
|
2014-01-14 16:43:06 +01:00
|
|
|
var extra = {};
|
2015-05-25 16:27:26 +02:00
|
|
|
extra[_action.data && _action.data.url && _action.data.url.indexOf('owner') > 0 ? 'owner' : 'participants'] = ids;
|
2014-01-14 16:43:06 +01:00
|
|
|
|
|
|
|
// Use framework to add calendar entry
|
|
|
|
egw.open('','calendar','add',extra);
|
2011-04-26 18:22:10 +02:00
|
|
|
}
|
2013-09-20 12:50:48 +02:00
|
|
|
},
|
2011-04-26 18:22:10 +02:00
|
|
|
|
2014-01-16 16:15:50 +01:00
|
|
|
/**
|
2014-03-18 20:20:29 +01:00
|
|
|
* View infolog entries linked to selected contact
|
2014-01-16 16:15:50 +01:00
|
|
|
* @param {egwAction} _action Select action
|
|
|
|
* @param {egwActionObject[]} _senders Selected contact(s)
|
|
|
|
*/
|
|
|
|
view_infolog: function(_action, _senders)
|
|
|
|
{
|
|
|
|
var extras = {
|
|
|
|
action: 'addressbook',
|
|
|
|
action_id: [],
|
|
|
|
action_title: _senders.length > 1 ? this.egw.lang('selected contacts') : ''
|
2014-02-13 14:54:52 +01:00
|
|
|
};
|
2014-03-18 20:20:29 +01:00
|
|
|
var orgs = [];
|
2014-03-13 20:04:47 +01:00
|
|
|
for(var i = 0; i < _senders.length; i++)
|
|
|
|
{
|
|
|
|
// Remove UID prefix for just contact_id
|
|
|
|
var ids = _senders[i].id.split('::');
|
|
|
|
ids.shift();
|
|
|
|
ids = ids.join('::');
|
|
|
|
|
2014-03-18 20:20:29 +01:00
|
|
|
// Orgs need to get all the contact IDs first
|
2014-03-13 20:04:47 +01:00
|
|
|
if (ids.substr(0,9) == 'org_name:')
|
|
|
|
{
|
2014-03-18 20:20:29 +01:00
|
|
|
orgs.push(ids);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
extras.action_id.push(ids);
|
2014-03-13 20:04:47 +01:00
|
|
|
}
|
|
|
|
}
|
2014-01-21 16:29:09 +01:00
|
|
|
|
2014-03-18 20:20:29 +01:00
|
|
|
if(orgs.length > 0)
|
|
|
|
{
|
|
|
|
// Get organisation contacts, then show infolog list
|
|
|
|
this.egw.json('addressbook.addressbook_ui.ajax_organisation_contacts',
|
|
|
|
[orgs],
|
|
|
|
function(contacts) {
|
|
|
|
extras.action_id = extras.action_id.concat(contacts);
|
|
|
|
this.egw.open('','infolog','list',extras,'infolog');
|
|
|
|
},this,true,this
|
|
|
|
).sendRequest();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
egw.open('', 'infolog', 'list', extras, 'infolog');
|
|
|
|
}
|
2014-01-16 16:15:50 +01:00
|
|
|
},
|
|
|
|
|
2013-09-20 12:50:48 +02:00
|
|
|
/**
|
|
|
|
* Add task for selected contacts, call default nm_action after some checks
|
|
|
|
*
|
|
|
|
* @param _action
|
|
|
|
* @param _senders
|
|
|
|
*/
|
|
|
|
add_task: function(_action, _senders)
|
|
|
|
{
|
|
|
|
if (!_senders[0].id.match(/^(addressbook::)?[0-9]+$/))
|
|
|
|
{
|
|
|
|
// send org-view requests to server
|
|
|
|
_action.data.nm_action = "submit";
|
2013-06-19 21:02:41 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-20 12:50:48 +02:00
|
|
|
// call nm_action's popup
|
|
|
|
_action.data.nm_action = "popup";
|
2013-06-19 21:02:41 +02:00
|
|
|
}
|
2013-09-20 12:50:48 +02:00
|
|
|
nm_action(_action, _senders);
|
|
|
|
},
|
|
|
|
|
2014-02-13 11:06:18 +01:00
|
|
|
/**
|
|
|
|
* [More...] in phones clicked: copy allways shown phone numbers to phone popup
|
|
|
|
*
|
|
|
|
* @param {jQuery.event} _event
|
|
|
|
* @param {et2_widget} _widget
|
|
|
|
*/
|
|
|
|
showphones: function(_event, _widget)
|
2013-09-20 12:50:48 +02:00
|
|
|
{
|
2014-02-13 11:06:18 +01:00
|
|
|
this._copyvalues({
|
|
|
|
tel_home: 'tel_home2',
|
|
|
|
tel_work: 'tel_work2',
|
|
|
|
tel_cell: 'tel_cell2',
|
2014-02-13 14:54:52 +01:00
|
|
|
tel_fax: 'tel_fax2'
|
2014-02-13 11:06:18 +01:00
|
|
|
});
|
|
|
|
jQuery('table.editphones').css('display','inline');
|
2013-09-20 12:50:48 +02:00
|
|
|
|
2014-02-13 11:06:18 +01:00
|
|
|
_event.stopPropagation();
|
|
|
|
return false;
|
2013-09-20 12:50:48 +02:00
|
|
|
},
|
|
|
|
|
2014-02-13 11:06:18 +01:00
|
|
|
/**
|
|
|
|
* [OK] in phone popup clicked: copy phone numbers back to always shown ones
|
|
|
|
*
|
|
|
|
* @param {jQuery.event} _event
|
|
|
|
* @param {et2_widget} _widget
|
|
|
|
*/
|
|
|
|
hidephones: function(_event, _widget)
|
2013-09-20 12:50:48 +02:00
|
|
|
{
|
2014-02-13 11:06:18 +01:00
|
|
|
this._copyvalues({
|
|
|
|
tel_home2: 'tel_home',
|
|
|
|
tel_work2: 'tel_work',
|
|
|
|
tel_cell2: 'tel_cell',
|
2014-02-13 14:54:52 +01:00
|
|
|
tel_fax2: 'tel_fax'
|
2014-02-13 11:06:18 +01:00
|
|
|
});
|
|
|
|
jQuery('table.editphones').css('display','none');
|
|
|
|
|
|
|
|
_event.stopPropagation();
|
|
|
|
return false;
|
2013-09-20 12:50:48 +02:00
|
|
|
},
|
|
|
|
|
2014-02-13 11:06:18 +01:00
|
|
|
/**
|
|
|
|
* Copy content of multiple fields
|
|
|
|
*
|
|
|
|
* @param {object} what object with src: dst pairs
|
|
|
|
*/
|
|
|
|
_copyvalues: function(what)
|
2013-09-20 12:50:48 +02:00
|
|
|
{
|
2014-02-13 11:06:18 +01:00
|
|
|
for(var name in what)
|
|
|
|
{
|
|
|
|
var src = this.et2.getWidgetById(name);
|
|
|
|
var dst = this.et2.getWidgetById(what[name]);
|
2014-02-13 18:29:44 +01:00
|
|
|
if (src && dst) dst.set_value(src.get_value ? src.get_value() : src.value);
|
2013-09-20 12:50:48 +02:00
|
|
|
}
|
2014-02-13 11:06:18 +01:00
|
|
|
// change tel_prefer according to what
|
|
|
|
var tel_prefer = this.et2.getWidgetById('tel_prefer');
|
2014-02-13 18:51:02 +01:00
|
|
|
if (tel_prefer)
|
|
|
|
{
|
|
|
|
var val = tel_prefer.get_value ? tel_prefer.get_value() : tel_prefer.value;
|
|
|
|
if (typeof what[val] != 'undefined') tel_prefer.set_value(what[val]);
|
|
|
|
}
|
2013-09-20 12:50:48 +02:00
|
|
|
},
|
|
|
|
|
2014-01-29 19:36:55 +01:00
|
|
|
/**
|
2014-01-31 16:37:44 +01:00
|
|
|
* Callback function to create confirm dialog for duplicates contacts
|
2014-01-29 19:36:55 +01:00
|
|
|
*
|
2014-01-31 16:37:44 +01:00
|
|
|
* @param {object} _data includes duplicates contacts information
|
2014-01-29 19:36:55 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
_confirmdialog_callback: function(_data)
|
|
|
|
{
|
2014-02-13 14:54:52 +01:00
|
|
|
var confirmdialog = function(_title, _value, _buttons, _egw_or_appname)
|
|
|
|
{
|
|
|
|
return et2_createWidget("dialog",
|
|
|
|
{
|
|
|
|
callback: function(_buttons, _value)
|
|
|
|
{
|
|
|
|
if (_buttons == et2_dialog.OK_BUTTON)
|
|
|
|
{
|
|
|
|
var id = '';
|
|
|
|
var content = this.template.widgetContainer.getArrayMgr('content').data;
|
|
|
|
for (var row in _value.grid)
|
|
|
|
{
|
|
|
|
if (_value.grid[row].confirm == "true" && typeof content.grid !='undefined')
|
2014-01-31 16:37:44 +01:00
|
|
|
{
|
2014-02-13 14:54:52 +01:00
|
|
|
id = this.options.value.content.grid[row].confirm;
|
|
|
|
egw.open(id, 'addressbook');
|
2014-01-29 19:36:55 +01:00
|
|
|
|
2014-02-13 14:54:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
title: _title||egw.lang('Input required'),
|
|
|
|
buttons: _buttons||et2_dialog.BUTTONS_OK_CANCEL,
|
|
|
|
value: {
|
|
|
|
content: {
|
|
|
|
grid: _value
|
|
|
|
}
|
|
|
|
},
|
|
|
|
template: egw.webserverUrl+'/addressbook/templates/default/dupconfirmdialog.xet'
|
|
|
|
}, et2_dialog._create_parent(_egw_or_appname));
|
|
|
|
};
|
2014-01-29 19:36:55 +01:00
|
|
|
|
|
|
|
if (_data.msg && _data.doublicates)
|
|
|
|
{
|
|
|
|
var content = [];
|
|
|
|
|
|
|
|
for(var id in _data.doublicates)
|
|
|
|
{
|
|
|
|
content.push({"confirm":id,"name":_data.doublicates[id]});
|
|
|
|
}
|
2014-01-31 16:37:44 +01:00
|
|
|
confirmdialog('Duplicate warning',content,et2_dialog.BUTTONs_OK_CANCEL);
|
2014-01-29 19:36:55 +01:00
|
|
|
}
|
2014-02-13 14:54:52 +01:00
|
|
|
if (typeof _data.fileas_options == 'object' && this.et2)
|
2014-01-29 19:36:55 +01:00
|
|
|
{
|
2014-02-13 14:54:52 +01:00
|
|
|
var selbox = this.et2.getWidgetById('fileas_type');
|
|
|
|
if (selbox)
|
2014-01-29 19:36:55 +01:00
|
|
|
{
|
|
|
|
selbox.set_select_options(_data.fileas_sel_options);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-02-13 11:06:18 +01:00
|
|
|
|
2014-01-29 19:36:55 +01:00
|
|
|
/**
|
2014-02-13 14:54:52 +01:00
|
|
|
* Callback if certain fields get changed
|
2014-01-29 19:36:55 +01:00
|
|
|
*
|
|
|
|
* @param {widget} widget widget
|
|
|
|
* @param {string} own_id Current AB id
|
|
|
|
*/
|
|
|
|
check_value: function(widget, own_id)
|
2013-09-20 12:50:48 +02:00
|
|
|
{
|
2014-03-28 17:56:35 +01:00
|
|
|
// if we edit an account, call account_change to let it do it's stuff too
|
|
|
|
if (this.et2.getWidgetById('account_lid'))
|
|
|
|
{
|
|
|
|
this.account_change(null, widget);
|
|
|
|
}
|
|
|
|
|
2014-02-13 14:54:52 +01:00
|
|
|
var values = this.et2._inst.getValues(this.et2);
|
2013-09-20 12:50:48 +02:00
|
|
|
|
2014-01-29 19:36:55 +01:00
|
|
|
if (widget.id.match(/n_/))
|
2012-09-06 14:26:11 +02:00
|
|
|
{
|
2013-09-20 12:50:48 +02:00
|
|
|
var value = '';
|
|
|
|
if (values.n_prefix) value += values.n_prefix+" ";
|
|
|
|
if (values.n_given) value += values.n_given+" ";
|
|
|
|
if (values.n_middle) value += values.n_middle+" ";
|
|
|
|
if (values.n_family) value += values.n_family+" ";
|
|
|
|
if (values.n_suffix) value += values.n_suffix;
|
|
|
|
|
2014-02-13 15:08:21 +01:00
|
|
|
var name = this.et2.getWidgetById("n_fn");
|
2014-01-29 19:36:55 +01:00
|
|
|
if (typeof name != 'undefined') name.set_value(value);
|
2012-09-06 14:26:11 +02:00
|
|
|
}
|
2014-01-29 19:36:55 +01:00
|
|
|
egw.json('addressbook.addressbook_ui.ajax_check_values', [values, widget.id, own_id],this._confirmdialog_callback,this,true,this).sendRequest();
|
2013-09-20 12:50:48 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
add_whole_list: function(list)
|
|
|
|
{
|
|
|
|
if (document.getElementById("exec[nm][email_type][email_home]").checked == true)
|
|
|
|
{
|
|
|
|
email_type = "email_home";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
email_type = "email";
|
|
|
|
}
|
|
|
|
var request = new egw_json_request("addressbook.addressbook_ui.ajax_add_whole_list",list,email_type);
|
|
|
|
request.sendRequest(true);
|
|
|
|
},
|
|
|
|
|
|
|
|
show_custom_country: function(selectbox)
|
|
|
|
{
|
|
|
|
if(!selectbox) return;
|
2013-11-27 00:37:48 +01:00
|
|
|
var custom_field_name = selectbox.id.replace("countrycode", "countryname");
|
2013-09-20 12:50:48 +02:00
|
|
|
var custom_field = document.getElementById(custom_field_name);
|
|
|
|
if(custom_field && selectbox.value == "-custom-") {
|
|
|
|
custom_field.style.display = "inline";
|
|
|
|
}
|
|
|
|
else if (custom_field)
|
|
|
|
{
|
|
|
|
if((selectbox.value == "" || selectbox.value == null) && custom_field.value != "")
|
|
|
|
{
|
|
|
|
selectbox.value = "-custom-";
|
|
|
|
// Chosen needs this to update
|
|
|
|
$j(selectbox).trigger("liszt:updated");
|
|
|
|
|
|
|
|
custom_field.style.display = "inline";
|
|
|
|
}
|
|
|
|
else
|
2013-06-19 21:02:41 +02:00
|
|
|
{
|
2013-09-20 12:50:48 +02:00
|
|
|
custom_field.style.display = "none";
|
2013-06-19 21:02:41 +02:00
|
|
|
}
|
2012-09-06 14:26:11 +02:00
|
|
|
}
|
2013-09-20 12:50:48 +02:00
|
|
|
},
|
2011-04-26 18:22:10 +02:00
|
|
|
|
2013-09-20 12:50:48 +02:00
|
|
|
add_new_list: function(owner)
|
2011-04-26 18:22:10 +02:00
|
|
|
{
|
2014-10-27 19:43:03 +01:00
|
|
|
if(!owner || typeof owner == 'object')
|
|
|
|
{
|
|
|
|
var filter = this.et2.getWidgetById('filter');
|
|
|
|
owner = filter.getValue()||egw.preference('add_default','addressbook');
|
|
|
|
}
|
2014-10-28 20:50:19 +01:00
|
|
|
var lists = this.et2.getWidgetById('filter2');
|
|
|
|
et2_dialog.show_prompt(
|
|
|
|
function(button, name) {
|
|
|
|
if(button == et2_dialog.OK_BUTTON)
|
|
|
|
{
|
|
|
|
egw.json('addressbook.addressbook_ui.ajax_set_list',[0, name, owner],
|
|
|
|
function(result)
|
|
|
|
{
|
|
|
|
if(typeof result == 'object') return; // This response not for us
|
|
|
|
// Update list
|
|
|
|
if(result)
|
|
|
|
{
|
|
|
|
lists.options.select_options.unshift({value:result,label:name});
|
|
|
|
lists.set_select_options(lists.options.select_options);
|
|
|
|
|
|
|
|
// Set to new list so they can see it easily
|
|
|
|
lists.set_value(result);
|
2015-03-06 15:35:19 +01:00
|
|
|
// Call cahnge event manually after setting the value
|
|
|
|
// Not sure why our selectbox does not trigger change event
|
|
|
|
jQuery(lists.node).change();
|
2014-10-28 20:50:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
).sendRequest(true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
this.egw.lang('Name for the distribution list'),
|
|
|
|
this.egw.lang('Add a new list...')
|
|
|
|
);
|
2013-09-20 12:50:48 +02:00
|
|
|
},
|
|
|
|
|
2014-10-27 19:43:03 +01:00
|
|
|
/**
|
|
|
|
* Rename the current distribution list selected in the nextmatch filter2
|
|
|
|
*
|
2014-10-28 20:50:19 +01:00
|
|
|
* Differences from add_new_list are in the dialog, parameters sent, and how the
|
|
|
|
* response is dealt with
|
|
|
|
*
|
2014-10-27 19:43:03 +01:00
|
|
|
* @param {egwAction} action Action selected in context menu (rename)
|
|
|
|
* @param {egwActionObject[]} selected The selected row(s). Not used for this.
|
|
|
|
*/
|
|
|
|
rename_list: function(action, selected)
|
|
|
|
{
|
|
|
|
var lists = this.et2.getWidgetById('filter2');
|
|
|
|
var list = lists.getValue() || 0;
|
|
|
|
var value = null;
|
|
|
|
for(var i = 0; i < lists.options.select_options.length; i++)
|
|
|
|
{
|
|
|
|
if(lists.options.select_options[i].value == list)
|
|
|
|
{
|
|
|
|
value = lists.options.select_options[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
et2_dialog.show_prompt(
|
|
|
|
function(button, name) {
|
|
|
|
if(button == et2_dialog.OK_BUTTON)
|
|
|
|
{
|
2014-10-28 20:50:19 +01:00
|
|
|
egw.json('addressbook.addressbook_ui.ajax_set_list',[list, name],
|
2014-10-27 19:43:03 +01:00
|
|
|
function(result)
|
|
|
|
{
|
|
|
|
if(typeof result == 'object') return; // This response not for us
|
|
|
|
// Update list
|
|
|
|
if(result)
|
|
|
|
{
|
|
|
|
value.label = name;
|
|
|
|
lists.set_select_options(lists.options.select_options);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
).sendRequest(true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
this.egw.lang('Name for the distribution list'),
|
|
|
|
this.egw.lang('Rename list'),
|
|
|
|
value.label
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2013-09-20 12:50:48 +02:00
|
|
|
filter2_onchange: function()
|
2011-04-26 18:22:10 +02:00
|
|
|
{
|
2013-09-20 12:50:48 +02:00
|
|
|
var filter2 = this.et2.getWidgetById('filter2');
|
|
|
|
var widget = this.et2.getWidgetById('nm');
|
2011-04-26 18:22:10 +02:00
|
|
|
|
2013-09-20 12:50:48 +02:00
|
|
|
if(filter2.get_value()=='add')
|
|
|
|
{
|
|
|
|
this.add_new_list(typeof widget == 'undefined' ? this.et2.getWidgetById('filter').value : widget.header.filter.get_value());
|
|
|
|
this.value='';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
filter2_onchnage_email: function ()
|
2011-04-26 18:22:10 +02:00
|
|
|
{
|
2013-09-20 12:50:48 +02:00
|
|
|
this.form.submit();
|
|
|
|
if (this.value && confirm('Add emails of whole distribution list?'))
|
|
|
|
{
|
|
|
|
this.add_whole_list(this.value);
|
|
|
|
}
|
|
|
|
else
|
2011-04-26 18:22:10 +02:00
|
|
|
{
|
2013-09-20 12:50:48 +02:00
|
|
|
this.form.submit();
|
|
|
|
}
|
|
|
|
},
|
2013-06-18 00:12:53 +02:00
|
|
|
|
2013-09-20 12:50:48 +02:00
|
|
|
/**
|
2014-02-13 14:54:52 +01:00
|
|
|
* Method to enable actions by comparing a field with given value
|
2013-09-20 12:50:48 +02:00
|
|
|
*/
|
|
|
|
nm_compare_field: function()
|
|
|
|
{
|
|
|
|
var field = this.et2.getWidgetById('filter2');
|
|
|
|
if (field) var val = field.get_value();
|
|
|
|
if (val)
|
|
|
|
{
|
|
|
|
return nm_compare_field;
|
2011-04-26 18:22:10 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-20 12:50:48 +02:00
|
|
|
return false;
|
2011-04-26 18:22:10 +02:00
|
|
|
}
|
2013-09-20 12:50:48 +02:00
|
|
|
},
|
2013-05-07 01:16:10 +02:00
|
|
|
|
2013-09-20 12:50:48 +02:00
|
|
|
/**
|
2014-09-08 20:47:40 +02:00
|
|
|
* Apply advanced search filters to index nextmatch
|
2014-10-16 11:32:13 +02:00
|
|
|
*
|
|
|
|
* @param {object} filters
|
2013-09-20 12:50:48 +02:00
|
|
|
*/
|
2014-09-08 20:47:40 +02:00
|
|
|
adv_search: function(filters)
|
|
|
|
{
|
|
|
|
var index = window.opener.etemplate2.getById('addressbook-index');
|
|
|
|
if(!index)
|
|
|
|
{
|
|
|
|
alert('Could not find index');
|
2014-12-12 15:21:04 +01:00
|
|
|
egw(window).close();
|
2014-09-08 20:47:40 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
var nm = index.widgetContainer.getWidgetById('nm');
|
|
|
|
if(!index)
|
|
|
|
{
|
|
|
|
window.opener.egw.message('Could not find list', 'error');
|
2014-12-12 15:21:04 +01:00
|
|
|
egw(window).close();
|
2014-09-08 20:47:40 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Reset filters first
|
|
|
|
nm.activeFilters = {};
|
|
|
|
nm.applyFilters(filters);
|
|
|
|
return false;
|
|
|
|
},
|
2013-09-20 12:50:48 +02:00
|
|
|
|
|
|
|
/**
|
2014-02-13 14:54:52 +01:00
|
|
|
* Mail vCard
|
2013-09-20 12:50:48 +02:00
|
|
|
*
|
2014-02-13 14:54:52 +01:00
|
|
|
* @param {object} _action
|
|
|
|
* @param {array} _elems
|
2013-09-20 12:50:48 +02:00
|
|
|
*/
|
|
|
|
adb_mail_vcard: function(_action, _elems)
|
2013-05-07 01:16:10 +02:00
|
|
|
{
|
2014-03-21 12:54:38 +01:00
|
|
|
var app_registry = egw.link_get_registry('mail');
|
|
|
|
var link = egw().link("/index.php","menuaction="+app_registry['add']['menuaction']);
|
2013-09-20 12:50:48 +02:00
|
|
|
for (var i = 0; i < _elems.length; i++)
|
|
|
|
{
|
2014-03-21 13:38:47 +01:00
|
|
|
var idToUse = _elems[i].id;
|
|
|
|
var idToUseArray = idToUse.split('::');
|
|
|
|
idToUse = idToUseArray[1];
|
2016-04-29 09:51:13 +02:00
|
|
|
link += "&preset[type][]="+encodeURIComponent("text/vcard; charset="+(egw.preference('vcard_charset', 'addressbook') || 'utf-8'));
|
2014-03-21 13:38:47 +01:00
|
|
|
link += "&preset[file][]="+encodeURIComponent("vfs://default/apps/addressbook/"+idToUse+"/.entry");
|
2013-09-20 12:50:48 +02:00
|
|
|
}
|
|
|
|
if (typeof app_registry['view'] != 'undefined' && typeof app_registry['view_popup'] != 'undefined' )
|
|
|
|
{
|
|
|
|
var w_h =app_registry['view_popup'].split('x');
|
|
|
|
if (w_h[1] == 'egw_getWindowOuterHeight()') w_h[1] = (screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight());
|
|
|
|
egw_openWindowCentered2(link, '_blank', w_h[0], w_h[1], 'yes');
|
|
|
|
}
|
2013-06-18 00:12:53 +02:00
|
|
|
|
2013-09-20 12:50:48 +02:00
|
|
|
},
|
|
|
|
|
2014-01-15 12:22:37 +01:00
|
|
|
/**
|
|
|
|
* Action function to set business or private mail checkboxes to user preferences
|
|
|
|
*
|
|
|
|
* @param {egwAction} action Action user selected.
|
|
|
|
*/
|
|
|
|
mailCheckbox: function(action)
|
|
|
|
{
|
|
|
|
var preferences = {
|
2014-02-13 14:54:52 +01:00
|
|
|
business: action.getManager().getActionById('email_business').checked ? true : false,
|
|
|
|
private: action.getManager().getActionById('email_home').checked ? true : false
|
|
|
|
};
|
|
|
|
this.egw.set_preference('addressbook','preferredMail', preferences);
|
2014-01-15 12:22:37 +01:00
|
|
|
},
|
2013-09-20 12:50:48 +02:00
|
|
|
|
2013-12-19 18:24:46 +01:00
|
|
|
/**
|
|
|
|
* Action function to add the email address (business or home) of the selected
|
|
|
|
* contacts to a compose email popup window.
|
|
|
|
*
|
|
|
|
* Uses the egw API to handle the opening of the popup.
|
|
|
|
*
|
|
|
|
* @param {egwAction} action Action user selected. Should have ID of either
|
|
|
|
* 'email_business' or 'email_home', from server side definition of actions.
|
|
|
|
* @param {egwActionObject[]} selected Selected rows
|
|
|
|
*/
|
|
|
|
addEmail: function(action, selected)
|
2013-09-20 12:50:48 +02:00
|
|
|
{
|
2014-10-16 11:32:13 +02:00
|
|
|
// Check for all selected.
|
2014-09-22 21:39:50 +02:00
|
|
|
var nm = this.et2.getWidgetById('nm');
|
|
|
|
if(fetchAll(selected, nm, jQuery.proxy(function(ids) {
|
|
|
|
// fetchAll() returns just the ID, no prefix, so map it to match normal selected
|
|
|
|
this.addEmail(action, ids.map(function(num) {return {id:'addressbook::'+num};}));
|
|
|
|
}, this)))
|
|
|
|
{
|
|
|
|
// Need more IDs, will use the above callback when they're ready.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-19 18:24:46 +01:00
|
|
|
// Go through selected & pull email addresses from data
|
|
|
|
var emails = [];
|
|
|
|
for(var i = 0; i < selected.length; i++)
|
|
|
|
{
|
|
|
|
// Pull data from global cache
|
|
|
|
var data = egw.dataGetUIDdata(selected[i].id) || {data:{}};
|
2014-01-13 18:40:36 +01:00
|
|
|
|
2014-01-15 10:11:32 +01:00
|
|
|
var email_business = data.data[action.getManager().getActionById('email_business').checked ? 'email' : ''];
|
|
|
|
var email = data.data[action.getManager().getActionById('email_home').checked ? 'email_home' : ''];
|
2014-12-05 13:37:40 +01:00
|
|
|
// prefix email with full name
|
|
|
|
var personal = data.data.n_fn || '';
|
|
|
|
if (personal.match(/[^a-z0-9. -]/i)) personal = '"'+personal.replace(/"/, '\\"')+'"';
|
|
|
|
|
2014-01-13 18:40:36 +01:00
|
|
|
if(email_business)
|
|
|
|
{
|
2014-12-05 13:37:40 +01:00
|
|
|
emails.push((personal?personal+' <':'')+email_business+(personal?'>':''));
|
2014-01-13 18:40:36 +01:00
|
|
|
}
|
2013-12-19 18:24:46 +01:00
|
|
|
if(email)
|
|
|
|
{
|
2014-12-05 13:37:40 +01:00
|
|
|
emails.push((personal?personal+' <':'')+email+(personal?'>':''));
|
2013-12-19 18:24:46 +01:00
|
|
|
}
|
|
|
|
}
|
2014-01-13 18:40:36 +01:00
|
|
|
switch (action.id)
|
2014-01-06 11:12:51 +01:00
|
|
|
{
|
2014-01-13 18:40:36 +01:00
|
|
|
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;
|
2014-01-06 11:12:51 +01:00
|
|
|
}
|
2014-01-13 18:40:36 +01:00
|
|
|
|
2013-12-19 18:24:46 +01:00
|
|
|
return false;
|
2013-09-20 12:50:48 +02:00
|
|
|
},
|
|
|
|
|
2013-12-07 00:13:33 +01:00
|
|
|
/**
|
|
|
|
* Retrieve the current state of the application for future restoration
|
|
|
|
*
|
|
|
|
* Overridden from parent to handle viewing a contact. In this case state
|
|
|
|
* will be {contact_id: #}
|
|
|
|
*
|
|
|
|
* @return {object} Application specific map representing the current state
|
|
|
|
*/
|
|
|
|
getState: function()
|
|
|
|
{
|
|
|
|
// Most likely we're in the list view
|
|
|
|
var state = this._super.apply(this, arguments);
|
|
|
|
|
|
|
|
if(jQuery.isEmptyObject(state))
|
|
|
|
{
|
|
|
|
// Not in a list view. Try to find contact ID
|
|
|
|
var etemplates = etemplate2.getByApplication('addressbook');
|
|
|
|
for(var i = 0; i < etemplates.length; i++)
|
|
|
|
{
|
|
|
|
var content = etemplates[i].widgetContainer.getArrayMgr("content");
|
|
|
|
if(content && content.getEntry('id'))
|
|
|
|
{
|
|
|
|
state = {app: 'addressbook', id: content.getEntry('id'), type: 'view'};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the application's state to the given state.
|
|
|
|
*
|
|
|
|
* Overridden from parent to stop the contact view's infolog nextmatch from
|
|
|
|
* being changed.
|
|
|
|
*
|
|
|
|
* @param {{name: string, state: object}|string} state Object (or JSON string) for a state.
|
|
|
|
* Only state is required, and its contents are application specific.
|
|
|
|
*
|
|
|
|
* @return {boolean} false - Returns false to stop event propagation
|
|
|
|
*/
|
|
|
|
setState: function(state)
|
|
|
|
{
|
|
|
|
var current_state = this.getState();
|
2014-01-06 11:12:51 +01:00
|
|
|
|
2013-12-07 00:13:33 +01:00
|
|
|
// State should be an object, not a string, but we'll parse
|
|
|
|
if(typeof state == "string")
|
|
|
|
{
|
|
|
|
if(state.indexOf('{') != -1 || state =='null')
|
|
|
|
{
|
|
|
|
state = JSON.parse(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Redirect from view to list - parent would do this, but infolog nextmatch stops it
|
|
|
|
if(current_state.app && current_state.id && (typeof state.state == 'undefined' || typeof state.state.app == 'undefined'))
|
|
|
|
{
|
|
|
|
// Redirect to list
|
|
|
|
// 'blank' is the special name for no filters, send that instead of the nice translated name
|
|
|
|
var safe_name = jQuery.isEmptyObject(state) || jQuery.isEmptyObject(state.state||state.filter) ? 'blank' : state.name.replace(/[^A-Za-z0-9-_]/g, '_');
|
|
|
|
egw.open('',this.appname,'list',{'favorite': safe_name},this.appname);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return this._super.apply(this, arguments);
|
2014-03-28 17:56:35 +01:00
|
|
|
},
|
2013-12-07 00:13:33 +01:00
|
|
|
|
2014-03-28 17:56:35 +01:00
|
|
|
/**
|
|
|
|
* Field changed, call server validation
|
|
|
|
*
|
|
|
|
* @param {jQuery.Event} _ev
|
|
|
|
* @param {et2_button} _widget
|
|
|
|
*/
|
|
|
|
account_change: function(_ev, _widget)
|
|
|
|
{
|
|
|
|
switch(_widget.id)
|
|
|
|
{
|
|
|
|
case 'account_lid':
|
|
|
|
case 'n_family':
|
|
|
|
case 'n_given':
|
|
|
|
case 'account_passwd_2':
|
|
|
|
var values = this.et2._inst.getValues(this.et2);
|
|
|
|
var data = {
|
|
|
|
account_id: this.et2.getArrayMgr('content').data.account_id,
|
|
|
|
account_lid: values.account_lid,
|
|
|
|
account_firstname: values.n_given,
|
|
|
|
account_lastname: values.n_family,
|
|
|
|
account_email: values.email,
|
|
|
|
account_passwd: values.account_passwd,
|
|
|
|
account_passwd_2: values.account_passwd_2
|
|
|
|
};
|
|
|
|
|
|
|
|
this.egw.message('');
|
2014-05-05 15:08:25 +02:00
|
|
|
this.egw.json('admin_account::ajax_check', [data, _widget.id], function(_msg)
|
2014-03-28 17:56:35 +01:00
|
|
|
{
|
|
|
|
if (_msg && typeof _msg == 'string')
|
|
|
|
{
|
|
|
|
egw(window).message(_msg, 'error'); // context get's lost :(
|
|
|
|
_widget.getDOMNode().focus();
|
|
|
|
}
|
|
|
|
}, this).sendRequest();
|
|
|
|
break;
|
|
|
|
}
|
2015-01-05 15:28:35 +01:00
|
|
|
},
|
2016-04-29 09:51:13 +02:00
|
|
|
|
2015-01-05 15:28:35 +01:00
|
|
|
/**
|
|
|
|
* Get title in order to set it as document title
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
getWindowTitle: function()
|
|
|
|
{
|
|
|
|
var widget = this.et2.getWidgetById('n_fn');
|
|
|
|
if(widget) return widget.options.value;
|
2014-03-28 17:56:35 +01:00
|
|
|
}
|
2013-10-07 18:53:13 +02:00
|
|
|
});
|