added gcube client context inject
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/liferay62-plugins/d4science-responsive-theme@134055 82a268e6-3cf1-43bd-a215-b396298e98cfmaster
parent
1353f5afd0
commit
419afb7566
@ -0,0 +1,27 @@
|
||||
/* The following function simply injects the Liferay object fields userId and scopeGroupId in the XMLHttpRequest header.
|
||||
* So that every ajax call performed in the page has those parameters set.
|
||||
* Author: Massimiliano Assante, CNR-ISTI */
|
||||
function injectClientContext() {
|
||||
if (Liferay != null) {
|
||||
var userId;
|
||||
var groupId;
|
||||
if (Liferay.ThemeDisplay.isSignedIn()) {
|
||||
userId = Liferay.ThemeDisplay.getUserId();
|
||||
groupId = Liferay.ThemeDisplay.getScopeGroupId();
|
||||
//console.log('userId is = ' + userId);
|
||||
//console.log("groupId is = " + groupId);
|
||||
}
|
||||
else {
|
||||
groupId = Liferay.ThemeDisplay.getScopeGroupId();
|
||||
//console.log('Not logged in, injecting groupId only');
|
||||
}
|
||||
|
||||
XMLHttpRequest.prototype.realSend = XMLHttpRequest.prototype.send;
|
||||
var newSend = function(vData) {
|
||||
this.setRequestHeader("gcube-userId", userId);
|
||||
this.setRequestHeader("gcube-vreid", groupId);
|
||||
this.realSend(vData);
|
||||
};
|
||||
XMLHttpRequest.prototype.send = newSend;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue