diff --git a/baseTemplate/static/baseTemplate/custom-js/system-status.js b/baseTemplate/static/baseTemplate/custom-js/system-status.js
index e0ca09fb0..d4f56b8bc 100644
--- a/baseTemplate/static/baseTemplate/custom-js/system-status.js
+++ b/baseTemplate/static/baseTemplate/custom-js/system-status.js
@@ -125,6 +125,7 @@ app.controller('adminController', function($scope,$http,$timeout) {
$("#normalUserG").hide();
$("#normalUserH").hide();
$("#normalUserP").hide();
+ $("#normalUserI").hide();
$("#ssl").hide();
$("#sslA").hide();
diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html
index 065e30264..42228d6ff 100755
--- a/baseTemplate/templates/baseTemplate/index.html
+++ b/baseTemplate/templates/baseTemplate/index.html
@@ -548,7 +548,7 @@
-
+
{% trans "Mail Settings" %}
diff --git a/emailPremium/models.pyc b/emailPremium/models.pyc
index 575d46341..7e4c5d6c3 100644
Binary files a/emailPremium/models.pyc and b/emailPremium/models.pyc differ
diff --git a/emailPremium/views.py b/emailPremium/views.py
index aa6ba2f6c..9370e5bb6 100644
--- a/emailPremium/views.py
+++ b/emailPremium/views.py
@@ -34,7 +34,7 @@ def listDomains(request):
if admin.type == 1:
websites = Websites.objects.all()
else:
- websites = Websites.objects.filter(admin=admin)
+ return HttpResponse("Only administrator can view this page.")
pages = float(len(websites)) / float(10)
@@ -84,15 +84,14 @@ def getFurtherDomains(request):
websites = Websites.objects.all()[finalPageNumber:endPageNumber]
else:
- finalPageNumber = ((pageNumber * 10)) - 10
- endPageNumber = finalPageNumber + 10
- websites = Websites.objects.filter(admin=admin)[finalPageNumber:endPageNumber]
+ final_dic = {'listWebSiteStatus': 0, 'error_message': "Only administrator can view this page."}
+ final_json = json.dumps(final_dic)
+ return HttpResponse(final_json)
json_data = "["
checker = 0
for items in websites:
-
try:
domain = Domains.objects.get(domainOwner=items)
domainLimits = DomainLimits.objects.get(domain=domain)
@@ -112,8 +111,6 @@ def getFurtherDomains(request):
json_data = json_data + ']'
final_dic = {'listWebSiteStatus': 1, 'error_message': "None", "data": json_data}
final_json = json.dumps(final_dic)
-
-
return HttpResponse(final_json)
except BaseException,msg:
@@ -134,6 +131,13 @@ def enableDisableEmailLimits(request):
if request.method == 'POST':
admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+
data = json.loads(request.body)
operationVal = data['operationVal']
domainName = data['domainName']
@@ -166,9 +170,13 @@ def enableDisableEmailLimits(request):
def emailLimits(request,domain):
try:
val = request.session['userID']
-
admin = Administrator.objects.get(pk=val)
+ admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ return HttpResponse("Only administrator can view this page.")
+
if Websites.objects.filter(domain=domain).exists():
if admin.type == 1:
@@ -189,7 +197,6 @@ def emailLimits(request,domain):
Data['limitsOn'] = 0
Data['limitsOff'] = 1
-
## Pagination for emails
@@ -226,6 +233,12 @@ def changeDomainLimit(request):
if request.method == 'POST':
admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
data = json.loads(request.body)
newLimit = data['newLimit']
domainName = data['domainName']
@@ -260,6 +273,12 @@ def getFurtherEmail(request):
try:
if request.method == 'POST':
admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
data = json.loads(request.body)
status = data['page']
domainName = data['domainName']
@@ -314,6 +333,13 @@ def enableDisableIndividualEmailLimits(request):
try:
if request.method == 'POST':
+ admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
data = json.loads(request.body)
operationVal = data['operationVal']
emailAddress = data['emailAddress']
@@ -343,9 +369,11 @@ def enableDisableIndividualEmailLimits(request):
def emailPage(request, emailAddress):
try:
val = request.session['userID']
-
admin = Administrator.objects.get(pk=val)
+ if admin.type != 1:
+ return HttpResponse("Only administrator can view this page.")
+
Data = {}
Data['emailAddress'] = emailAddress
@@ -376,7 +404,14 @@ def getEmailStats(request):
val = request.session['userID']
try:
if request.method == 'POST':
+
admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
data = json.loads(request.body)
emailAddress = data['emailAddress']
@@ -411,6 +446,13 @@ def enableDisableIndividualEmailLogs(request):
try:
if request.method == 'POST':
+ admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
data = json.loads(request.body)
operationVal = data['operationVal']
emailAddress = data['emailAddress']
@@ -444,6 +486,12 @@ def changeDomainEmailLimitsIndividual(request):
if request.method == 'POST':
admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
data = json.loads(request.body)
emailAddress = data['emailAddress']
monthlyLimit = data['monthlyLimit']
@@ -511,6 +559,12 @@ def getEmailLogs(request):
if request.method == 'POST':
admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
data = json.loads(request.body)
status = data['page']
emailAddress = data['emailAddress']
@@ -559,6 +613,13 @@ def flushEmailLogs(request):
try:
if request.method == 'POST':
+ admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
data = json.loads(request.body)
emailAddress = data['emailAddress']
@@ -587,6 +648,10 @@ def flushEmailLogs(request):
def spamAssassinHome(request):
try:
val = request.session['userID']
+ admin = Administrator.objects.get(pk=val)
+
+ if admin.type != 1:
+ return HttpResponse("Only administrator can view this page.")
checkIfSpamAssassinInstalled = 0
@@ -602,6 +667,14 @@ def installSpamAssassin(request):
try:
val = request.session['userID']
try:
+
+ admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
thread.start_new_thread(mailUtilities.installSpamAssassin, ('Install','SpamAssassin'))
final_json = json.dumps({'status': 1, 'error_message': "None"})
return HttpResponse(final_json)
@@ -620,6 +693,13 @@ def installStatusSpamAssassin(request):
try:
if request.method == 'POST':
+ admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
command = "sudo cat " + mailUtilities.spamassassinInstallLogPath
installStatus = subprocess.check_output(shlex.split(command))
@@ -751,6 +831,13 @@ def saveSpamAssassinConfigurations(request):
try:
if request.method == 'POST':
+ admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if admin.type != 1:
+ dic = {'status': 0, 'error_message': "Only administrator can view this page."}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
data = json.loads(request.body)
report_safe = data['report_safe']
diff --git a/mailServer/models.pyc b/mailServer/models.pyc
index be9900f8f..7875f6c27 100644
Binary files a/mailServer/models.pyc and b/mailServer/models.pyc differ
diff --git a/manageSSL/views.py b/manageSSL/views.py
index 8d1d400f0..ddf023903 100644
--- a/manageSSL/views.py
+++ b/manageSSL/views.py
@@ -271,9 +271,6 @@ def obtainMailServerSSL(request):
execPath = execPath + " issueSSLForMailServer --virtualHostName " + virtualHost + " --path " + path
- logging.writeToFile(execPath)
-
-
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
diff --git a/plogical/virtualHostUtilities.py b/plogical/virtualHostUtilities.py
index d19ce8b37..25e4ae4dd 100644
--- a/plogical/virtualHostUtilities.py
+++ b/plogical/virtualHostUtilities.py
@@ -1055,6 +1055,30 @@ class virtualHostUtilities:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [getDiskUsage]")
return [int(0), int(0)]
+ @staticmethod
+ def permissionControl(path):
+ try:
+ command = 'sudo chown -R cyberpanel:cyberpanel ' + path
+
+ cmd = shlex.split(command)
+
+ res = subprocess.call(cmd)
+
+ except BaseException, msg:
+ logging.CyberCPLogFileWriter.writeToFile(str(msg))
+
+ @staticmethod
+ def leaveControl(path):
+ try:
+ command = 'sudo chown -R root:root ' + path
+
+ cmd = shlex.split(command)
+
+ res = subprocess.call(cmd)
+
+ except BaseException, msg:
+ logging.CyberCPLogFileWriter.writeToFile(str(msg))
+
def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
diff --git a/static/baseTemplate/custom-js/system-status.js b/static/baseTemplate/custom-js/system-status.js
index e0ca09fb0..d4f56b8bc 100644
--- a/static/baseTemplate/custom-js/system-status.js
+++ b/static/baseTemplate/custom-js/system-status.js
@@ -125,6 +125,7 @@ app.controller('adminController', function($scope,$http,$timeout) {
$("#normalUserG").hide();
$("#normalUserH").hide();
$("#normalUserP").hide();
+ $("#normalUserI").hide();
$("#ssl").hide();
$("#sslA").hide();
diff --git a/static/emailPremium/emailPremium.js b/static/emailPremium/emailPremium.js
index 37b118fd1..e2a7f3e09 100644
--- a/static/emailPremium/emailPremium.js
+++ b/static/emailPremium/emailPremium.js
@@ -110,18 +110,23 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) {
$scope.listFail = true;
$scope.emailLimitsLoading = true;
+ var globalDomainName = window.location.pathname.split("/")[2];
+
// Global page number, to be used in later function to refresh the domains
var globalPageNumber;
- $scope.getFurtherWebsitesFromDB = function(pageNumber) {
+ $scope.getFurtherEmailsFromDB = function(pageNumber) {
globalPageNumber = pageNumber;
$scope.emailLimitsLoading = false;
- url = "/emailPremium/getFurtherDomains";
+ url = "/emailPremium/getFurtherEmail";
- var data = {page: pageNumber};
+ var data = {
+ page: pageNumber,
+ domainName: globalDomainName
+ };
var config = {
headers : {
@@ -136,9 +141,9 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) {
$scope.emailLimitsLoading = true;
- if (response.data.listWebSiteStatus === 1) {
+ if (response.data.status === 1) {
- $scope.WebSitesList = JSON.parse(response.data.data);
+ $scope.emailList = JSON.parse(response.data.data);
$scope.listFail = true;
}
else
@@ -155,7 +160,7 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) {
};
- $scope.getFurtherWebsitesFromDB(1);
+ $scope.getFurtherEmailsFromDB(1);
$scope.enableDisableEmailLimits = function (operationVal, domainName) {
@@ -183,17 +188,770 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) {
if (response.data.status === 1) {
- $timeout(function() { $window.location.reload(); }, 3000);
+ $timeout(function() { $window.location.reload(); }, 0);
}
else
{
- $timeout(function() { $window.location.reload(); }, 3000);
+ $timeout(function() { $window.location.reload(); }, 0);
}
}
function cantLoadInitialData(response) {
- $timeout(function() { $window.location.reload(); }, 3000);
+ $timeout(function() { $window.location.reload(); }, 0);
}
+ };
+
+
+ /// Email limits
+
+ $scope.changeLimitsForm = true;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+
+ $scope.showLimitsForm = function () {
+ $scope.changeLimitsForm = false;
+ };
+
+ $scope.hideLimitsForm = function () {
+ $scope.changeLimitsForm = true;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+ };
+
+ $scope.changeDomainEmailLimits = function (domainName) {
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/changeDomainLimit";
+
+ var data = {
+ domainName: domainName,
+ newLimit: $scope.monthlyLimit
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+
+ if (response.data.status === 1) {
+
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = false;
+ $scope.couldNotConnect = true;
+ $timeout(function() { $window.location.reload(); }, 3000);
+ }
+ else
+ {
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = false;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = false;
+ }
}
+
+
+ $scope.enableDisableIndividualEmailLimits = function (operationVal, emailAddress) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableIndividualEmailLimits";
+
+ var data = {
+ operationVal: operationVal,
+ emailAddress: emailAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+ $scope.getFurtherEmailsFromDB(1);
+ }
+ else
+ {
+ $scope.getFurtherEmailsFromDB(1);
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.getFurtherEmailsFromDB(1);
+ }
+ };
+
});
-/* Java script code for email domain page */
\ No newline at end of file
+/* Java script code for email domain page */
+
+
+/* Java script code for Email Page */
+
+app.controller('emailPage', function($scope,$http, $timeout, $window) {
+
+ $scope.emailLimitsLoading = true;
+
+ var globalEamilAddress = $("#emailAddress").text();
+
+ // Global page number, to be used in later function to refresh the domains
+ var globalPageNumber;
+
+ $scope.getEmailStats = function() {
+
+ $scope.emailLimitsLoading = false;
+
+ ////
+
+ $scope.limitsOn = true;
+ $scope.limitsOff = true;
+
+ url = "/emailPremium/getEmailStats";
+
+ var data = {
+ emailAddress: globalEamilAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+
+ $scope.monthlyLimit = response.data.monthlyLimit;
+ $scope.monthlyUsed = response.data.monthlyUsed;
+ $scope.hourlyLimit = response.data.hourlyLimit;
+ $scope.hourlyUsed = response.data.hourlyUsed;
+
+ if(response.data.limitStatus === 1){
+ $scope.limitsOn = false;
+ $scope.limitsOff = true;
+ }else{
+ $scope.limitsOn = true;
+ $scope.limitsOff = false;
+ }
+
+ if(response.data.logsStatus === 1){
+ $scope.loggingOn = false;
+ $scope.loggingOff = true;
+ }else{
+ $scope.loggingOn = true;
+ $scope.loggingOff = false;
+ }
+
+ }
+ else
+ {
+
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+
+
+ };
+ $scope.getEmailStats();
+
+ $scope.enableDisableIndividualEmailLimits = function (operationVal, emailAddress) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableIndividualEmailLimits";
+
+ var data = {
+ operationVal: operationVal,
+ emailAddress: emailAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+ $scope.getEmailStats();
+ }
+ else
+ {
+ $scope.getEmailStats();
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.getEmailStats();
+ }
+ };
+ $scope.enableDisableIndividualEmailLogs = function (operationVal, emailAddress) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableIndividualEmailLogs";
+
+ var data = {
+ operationVal: operationVal,
+ emailAddress: emailAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+ $scope.getEmailStats();
+ }
+ else
+ {
+ $scope.getEmailStats();
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.getEmailStats();
+ }
+ };
+
+
+ $scope.enableDisableEmailLimits = function (operationVal, domainName) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableEmailLimits";
+
+ var data = {
+ operationVal: operationVal,
+ domainName: domainName
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+
+ $timeout(function() { $window.location.reload(); }, 0);
+ }
+ else
+ {
+ $timeout(function() { $window.location.reload(); }, 0);
+ }
+ }
+ function cantLoadInitialData(response) {
+ $timeout(function() { $window.location.reload(); }, 0);
+ }
+ };
+
+
+ /// Email limits
+ $scope.changeLimitsForm = true;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+
+ $scope.showLimitsForm = function () {
+ $scope.changeLimitsForm = false;
+ };
+
+ $scope.hideLimitsForm = function () {
+ $scope.changeLimitsForm = true;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+ };
+
+ $scope.changeDomainEmailLimitsIndividual = function () {
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/changeDomainEmailLimitsIndividual";
+
+ var data = {
+ emailAddress: globalEamilAddress,
+ monthlyLimit: $scope.monthlyLimitForm,
+ hourlyLimit: $scope.hourlyLimitForm
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+
+ if (response.data.status === 1) {
+
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = false;
+ $scope.couldNotConnect = true;
+ $scope.getEmailStats();
+
+ }
+ else
+ {
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = false;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = false;
+ }
+ };
+
+ /// Get email logs
+
+ $scope.getLogEntries = function(pageNumber) {
+
+ globalPageNumber = pageNumber;
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/getEmailLogs";
+
+ var data = {
+ page: pageNumber,
+ emailAddress: globalEamilAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+
+ $scope.logs = JSON.parse(response.data.data);
+ $scope.listFail = true;
+ }
+ else
+ {
+ $scope.listFail = false;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+
+
+ };
+ $scope.getLogEntries(1);
+
+
+ $scope.flushLogs = function(emailAddress) {
+
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/flushEmailLogs";
+
+ var data = {
+ emailAddress: emailAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+ $scope.getLogEntries(1);
+
+ }
+ else
+ {
+ $scope.listFail = false;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+
+
+ };
+
+});
+
+/* Java script code for Email Page */
+
+
+/* Java script code for SpamAssassin */
+
+app.controller('SpamAssassin', function($scope, $http, $timeout, $window) {
+
+ $scope.SpamAssassinNotifyBox = true;
+ $scope.SpamAssassinInstallBox = true;
+ $scope.SpamAssassinLoading = true;
+ $scope.failedToStartInallation = true;
+ $scope.couldNotConnect = true;
+ $scope.SpamAssassinSuccessfullyInstalled = true;
+ $scope.installationFailed = true;
+
+
+
+ $scope.installSpamAssassin = function(){
+
+ $scope.SpamAssassinNotifyBox = true;
+ $scope.SpamAssassinInstallBox = true;
+ $scope.SpamAssassinLoading = false;
+ $scope.failedToStartInallation = true;
+ $scope.couldNotConnect = true;
+ $scope.SpamAssassinSuccessfullyInstalled = true;
+ $scope.installationFailed = true;
+
+ url = "/emailPremium/installSpamAssassin";
+
+ var data = {};
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+
+
+ $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
+
+
+ function ListInitialDatas(response) {
+
+
+ if(response.data.status === 1){
+
+ $scope.SpamAssassinNotifyBox = true;
+ $scope.SpamAssassinInstallBox = false;
+ $scope.SpamAssassinLoading = false;
+ $scope.failedToStartInallation = true;
+ $scope.couldNotConnect = true;
+ $scope.SpamAssassinSuccessfullyInstalled = true;
+ $scope.installationFailed = true;
+
+ getRequestStatus();
+
+ }
+ else{
+ $scope.errorMessage = response.data.error_message;
+
+ $scope.SpamAssassinNotifyBox = false;
+ $scope.SpamAssassinInstallBox = true;
+ $scope.SpamAssassinLoading = true;
+ $scope.failedToStartInallation = false;
+ $scope.couldNotConnect = true;
+ $scope.SpamAssassinSuccessfullyInstalled = true;
+ }
+
+ }
+ function cantLoadInitialDatas(response) {
+
+ $scope.SpamAssassinNotifyBox = false;
+ $scope.SpamAssassinInstallBox = false;
+ $scope.SpamAssassinLoading = true;
+ $scope.failedToStartInallation = true;
+ $scope.couldNotConnect = false;
+ $scope.SpamAssassinSuccessfullyInstalled = true;
+ $scope.installationFailed = true;
+ }
+
+ };
+
+ function getRequestStatus(){
+
+ $scope.SpamAssassinNotifyBox = true;
+ $scope.SpamAssassinInstallBox = false;
+ $scope.SpamAssassinLoading = false;
+ $scope.failedToStartInallation = true;
+ $scope.couldNotConnect = true;
+ $scope.SpamAssassinSuccessfullyInstalled = true;
+ $scope.installationFailed = true;
+
+ url = "/emailPremium/installStatusSpamAssassin";
+
+ var data = {};
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+
+
+ $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
+
+
+ function ListInitialDatas(response) {
+
+
+ if(response.data.abort === 0){
+
+ $scope.SpamAssassinNotifyBox = true;
+ $scope.SpamAssassinInstallBox = false;
+ $scope.SpamAssassinLoading = false;
+ $scope.failedToStartInallation = true;
+ $scope.couldNotConnect = true;
+ $scope.SpamAssassinSuccessfullyInstalled = true;
+ $scope.installationFailed = true;
+
+ $scope.requestData = response.data.requestStatus;
+ $timeout(getRequestStatus,1000);
+ }
+ else{
+ // Notifications
+ $timeout.cancel();
+ $scope.SpamAssassinNotifyBox = false;
+ $scope.SpamAssassinInstallBox = false;
+ $scope.SpamAssassinLoading = true;
+ $scope.failedToStartInallation = true;
+ $scope.couldNotConnect = true;
+
+ $scope.requestData = response.data.requestStatus;
+
+ if(response.data.installed === 0) {
+ $scope.installationFailed = false;
+ $scope.errorMessage = response.data.error_message;
+ }else{
+ $scope.SpamAssassinSuccessfullyInstalled = false;
+ $timeout(function() { $window.location.reload(); }, 3000);
+ }
+
+ }
+
+ }
+ function cantLoadInitialDatas(response) {
+
+ $scope.SpamAssassinNotifyBox = false;
+ $scope.SpamAssassinInstallBox = false;
+ $scope.SpamAssassinLoading = true;
+ $scope.failedToStartInallation = true;
+ $scope.couldNotConnect = false;
+ $scope.SpamAssassinSuccessfullyInstalled = true;
+ $scope.installationFailed = true;
+
+
+ }
+
+ }
+
+ ///// SpamAssassin configs
+
+ var report_safe = false;
+
+
+ $('#report_safe').change(function() {
+ report_safe = $(this).prop('checked');
+ });
+
+ fetchSpamAssassinSettings();
+ function fetchSpamAssassinSettings(){
+
+ $scope.SpamAssassinLoading = false;
+
+ $('#report_safe').bootstrapToggle('off');
+
+ url = "/emailPremium/fetchSpamAssassinSettings";
+
+ var data = {};
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+
+
+ $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
+
+
+ function ListInitialDatas(response) {
+
+ $scope.SpamAssassinLoading = true;
+
+ if(response.data.fetchStatus === 1){
+
+ if(response.data.installed === 1) {
+
+ if (response.data.report_safe === 1) {
+ $('#report_safe').bootstrapToggle('on');
+ }
+
+ $scope.required_hits = response.data.required_hits;
+ $scope.rewrite_header = response.data.rewrite_header;
+ $scope.required_score = response.data.required_score;
+
+ }
+
+ }
+
+ }
+ function cantLoadInitialDatas(response) {
+ $scope.SpamAssassinLoading = true;
+ }
+
+ }
+
+
+ /////
+
+ /// Save SpamAssassin Changes
+
+ $scope.failedToSave = true;
+ $scope.successfullySaved = true;
+
+ $scope.saveSpamAssassinConfigurations = function () {
+
+ $scope.failedToSave = true;
+ $scope.successfullySaved = true;
+ $scope.SpamAssassinLoading = false;
+ $scope.couldNotConnect = true;
+
+
+ url = "/emailPremium/saveSpamAssassinConfigurations";
+
+ var data = {
+ report_safe:report_safe,
+ required_hits:$scope.required_hits,
+ rewrite_header:$scope.rewrite_header,
+ required_score:$scope.required_score
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+
+
+ $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
+
+
+ function ListInitialDatas(response) {
+
+
+ if(response.data.saveStatus === 1){
+
+ $scope.failedToSave = true;
+ $scope.successfullySaved = false;
+ $scope.SpamAssassinLoading = true;
+ $scope.couldNotConnect = true;
+
+ }
+ else{
+ $scope.errorMessage = response.data.error_message;
+
+ $scope.failedToSave = false;
+ $scope.successfullySaved = true;
+ $scope.SpamAssassinLoading = true;
+ $scope.couldNotConnect = true;
+ }
+
+ }
+ function cantLoadInitialDatas(response) {
+ $scope.failedToSave = true;
+ $scope.successfullySaved = false;
+ $scope.SpamAssassinLoading = true;
+ $scope.couldNotConnect = true;
+ }
+
+
+ };
+
+});
\ No newline at end of file