Skip to content

Commit

Permalink
UI-1944: Restrict access of faxboxes to non-trial users
Browse files Browse the repository at this point in the history
  • Loading branch information
JRMaitre committed Jan 19, 2016
1 parent b1a51a8 commit 1eeb9c3
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 70 deletions.
1 change: 1 addition & 0 deletions i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
145 changes: 75 additions & 70 deletions submodules/users/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 1eeb9c3

Please sign in to comment.