2012-03-01 17:24:29 +01:00
|
|
|
/**
|
|
|
|
* EGroupware clientside API object
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage api
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Andreas Stöckel (as AT stylite.de)
|
|
|
|
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*egw:uses
|
|
|
|
egw_core;
|
|
|
|
*/
|
2021-06-05 20:39:39 +02:00
|
|
|
import './egw_core.js';
|
2012-03-01 17:24:29 +01:00
|
|
|
|
2014-03-28 09:06:30 +01:00
|
|
|
egw.extend('user', egw.MODULE_GLOBAL, function()
|
|
|
|
{
|
2016-02-29 16:50:24 +01:00
|
|
|
"use strict";
|
|
|
|
|
2012-03-01 17:24:29 +01:00
|
|
|
/**
|
|
|
|
* Data about current user
|
2014-03-28 09:06:30 +01:00
|
|
|
*
|
2012-03-01 17:24:29 +01:00
|
|
|
* @access: private, use egw.user(_field) or egw.app(_app)
|
|
|
|
*/
|
2022-04-27 17:33:07 +02:00
|
|
|
let userData = {apps: {}};
|
2012-03-01 17:24:29 +01:00
|
|
|
|
2014-04-23 21:00:59 +02:00
|
|
|
/**
|
|
|
|
* Client side cache of accounts user has access to
|
|
|
|
* Used by account select widgets
|
|
|
|
*/
|
2022-04-27 17:33:07 +02:00
|
|
|
let accountStore = {
|
2014-04-23 21:00:59 +02:00
|
|
|
// Filled by AJAX when needed
|
|
|
|
//accounts: {},
|
|
|
|
//groups: {},
|
|
|
|
//owngroups: {}
|
|
|
|
};
|
|
|
|
|
2015-05-28 16:40:33 +02:00
|
|
|
/**
|
|
|
|
* Clientside cache for accountData calls
|
|
|
|
*/
|
2022-04-27 17:33:07 +02:00
|
|
|
let accountData = {};
|
|
|
|
let resolveGroup = {};
|
2019-01-11 18:22:15 +01:00
|
|
|
|
2022-12-15 18:22:19 +01:00
|
|
|
// Hold in-progress request to avoid making more
|
|
|
|
let request = null;
|
|
|
|
|
2012-03-01 17:24:29 +01:00
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* Set data of current user
|
2014-03-28 09:06:30 +01:00
|
|
|
*
|
|
|
|
* @param {object} _data
|
2015-02-02 20:49:18 +01:00
|
|
|
* @param {boolean} _need_clone _data need to be cloned, as it is from different window context
|
|
|
|
* and therefore will be inaccessible in IE, after that window is closed
|
2012-03-01 17:24:29 +01:00
|
|
|
*/
|
2022-12-15 18:22:19 +01:00
|
|
|
set_user: function (_data, _need_clone)
|
2012-03-01 17:24:29 +01:00
|
|
|
{
|
2015-02-02 20:49:18 +01:00
|
|
|
userData = _need_clone ? jQuery.extend(true, {}, _data) : _data;
|
2012-03-01 17:24:29 +01:00
|
|
|
},
|
2014-03-28 09:06:30 +01:00
|
|
|
|
2012-03-01 17:24:29 +01:00
|
|
|
/**
|
|
|
|
* Get data about current user
|
|
|
|
*
|
2014-03-28 09:06:30 +01:00
|
|
|
* @param {string} _field
|
2020-07-31 09:47:49 +02:00
|
|
|
* - 'account_id','account_lid','person_id','account_status','memberships'
|
2012-03-01 17:24:29 +01:00
|
|
|
* - 'account_firstname','account_lastname','account_email','account_fullname','account_phone'
|
|
|
|
* - 'apps': object with app => data pairs the user has run-rights for
|
2014-03-28 09:06:30 +01:00
|
|
|
* @return {string|array|null}
|
2012-03-01 17:24:29 +01:00
|
|
|
*/
|
|
|
|
user: function (_field)
|
|
|
|
{
|
2014-03-28 09:06:30 +01:00
|
|
|
return userData[_field];
|
2012-03-01 17:24:29 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return data of apps the user has rights to run
|
2014-03-28 09:06:30 +01:00
|
|
|
*
|
2012-03-01 17:24:29 +01:00
|
|
|
* Can be used the check of run rights like: if (egw.app('addressbook')) { do something if user has addressbook rights }
|
2014-03-28 09:06:30 +01:00
|
|
|
*
|
|
|
|
* @param {string} _app
|
|
|
|
* @param {string} _name attribute to return, default return whole app-data-object
|
2012-03-01 17:24:29 +01:00
|
|
|
* @return object|string|null null if not found
|
|
|
|
*/
|
|
|
|
app: function(_app, _name)
|
|
|
|
{
|
2014-03-28 09:06:30 +01:00
|
|
|
return typeof _name == 'undefined' || typeof userData.apps[_app] == 'undefined' ?
|
|
|
|
userData.apps[_app] : userData.apps[_app][_name];
|
2014-04-23 21:00:59 +02:00
|
|
|
},
|
|
|
|
|
2024-09-17 10:49:03 +02:00
|
|
|
/**
|
|
|
|
* Same as app(), but use the translated app-name / title
|
|
|
|
*
|
|
|
|
* @param {string} _title
|
|
|
|
* @param {string} _name attribute to return, default return whole app-data-object
|
|
|
|
*/
|
|
|
|
appByTitle: function(_title, _name)
|
|
|
|
{
|
|
|
|
for(const app in userData.apps)
|
|
|
|
{
|
|
|
|
if (userData.apps[app].title === _title)
|
|
|
|
{
|
|
|
|
return typeof _name == 'undefined' || typeof userData.apps[app] == 'undefined' ?
|
|
|
|
userData.apps[app] : userData.apps[app][_name];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-04-23 21:00:59 +02:00
|
|
|
/**
|
|
|
|
* Get a list of accounts the user has access to
|
|
|
|
* The list is filtered by type, one of 'accounts','groups','both', 'owngroups'
|
|
|
|
*
|
|
|
|
* @param {string} type
|
2022-12-15 18:22:19 +01:00
|
|
|
* @returns {Promise<{value:string,label:string,icon?:string}[]>}
|
2014-04-23 21:00:59 +02:00
|
|
|
*/
|
2022-12-15 18:22:19 +01:00
|
|
|
accounts: function (type)
|
2014-04-23 21:00:59 +02:00
|
|
|
{
|
2022-12-15 18:22:19 +01:00
|
|
|
if (typeof type === 'undefined')
|
|
|
|
{
|
|
|
|
type = 'accounts';
|
|
|
|
}
|
2014-04-23 21:00:59 +02:00
|
|
|
|
2022-12-15 18:22:19 +01:00
|
|
|
if (request !== null)
|
|
|
|
{
|
|
|
|
return request.then(() =>
|
|
|
|
{
|
|
|
|
return this.accounts(type)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (jQuery.isEmptyObject(accountStore))
|
2014-04-23 21:00:59 +02:00
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
const cache_it = data =>
|
|
|
|
{
|
|
|
|
let types = ["accounts", "groups", "owngroups"];
|
2022-12-15 18:22:19 +01:00
|
|
|
for (let t of types)
|
2022-04-27 17:33:07 +02:00
|
|
|
{
|
2022-12-15 18:22:19 +01:00
|
|
|
if (typeof data[t] === "object")
|
2020-10-05 18:55:34 +02:00
|
|
|
{
|
2023-10-06 19:37:11 +02:00
|
|
|
accountStore[t] = (Array.isArray(data[t]) ? data[t]:Object.values(data[t]) ?? []).map(a => {a.value = ""+a.value; return a});
|
2020-10-05 18:55:34 +02:00
|
|
|
}
|
2022-04-27 17:33:07 +02:00
|
|
|
}
|
|
|
|
}
|
2022-12-15 18:22:19 +01:00
|
|
|
request = egw.request("EGroupware\\Api\\Framework::ajax_user_list", []).then(_data =>
|
2022-04-27 17:33:07 +02:00
|
|
|
{
|
2022-12-15 18:22:19 +01:00
|
|
|
cache_it(_data);
|
|
|
|
request = null;
|
|
|
|
return this.accounts(type);
|
|
|
|
});
|
|
|
|
return request;
|
2014-04-23 21:00:59 +02:00
|
|
|
}
|
2022-09-20 16:05:21 +02:00
|
|
|
let result = [];
|
2022-04-27 17:33:07 +02:00
|
|
|
if (type === 'both')
|
2014-04-23 21:00:59 +02:00
|
|
|
{
|
2023-07-11 22:16:10 +02:00
|
|
|
result = [...Object.values(accountStore.accounts), ...Object.values(accountStore.groups)];
|
2014-04-23 21:00:59 +02:00
|
|
|
}
|
2022-09-20 16:05:21 +02:00
|
|
|
else
|
|
|
|
{
|
2023-07-11 22:16:10 +02:00
|
|
|
result = [...Object.values(accountStore[type])];
|
2022-09-20 16:05:21 +02:00
|
|
|
}
|
2022-12-15 18:22:19 +01:00
|
|
|
return Promise.resolve(result);
|
2014-06-26 10:23:02 +02:00
|
|
|
},
|
|
|
|
|
2015-05-28 16:40:33 +02:00
|
|
|
/**
|
|
|
|
* Get account-infos for given numerical _account_ids
|
|
|
|
*
|
2022-04-27 17:33:07 +02:00
|
|
|
* @param {int|int[]} _account_ids
|
2015-05-28 16:40:33 +02:00
|
|
|
* @param {string} _field default 'account_email'
|
|
|
|
* @param {boolean} _resolve_groups true: return attribute for all members, false: return attribute of group
|
2022-04-27 17:33:07 +02:00
|
|
|
* @param {function|undefined} _callback deprecated, use egw.accountDate(...).then(data => _callback.bind(_context)(data))
|
|
|
|
* @param {object|undefined} _context deprecated, see _context
|
|
|
|
* @return {Promise} resolving to object { account_id => value, ... }
|
2015-05-28 16:40:33 +02:00
|
|
|
*/
|
|
|
|
accountData: function(_account_ids, _field, _resolve_groups, _callback, _context)
|
|
|
|
{
|
|
|
|
if (!_field) _field = 'account_email';
|
2022-04-27 17:33:07 +02:00
|
|
|
if (!Array.isArray(_account_ids)) _account_ids = [_account_ids];
|
2015-05-28 16:40:33 +02:00
|
|
|
|
|
|
|
// check our cache or current user first
|
2022-04-27 17:33:07 +02:00
|
|
|
const data = {};
|
|
|
|
let pending = false;
|
|
|
|
for(let i=0; i < _account_ids.length; ++i)
|
2015-05-28 16:40:33 +02:00
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
const account_id = _account_ids[i];
|
2015-05-28 16:40:33 +02:00
|
|
|
|
|
|
|
if (account_id == userData.account_id)
|
|
|
|
{
|
|
|
|
data[account_id] = userData[_field];
|
|
|
|
}
|
2022-04-27 17:33:07 +02:00
|
|
|
else if ((!_resolve_groups || account_id > 0) && typeof accountData[account_id] !== 'undefined' &&
|
|
|
|
typeof accountData[account_id][_field] !== 'undefined')
|
2015-05-28 16:40:33 +02:00
|
|
|
{
|
|
|
|
data[account_id] = accountData[account_id][_field];
|
2022-04-27 17:33:07 +02:00
|
|
|
pending = pending || data[account_id] instanceof Promise;
|
2015-05-28 16:40:33 +02:00
|
|
|
}
|
2022-04-27 17:33:07 +02:00
|
|
|
else if (_resolve_groups && account_id < 0 && typeof resolveGroup[account_id] !== 'undefined' &&
|
|
|
|
typeof resolveGroup[account_id][_field] != 'undefined')
|
2016-01-15 17:57:42 +01:00
|
|
|
{
|
|
|
|
// Groups are resolved on the server, but then the response
|
2022-04-27 17:33:07 +02:00
|
|
|
// is cached, so we can re-resolve it locally
|
|
|
|
for(let id in resolveGroup[account_id][_field])
|
2016-01-15 17:57:42 +01:00
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
data[id] = resolveGroup[account_id][_field][id];
|
|
|
|
pending = pending || data[id] instanceof Promise;
|
2016-01-15 17:57:42 +01:00
|
|
|
}
|
|
|
|
}
|
2015-05-28 16:40:33 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
_account_ids.splice(i--, 1);
|
|
|
|
}
|
|
|
|
|
2022-04-27 17:33:07 +02:00
|
|
|
let promise;
|
2015-05-28 16:40:33 +02:00
|
|
|
// something not found in cache --> ask server
|
|
|
|
if (_account_ids.length)
|
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
promise = egw.request('EGroupware\\Api\\Framework::ajax_account_data',[_account_ids, _field, _resolve_groups]).then(_data =>
|
|
|
|
{
|
|
|
|
for(let account_id in _data)
|
|
|
|
{
|
|
|
|
if (typeof accountData[account_id] === 'undefined')
|
2016-01-15 17:57:42 +01:00
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
accountData[account_id] = {};
|
2016-01-15 17:57:42 +01:00
|
|
|
}
|
2022-04-27 17:33:07 +02:00
|
|
|
data[account_id] = accountData[account_id][_field] = _data[account_id];
|
|
|
|
}
|
|
|
|
// If resolving for 1 group, cache the whole answer too
|
|
|
|
// (More than 1 group, we can't split to each group)
|
|
|
|
if(_resolve_groups && _account_ids.length === 1 && _account_ids[0] < 0)
|
|
|
|
{
|
|
|
|
const group_id = _account_ids[0];
|
|
|
|
if (typeof resolveGroup[group_id] === 'undefined')
|
2018-12-19 23:27:25 +01:00
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
resolveGroup[group_id] = {};
|
2018-12-19 23:27:25 +01:00
|
|
|
}
|
2022-04-27 17:33:07 +02:00
|
|
|
resolveGroup[group_id][_field] = _data;
|
2015-05-28 16:40:33 +02:00
|
|
|
}
|
2022-04-27 17:33:07 +02:00
|
|
|
return data;
|
|
|
|
});
|
|
|
|
|
|
|
|
// store promise, in case someone asks while the request is pending, to not query the server again
|
|
|
|
_account_ids.forEach(account_id =>
|
2018-12-19 23:27:25 +01:00
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
if (_resolve_groups && account_id < 0) return; // we must NOT cache the promise for account_id!
|
|
|
|
|
|
|
|
if (typeof accountData[account_id] === 'undefined')
|
2018-12-19 23:27:25 +01:00
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
accountData[account_id] = {};
|
2018-12-19 23:27:25 +01:00
|
|
|
}
|
2022-04-27 17:33:07 +02:00
|
|
|
accountData[account_id][_field] = promise.then(function(_data)
|
|
|
|
{
|
|
|
|
const result = {};
|
|
|
|
result[this.account_id] = _data[this.account_id];
|
|
|
|
return result;
|
|
|
|
}.bind({ account_id: account_id }));
|
|
|
|
});
|
|
|
|
if (_resolve_groups && _account_ids.length === 1 && _account_ids[0] < 0)
|
|
|
|
{
|
|
|
|
resolveGroup[_account_ids[0]] = promise;
|
2018-12-19 23:27:25 +01:00
|
|
|
}
|
2015-05-28 16:40:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
promise = Promise.resolve(data);
|
2015-05-28 16:40:33 +02:00
|
|
|
}
|
2022-04-27 17:33:07 +02:00
|
|
|
|
|
|
|
// if we have any pending promises, we need to resolve and merge them
|
|
|
|
if (pending)
|
|
|
|
{
|
|
|
|
promise = promise.then(_data =>
|
|
|
|
{
|
|
|
|
const promises = [];
|
|
|
|
for (let account_id in _data)
|
|
|
|
{
|
|
|
|
if (_data[account_id] instanceof Promise)
|
|
|
|
{
|
|
|
|
promises.push(_data[account_id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Promise.all(promises).then(_results =>
|
|
|
|
{
|
|
|
|
_results.forEach(result =>
|
|
|
|
{
|
|
|
|
for (let account_id in result)
|
|
|
|
{
|
|
|
|
_data[account_id] = result[account_id];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return _data;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// if deprecated callback is given, call it with then
|
|
|
|
if (typeof _callback === 'function')
|
|
|
|
{
|
|
|
|
promise = promise.then(_data =>
|
|
|
|
{
|
|
|
|
_callback.bind(_context)(_data);
|
|
|
|
return _data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return promise;
|
2015-05-28 16:40:33 +02:00
|
|
|
},
|
|
|
|
|
2019-09-11 21:28:33 +02:00
|
|
|
/**
|
|
|
|
* Set account data. This one can be called from the server to pre-fill the cache.
|
|
|
|
*
|
|
|
|
* @param {Array} _data
|
|
|
|
* @param {String} _field
|
|
|
|
*/
|
|
|
|
set_account_cache: function(_data, _field)
|
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
for(let account_id in _data)
|
2019-09-11 21:28:33 +02:00
|
|
|
{
|
|
|
|
if (typeof accountData[account_id] === 'undefined')
|
|
|
|
{
|
|
|
|
accountData[account_id] = {};
|
|
|
|
}
|
|
|
|
accountData[account_id][_field] = _data[account_id];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-08-02 11:40:02 +02:00
|
|
|
/**
|
|
|
|
* Set specified account-data of selected user in an other widget
|
|
|
|
*
|
|
|
|
* Used eg. in template as: onchange="egw.set_account_data(widget, 'target', 'account_email')"
|
|
|
|
*
|
|
|
|
* @param {et2_widget} _src_widget widget to select the user
|
|
|
|
* @param {string} _target_name name of widget to set the data
|
2018-08-03 15:38:34 +02:00
|
|
|
* @param {string} _field name of data to set eg. "account_email" or "{account_fullname} <{account_email}>"
|
2018-08-02 11:40:02 +02:00
|
|
|
*/
|
|
|
|
set_account_data: function(_src_widget, _target_name, _field)
|
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
const user = _src_widget.get_value();
|
|
|
|
const target = _src_widget.getRoot().getWidgetById(_target_name);
|
|
|
|
const field = _field;
|
2018-08-02 11:40:02 +02:00
|
|
|
|
|
|
|
if (user && target)
|
|
|
|
{
|
|
|
|
egw.accountData(user, _field, false, function(_data)
|
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
let data;
|
2018-08-03 15:38:34 +02:00
|
|
|
if (field.indexOf('{') == -1)
|
|
|
|
{
|
|
|
|
data = _data[user];
|
2018-10-09 17:41:27 +02:00
|
|
|
target.set_value(data);
|
2018-08-03 15:38:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data = field;
|
2018-10-09 17:41:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* resolve given data whilst the condition met
|
|
|
|
*/
|
2022-04-27 17:33:07 +02:00
|
|
|
const resolveData = function(_d, condition, action) {
|
|
|
|
const whilst = function (_d) {
|
2018-10-09 17:41:27 +02:00
|
|
|
return condition(_d) ? action(condition(_d)).then(whilst) : Promise.resolve(_d);
|
|
|
|
}
|
|
|
|
return whilst(_d);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get data promise
|
|
|
|
*/
|
2022-04-27 17:33:07 +02:00
|
|
|
const getData = function(_match)
|
2018-08-03 15:38:34 +02:00
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
const match = _match;
|
2018-10-09 17:41:27 +02:00
|
|
|
return new Promise(function(resolve)
|
2018-08-03 15:38:34 +02:00
|
|
|
{
|
2018-10-09 17:41:27 +02:00
|
|
|
egw.accountData(user, match, false, function(_d)
|
|
|
|
{
|
|
|
|
data = data.replace(/{([^}]+)}/, _d[user]);
|
|
|
|
resolve(data);
|
|
|
|
});
|
2018-08-03 15:38:34 +02:00
|
|
|
});
|
2018-10-09 17:41:27 +02:00
|
|
|
};
|
|
|
|
|
2022-04-27 17:33:07 +02:00
|
|
|
// run resolve data
|
|
|
|
resolveData(data, function(_d) {
|
|
|
|
const r = _d.match(/{([^}]+)}/);
|
2018-10-09 17:41:27 +02:00
|
|
|
return r && r.length > 0 ? r[1] : r;
|
|
|
|
},
|
|
|
|
getData).then(function(data){
|
|
|
|
target.set_value(data)
|
|
|
|
});
|
2018-08-03 15:38:34 +02:00
|
|
|
}
|
2018-08-02 11:40:02 +02:00
|
|
|
});
|
2022-04-27 17:33:07 +02:00
|
|
|
}
|
2018-08-02 11:40:02 +02:00
|
|
|
},
|
|
|
|
|
2014-06-26 10:23:02 +02:00
|
|
|
/**
|
|
|
|
* Invalidate client-side account cache
|
|
|
|
*
|
|
|
|
* For _type == "add" we invalidate the whole cache currently.
|
|
|
|
*
|
|
|
|
* @param {number} _id nummeric account_id, !_id will invalidate whole cache
|
|
|
|
* @param {string} _type "add", "delete", "update" or "edit"
|
|
|
|
*/
|
|
|
|
invalidate_account: function(_id, _type)
|
|
|
|
{
|
2015-05-28 16:40:33 +02:00
|
|
|
if (_id)
|
|
|
|
{
|
|
|
|
delete accountData[_id];
|
2022-04-27 17:33:07 +02:00
|
|
|
delete resolveGroup[_id];
|
2015-05-28 16:40:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
accountData = {};
|
2022-04-27 17:33:07 +02:00
|
|
|
resolveGroup = {};
|
2015-05-28 16:40:33 +02:00
|
|
|
}
|
2014-06-26 10:23:02 +02:00
|
|
|
if (jQuery.isEmptyObject(accountStore)) return;
|
|
|
|
|
|
|
|
switch(_type)
|
|
|
|
{
|
|
|
|
case 'delete':
|
|
|
|
case 'edit':
|
|
|
|
case 'update':
|
|
|
|
if (_id)
|
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
const store = _id < 0 ? accountStore.groups : accountStore.accounts;
|
|
|
|
for(let i=0; i < store.length; ++i)
|
2014-06-26 10:23:02 +02:00
|
|
|
{
|
2014-10-01 17:53:31 +02:00
|
|
|
if (store && typeof store[i] != 'undefined' && _id == store[i].value)
|
2014-06-26 10:23:02 +02:00
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
if (_type === 'delete')
|
2014-06-26 10:23:02 +02:00
|
|
|
{
|
|
|
|
delete(store[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-01 11:57:48 +02:00
|
|
|
this.link_title('api-accounts', _id, function(_label)
|
2014-06-26 10:23:02 +02:00
|
|
|
{
|
|
|
|
store[i].label = _label;
|
|
|
|
if (_id < 0)
|
|
|
|
{
|
2022-04-27 17:33:07 +02:00
|
|
|
for(let j=0; j < accountStore.owngroups.length; ++j)
|
2014-06-26 10:23:02 +02:00
|
|
|
{
|
|
|
|
if (_id == accountStore.owngroups[j].value)
|
|
|
|
{
|
|
|
|
accountStore.owngroups[j].label = _label;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, this, true); // true = force reload
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// fall through
|
|
|
|
default:
|
|
|
|
accountStore = {};
|
|
|
|
break;
|
|
|
|
}
|
2012-03-01 17:24:29 +01:00
|
|
|
}
|
|
|
|
};
|
2022-04-27 17:33:07 +02:00
|
|
|
});
|