2016-11-11 15:39:46 +01:00
/ *
* Author : Massimiliano Assante , CNR - ISTI
* * /
/ * T h e f o l l o w i n g f u n c t i o n s i m p l y i n j e c t s t h e L i f e r a y o b j e c t f i e l d s u s e r I d a n d s c o p e G r o u p I d i n t h e X M L H t t p R e q u e s t h e a d e r .
* So that every ajax call performed in the page has those parameters set . * /
function injectClientContext ( ) {
if ( Liferay != null ) {
var userId ;
var groupId ;
if ( Liferay . ThemeDisplay . isSignedIn ( ) ) {
userId = Liferay . ThemeDisplay . getUserId ( ) ;
groupId = Liferay . ThemeDisplay . getScopeGroupId ( ) ;
2016-11-25 10:15:49 +01:00
console . log ( "groupid is = " + groupId ) ;
2016-11-11 15:39:46 +01:00
}
else {
groupId = Liferay . ThemeDisplay . getScopeGroupId ( ) ;
//console.log('Not logged in, injecting groupId only');
}
2017-01-26 16:45:55 +01:00
//attach the 3 header params in all the XHR sends
( function ( send ) {
XMLHttpRequest . prototype . send = function ( data ) {
this . setRequestHeader ( "gcube-userId" , userId ) ;
this . setRequestHeader ( "gcube-vreid" , groupId ) ;
this . setRequestHeader ( "gcube-request-url" , location . href ) ;
send . call ( this , data ) ;
} ;
} ) ( XMLHttpRequest . prototype . send ) ;
2016-11-11 15:39:46 +01:00
}
}
/ *
* Override the expire function of the Liferay . Session javascript object . It makes the default behaviour and then open a modal
* * /
$ ( function ( ) {
2017-01-26 16:45:55 +01:00
AUI ( ) . use ( 'liferay-session' , function ( A ) {
if ( Liferay . Session ) {
console . log ( 'Liferay session default overridden' ) ;
Liferay . Session . expire = function ( ) {
var instance = this ;
instance . set ( 'sessionState' , 'expired' , { } ) ;
$ ( "#expirationModal" ) . css ( "display" , "block" ) ;
$ ( "#expirationModal" ) . modal ( { backdrop : 'static' , keyboard : false } , 'show' ) ;
$ ( "body div.alert.alert-block.popup-alert-warning.alert-error" ) . html ( "Due to inactivity your session has expired, please <a class='refresh' href=''>Refresh</a>" ) ;
} ;
}
2016-11-11 15:39:46 +01:00
} ) ;
2017-01-26 16:45:55 +01:00
} ) ;