Expose display name in JS side
Adds a new method `OC.getCurrentUser` to get both the user id and display name Could be used for a future Js
This commit is contained in:
parent
67a36a2cca
commit
3b581b051f
|
@ -82,6 +82,12 @@ var OC={
|
|||
webroot:oc_webroot,
|
||||
|
||||
appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
|
||||
/**
|
||||
* Currently logged in user or null if none
|
||||
*
|
||||
* @type String
|
||||
* @deprecated use {@link OC.getCurrentUser} instead
|
||||
*/
|
||||
currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false,
|
||||
config: window.oc_config,
|
||||
appConfig: window.oc_appconfig || {},
|
||||
|
@ -271,6 +277,23 @@ var OC={
|
|||
return OC.webroot;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the currently logged in user or null if there is no logged in
|
||||
* user (public page mode)
|
||||
*
|
||||
* @return {OC.CurrentUser} user spec
|
||||
* @since 9.0.0
|
||||
*/
|
||||
getCurrentUser: function() {
|
||||
if (_.isUndefined(this._currentUserDisplayName)) {
|
||||
this._currentUserDisplayName = document.getElementsByTagName('head')[0].getAttribute('data-user-displayname');
|
||||
}
|
||||
return {
|
||||
uid: this.currentUser,
|
||||
displayName: this._currentUserDisplayName
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* get the absolute path to an image file
|
||||
* if no extension is given for the image, it will automatically decide
|
||||
|
@ -689,6 +712,15 @@ var OC={
|
|||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Current user attributes
|
||||
*
|
||||
* @typedef {Object} OC.CurrentUser
|
||||
*
|
||||
* @property {String} uid user id
|
||||
* @property {String} displayName display name
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace OC.Plugins
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--[if lte IE 8]><html class="ng-csp ie ie8 lte9 lte8" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" ><![endif]-->
|
||||
<!--[if IE 9]><html class="ng-csp ie ie9 lte9" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" ><![endif]-->
|
||||
<!--[if (gt IE 9)|!(IE)]><!--><html class="ng-csp" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" ><!--<![endif]-->
|
||||
<head data-user="<?php p($_['user_uid']); ?>" data-requesttoken="<?php p($_['requesttoken']); ?>"
|
||||
<head data-user="<?php p($_['user_uid']); ?>" data-user-displayname="<?php p($_['user_displayname']); ?>" data-requesttoken="<?php p($_['requesttoken']); ?>"
|
||||
<?php if ($_['updateAvailable']): ?>
|
||||
data-update-version="<?php p($_['updateVersion']); ?>" data-update-link="<?php p($_['updateLink']); ?>"
|
||||
<?php endif; ?>
|
||||
|
|
Loading…
Reference in New Issue