37 lines
No EOL
876 B
JavaScript
37 lines
No EOL
876 B
JavaScript
/*eslint no-var: "error" */
|
|
/*eslint-env es6*/
|
|
|
|
import {call} from 'core/ajax';
|
|
import notification from 'core/notification';
|
|
|
|
// Prepare default value.
|
|
let premiumstatus_cache = null;
|
|
|
|
/**
|
|
* Check if premium status is enabled.
|
|
* @returns {Bool} True/False
|
|
*/
|
|
export function premiumenabled (){
|
|
const premium = premiumstatus();
|
|
return (premium.enabled)?true:false;
|
|
}
|
|
|
|
/**
|
|
* Get premium status object
|
|
* @returns {Object} The premium status object
|
|
*/
|
|
function premiumstatus() {
|
|
if (!premiumstatus_cache) {
|
|
// Retrieve premium status if needed.
|
|
call([{
|
|
methodname: 'local_treestudyplan_premiumstatus',
|
|
args: {}
|
|
}])[0].then(function(response){
|
|
premiumstatus_cache = response;
|
|
}).catch(notification.exception);
|
|
}
|
|
return premiumstatus_cache;
|
|
}
|
|
|
|
// Preload premium status.
|
|
premiumstatus(); |