fixed error because using (by loading order sometimes) uninitialised class-variable instead of documented and initialies private var

This commit is contained in:
Ralf Becker 2014-03-28 08:06:30 +00:00
parent d6747117ca
commit 115aabf21a

View File

@ -16,11 +16,11 @@
egw_core; egw_core;
*/ */
egw.extend('user', egw.MODULE_GLOBAL, function() { egw.extend('user', egw.MODULE_GLOBAL, function()
{
/** /**
* Data about current user * Data about current user
* *
* @access: private, use egw.user(_field) or egw.app(_app) * @access: private, use egw.user(_field) or egw.app(_app)
*/ */
var userData = {}; var userData = {};
@ -28,41 +28,41 @@ egw.extend('user', egw.MODULE_GLOBAL, function() {
return { return {
/** /**
* Set data of current user * Set data of current user
* *
* @param object _data * @param {object} _data
*/ */
set_user: function(_data) set_user: function(_data)
{ {
this.userData = _data; userData = _data;
}, },
/** /**
* Get data about current user * Get data about current user
* *
* @param string _field * @param {string} _field
* - 'account_id','account_lid','person_id','account_status', * - 'account_id','account_lid','person_id','account_status',
* - 'account_firstname','account_lastname','account_email','account_fullname','account_phone' * - 'account_firstname','account_lastname','account_email','account_fullname','account_phone'
* - 'apps': object with app => data pairs the user has run-rights for * - 'apps': object with app => data pairs the user has run-rights for
* @return string|array|null * @return {string|array|null}
*/ */
user: function (_field) user: function (_field)
{ {
return this.userData[_field]; return userData[_field];
}, },
/** /**
* Return data of apps the user has rights to run * Return data of apps the user has rights to run
* *
* Can be used the check of run rights like: if (egw.app('addressbook')) { do something if user has addressbook rights } * Can be used the check of run rights like: if (egw.app('addressbook')) { do something if user has addressbook rights }
* *
* @param string _app * @param {string} _app
* @param string _name attribute to return, default return whole app-data-object * @param {string} _name attribute to return, default return whole app-data-object
* @return object|string|null null if not found * @return object|string|null null if not found
*/ */
app: function(_app, _name) app: function(_app, _name)
{ {
return typeof _name == 'undefined' || typeof this.userData.apps[_app] == 'undefined' ? return typeof _name == 'undefined' || typeof userData.apps[_app] == 'undefined' ?
this.userData.apps[_app] : this.userData.apps[_app][_name]; userData.apps[_app] : userData.apps[_app][_name];
} }
}; };