From 1eeb9c33cf4bf741c71c8db111ee92517acbc7cf Mon Sep 17 00:00:00 2001 From: Jean-Roch Maitre Date: Tue, 19 Jan 2016 15:02:37 -0800 Subject: [PATCH] UI-1944: Restrict access of faxboxes to non-trial users --- i18n/en-US.json | 1 + submodules/users/users.js | 145 ++++++++++++++++++++------------------ 2 files changed, 76 insertions(+), 70 deletions(-) diff --git a/i18n/en-US.json b/i18n/en-US.json index 96b2e326..6dc3a6ce 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -545,6 +545,7 @@ "noConfNumbers": "You need to add a Main Conference Number (in the Main number section on the left of the SmartPBX) in order to enable the Personnals Conference Bridges" }, "faxing": { + "trialError": "You're currently using a trial version of the UI. Please upgrade your account to have access to the Faxing feature!", "title": "Faxbox", "headline": "Faxbox", "defaultSettings": { diff --git a/submodules/users/users.js b/submodules/users/users.js index 0c399470..77bd489c 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -1344,89 +1344,94 @@ define(function(require){ }); template.on('click', '.feature[data-feature="faxing"]', function() { - monster.parallel({ - numbers: function(callback) { - self.usersListNumbers(function(listNumbers) { - var spareNumbers = {}; + if(!monster.util.isTrial()) { + monster.parallel({ + numbers: function(callback) { + self.usersListNumbers(function(listNumbers) { + var spareNumbers = {}; - _.each(listNumbers.numbers, function(number, key) { - if(number.used_by === '') { - spareNumbers[key] = number; - } + _.each(listNumbers.numbers, function(number, key) { + if(number.used_by === '') { + spareNumbers[key] = number; + } + }); + + callback && callback(null, spareNumbers); }); + }, + callflows: function(callback) { + self.usersListCallflowsUser(currentUser.id, function(callflows) { + var existingCallflow; - callback && callback(null, spareNumbers); - }); - }, - callflows: function(callback) { - self.usersListCallflowsUser(currentUser.id, function(callflows) { - var existingCallflow; + _.each(callflows, function(callflow) { + if(callflow.type === 'faxing') { + existingCallflow = callflow; - _.each(callflows, function(callflow) { - if(callflow.type === 'faxing') { - existingCallflow = callflow; + return false; + } + }); - return false; + if ( existingCallflow ) { + self.callApi({ + resource: 'callflow.get', + data: { + accountId: self.accountId, + callflowId: existingCallflow.id + }, + success: function(data, status) { + callback && callback(null, data.data); + } + }); + } else { + callback && callback(null, existingCallflow); } }); - - if ( existingCallflow ) { - self.callApi({ - resource: 'callflow.get', - data: { - accountId: self.accountId, - callflowId: existingCallflow.id - }, - success: function(data, status) { - callback && callback(null, data.data); - } - }); - } else { - callback && callback(null, existingCallflow); - } - }); + }, + account: function(callback) { + self.callApi({ + resource: 'account.get', + data: { + accountId: self.accountId + }, + success: function(data, status) { + callback(null, data.data); + } + }); + } }, - account: function(callback) { - self.callApi({ - resource: 'account.get', - data: { - accountId: self.accountId - }, - success: function(data, status) { - callback(null, data.data); - } - }); - } - }, - function(err, results) { - results.user = currentUser; + function(err, results) { + results.user = currentUser; - if ( typeof results.callflows !== 'undefined' ) { - // Compatibility with old version - var faxboxId = results.callflows.flow.data.hasOwnProperty('faxbox_id') ? results.callflows.flow.data.faxbox_id : results.callflows.flow.data.id; + if ( typeof results.callflows !== 'undefined' ) { + // Compatibility with old version + var faxboxId = results.callflows.flow.data.hasOwnProperty('faxbox_id') ? results.callflows.flow.data.faxbox_id : results.callflows.flow.data.id; - self.callApi({ - resource: 'faxbox.get', - data: { - accountId: self.accountId, - faxboxId: faxboxId - }, - success: function(_data) { - results.faxbox = _data.data; + self.callApi({ + resource: 'faxbox.get', + data: { + accountId: self.accountId, + faxboxId: faxboxId + }, + success: function(_data) { + results.faxbox = _data.data; - results.faxbox.id = faxboxId; + results.faxbox.id = faxboxId; - self.usersRenderFaxboxes(results); - }, - error: function() { - self.usersRenderFaxboxes(results); - } - }); - } else { - self.usersRenderFaxboxes(results); + self.usersRenderFaxboxes(results); + }, + error: function() { + self.usersRenderFaxboxes(results); + } + }); + } else { + self.usersRenderFaxboxes(results); + } } - } - ); + ); + } + else { + monster.ui.alert('warning', self.i18n.active().users.faxing.trialError); + } }); $('body').on('click', '#users_container_overlay', function() {