now possible to limit automatic forwards to internal/external domains

This commit is contained in:
Ludovic Marcotte
2015-02-11 14:30:40 -05:00
parent 55ae4cb8c0
commit 322f72626a
7 changed files with 64 additions and 3 deletions
+10 -1
View File
@@ -1,6 +1,6 @@
/* UIxPreferences.m - this file is part of SOGo
*
* Copyright (C) 2007-2014 Inverse inc.
* Copyright (C) 2007-2015 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1238,6 +1238,15 @@ static NSArray *reminderValues = nil;
return [[forwardOptions objectForKey: @"keepCopy"] boolValue];
}
- (NSString *) forwardConstraints
{
SOGoDomainDefaults *dd;
dd = [[context activeUser] domainDefaults];
return [NSString stringWithFormat: @"%d", [dd forwardConstraints]];
}
/* main */
- (NSArray *) availableModules
@@ -654,6 +654,10 @@
const:id="forwardKeepCopy"
var:checked="forwardKeepCopy" />
<var:string label:value="Keep a copy" /></label><br/>
<input type="hidden"
const:id="forwardConstraints"
var:value="forwardConstraints" />
</div>
</div>
</var:if>
+31
View File
@@ -70,11 +70,42 @@ function savePreferences(sender) {
if ($("enableForward") && $("enableForward").checked) {
var addresses = $("forwardAddress").value.split(",");
// We check if all addresses are valid
for (var i = 0; i < addresses.length && sendForm; i++)
if (!emailRE.test(addresses[i].strip())) {
showAlertDialog(_("Please specify an address to which you want to forward your messages."));
sendForm = false;
}
// We check if we can only to internal/external addresses.
var constraints = parseInt($("forwardConstraints").value);
if (constraints > 0) {
// We first extract the list of 'known domains' to SOGo
var defaultAddresses = $("defaultEmailAddresses").value.split(/, */);
var domains = new Array();
defaultAddresses.each(function(adr) {
var domain = adr.split("@")[1];
if (domain) {
domains.push(domain.toLowerCase());
}
});
// We check if we're allowed or not to forward based on the domain defaults
for (var i = 0; i < addresses.length && sendForm; i++) {
var domain = addresses[i].split("@")[1].toLowerCase();
if (domains.indexOf(domain) < 0 && constraints == 1) {
showAlertDialog(_("You are not allowed to forward your messages to an external email address."));
sendForm = false;
}
else if (domains.indexOf(domain) >= 0 && constraints == 2) {
showAlertDialog(_("You are not allowed to forward your messages to an internal email address."));
sendForm = false;
}
}
}
}
if (typeof sieveCapabilities != "undefined") {