now possible to limit automatic forwards to internal/external domains

pull/70/head
Ludovic Marcotte 2015-02-11 14:30:40 -05:00
parent 55ae4cb8c0
commit 322f72626a
7 changed files with 64 additions and 3 deletions

View File

@ -1792,6 +1792,12 @@ host.
Defaults to `NO` when unset.
|D |SOGoForwardConstraints
|Parameter used to set constraints on possible addresses used when
automatically forwarding mails. When set to `0` (default), no constraint
is enforced. When set to `1`, only internal domains can be used. When
set to `2`, only external domains can be used.
|D |SOGoSieveScriptsEnabled
|Parameter used to activate the edition from the preferences windows of
server-side mail filters. Requires Sieve script support on the IMAP

1
NEWS
View File

@ -3,6 +3,7 @@
New features
- now possible for SOGo to change the sambaNTPassword/sambaLMPassword
- now possible to limit automatic forwards to internal/external domains
Enhancements
- added support for email categories using EAS (#2995)

View File

@ -1,6 +1,6 @@
/* SOGoDomainDefaults.h - this file is part of SOGo
*
* Copyright (C) 2009-2014 Inverse inc.
* Copyright (C) 2009-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
@ -49,6 +49,7 @@
- (BOOL) forceExternalLoginWithEmail;
- (BOOL) sieveScriptsEnabled;
- (BOOL) forwardEnabled;
- (int) forwardConstraints;
- (BOOL) vacationEnabled;
- (NSString *) mailingMechanism;
- (NSString *) smtpServer;

View File

@ -1,6 +1,6 @@
/* SOGoDomainDefaults.m - this file is part of SOGo
*
* Copyright (C) 2009-2014 Inverse inc.
* Copyright (C) 2009-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
@ -201,6 +201,15 @@
return [self boolForKey: @"SOGoForwardEnabled"];
}
- (int) forwardConstraints
{
unsigned int v;
v = [self integerForKey: @"SOGoForwardConstraints"];
return (v > 2 ? 0 : v);
}
- (BOOL) vacationEnabled
{
return [self boolForKey: @"SOGoVacationEnabled"];

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

View File

@ -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>

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") {