var html = '';
if (licenseInfo.key) {
html += '
' + FR.T('License key in use: %1').replace('%1', licenseInfo.key) + '
';
html += '' + FR.T('You are using %1 user accounts out of %2.').replace('%1', licenseInfo.users.current).replace('%2', licenseInfo.users.maximum) + '
';
if (licenseInfo.expiry) {
html += '' + FR.T('The license will expire on %1.').replace('%1', licenseInfo.expiry).replace('%2', licenseInfo.users.maximum) + '
';
}
} else {
html += '' + FR.T('You are using %1 user accounts out of %2.').replace('%1', licenseInfo.users.current).replace('%2', licenseInfo.users.maximum) + '
';
html += '' + FR.T('Click the above button to register your FileRun copy.') + '
';
}
FR.licensing = {
promptForEmail: function() {
new Ext.ux.prompt({text: FR.T('Please type your e-mail address.
It will be kept safe and you will not receive any unwanted messages.
It is needed for receiving a private license key which will give you access to the software update server.
'), defaultValue: userEmail, confirmHandler: function(emailAddress, d, prompt) {
FR.licensing.panel.bwrap.mask(FR.T('Please wait...'));
Ext.Ajax.request({
url: FR.URLRoot + '/?module=cpanel§ion=settings&page=license&action=request',
params: {
emailAddress: emailAddress
},
callback: function () {
if (FR.licensing.panel) {
FR.licensing.panel.bwrap.unmask();
}
},
success: function (req) {
try {
var rs = Ext.util.JSON.decode(req.responseText);
} catch (er) {return false;}
if (rs.success) {
FR.licensing.promptForKey();
} else {
if (rs.msg) {
new Ext.ux.prompt({
text: rs.msg, callback: function () {
FR.licensing.promptForEmail();
}
});
}
}
},
failure: function (f, a) {
new Ext.ux.prompt({text: f.responseText, callback: function() {
FR.licensing.promptForEmail();
}});
},
scope: this
});
prompt.close();
}, scope: this});
},
promptForKey: function() {
new Ext.ux.prompt({
text: FR.T('An e-mail message has been now sent to you.')+'
'+FR.T('Please paste here the received license key')+':',
defaultValue: '',
confirmHandler: function(lkey, d, prompt) {
FR.licensing.panel.bwrap.mask(FR.T('Please wait...'));
Ext.Ajax.request({
url: FR.URLRoot + '/?module=cpanel§ion=settings&page=license&action=applyKey',
params: {key: lkey},
callback: function () {
if (FR.licensing.panel) {FR.licensing.panel.bwrap.unmask();}
},
success: function (req) {
try {
var rs = Ext.util.JSON.decode(req.responseText);
} catch (er) {return false;}
if (rs.success) {
if (rs.msg) {FR.feedback(rs.msg);}
Ext.getCmp('appTab').removeAll(true);
FR.tempPanel.load({
url: FR.URLRoot + '/?module=cpanel§ion=settings&page=license',
scripts: true
});
} else {
if (rs.msg) {
new Ext.ux.prompt({text: rs.msg, callback: function() {
FR.licensing.promptForKey();
}});
}
}
},
failure: function (f, a) {
new Ext.ux.prompt({text: f.responseText, callback: function() {
FR.licensing.promptForKey();
}});
},
scope: this
});
}
});
}
};
FR.licensing.panel = new Ext.Panel({
title: FR.T('Software licensing'), layout:'fit', border: false,
bodyStyle: 'padding:15px;', cls: 'FREditForm',
html: html,
tbar: [
{
text: FR.T(licenseInfo.key ? 'Update' : 'Register'),
cls: 'fr-btn-primary',
iconCls: 'fa fa-fw fa-refresh color-white',
handler: function() {
if (!licenseInfo.key) {
FR.licensing.promptForEmail();
} else {
FR.licensing.panel.bwrap.mask(FR.T('Please wait...'));
Ext.Ajax.request({
url: FR.URLRoot + '/?module=cpanel§ion=settings&page=license&action=update',
callback: function () {
if (FR.licensing.panel) {
FR.licensing.panel.bwrap.unmask();
}
},
success: function (req) {
try {
var rs = Ext.util.JSON.decode(req.responseText);
} catch (er) {
return false;
}
if (rs.msg) {
FR.feedback(rs.msg);
Ext.getCmp('appTab').removeAll(true);
FR.tempPanel.load({
url: FR.URLRoot + '/?module=cpanel§ion=settings&page=license',
scripts: true
});
}
},
failure: function (f, a) {
FR.feedback(f.responseText);
},
scope: this
});
}
}
}
]
});
Ext.getCmp('appTab').add(FR.licensing.panel);
Ext.getCmp('appTab').doLayout();