Monotone-Parent: 0869cb2e3bedff16fb0985d9bde1c2c2a5c80820

Monotone-Revision: ac0d12f89b420e5f1e825cebddb440417e76ce4b

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2012-04-20T13:37:46
This commit is contained in:
Wolfgang Sourdeau
2012-04-20 13:37:46 +00:00
parent f306ab6a71
commit 2346d35d21
10 changed files with 134 additions and 4 deletions

View File

@@ -1,5 +1,24 @@
2012-04-20 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/WebServerResources/UIxPreferences.js (displayMailAccount):
disable the "fullName" and "email" input fields of the first
account only when SOGoMailCustomFromEnabled is NO.
* UI/PreferencesUI/UIxPreferences.m (_extractMainIdentity:): the
custom values for "fullName" and "email" are now registered in the
user defaults, if "email" is different from all the values
returned by the user directory AND if SOGoMailCustomFromEnabled is
YES.
* SoObjects/SOGo/SOGoUserDefaults.m (-setMailCustomFullName:)
(-mailCustomFullName): new accessors for the new
"SOGoMailCustomFullName" user default.
(-setMailCustomEmail:, -mailCustomEmail): new accessors for the
new "SOGoMailCustomEmail" user default.
* SoObjects/SOGo/SOGoDomainDefaults.m (-mailCustomFromEnabled):
new getter for the "SOGoMailCustomFromEnabled" domain default.
* SoObjects/Mailer/SOGoDraftObject.m
(-mimeHeaderMapWithHeaders:excluding:) take the new "replyTo"
header into account.
@@ -7,6 +26,10 @@
* SoObjects/SOGo/SOGoUser.m (-_appendSystemMailAccount): specify
the value of "SOGoMailReplyTo" in the "replyTo" field of each
identity, if present.
When "SOGoMailCustomFromEnabled" is YES and the user has set
a value for "SOGoMailCustomEmail", a first identity is created and
set at the first position in the list, based on that value and on
"SOGoMailCustomFullName".
* SoObjects/SOGo/SOGoUserDefaults.m (-setMailReplyTo:)
(-mailReplyTo:): accessors for the "SOGoMailReplyTo" user default.

View File

@@ -37,6 +37,7 @@
- (NSArray *) userSources;
- (BOOL) mailCustomFromEnabled;
- (BOOL) mailAuxiliaryUserAccountsEnabled;
- (NSString *) mailDomain;

View File

@@ -98,6 +98,11 @@
return [self stringForKey: @"OCSFolderInfoURL"];
}
- (BOOL) mailCustomFromEnabled
{
return [self boolForKey: @"SOGoMailCustomFromEnabled"];
}
- (BOOL) mailAuxiliaryUserAccountsEnabled
{
return [self boolForKey: @"SOGoMailAuxiliaryUserAccountsEnabled"];

View File

@@ -577,7 +577,7 @@
- (void) _appendSystemMailAccount
{
NSString *fullName, *replyTo, *imapLogin, *imapServer, *signature,
*encryption, *scheme, *action, *query;
*encryption, *scheme, *action, *query, *customValue;
NSMutableDictionary *mailAccount, *identity, *mailboxes, *receipts;
NSNumber *port;
NSMutableArray *identities;
@@ -647,6 +647,37 @@
max = [mails count];
if (max > 1)
max--;
/* custom from */
if ([[self domainDefaults] mailCustomFromEnabled])
{
[self userDefaults];
customValue = [_defaults mailCustomEmail];
if ([customValue length] > 0)
{
identity = [NSMutableDictionary new];
[identity setObject: customValue forKey: @"email"];
fullName = [_defaults mailCustomFullName];
if (![fullName length])
{
fullName = [self cn];
if (![fullName length])
fullName = login;
}
[identity setObject: fullName forKey: @"fullName"];
if ([replyTo length] > 0)
[identity setObject: replyTo forKey: @"replyTo"];
signature = [_defaults mailSignature];
if (signature)
[identity setObject: signature forKey: @"signature"];
[identities addObject: identity];
[identity release];
}
}
for (count = 0; count < max; count++)
{
identity = [NSMutableDictionary new];
@@ -749,7 +780,7 @@
NSArray *identities;
identities = [[self mailAccounts] objectsForKey: @"identities"
notFoundMarker: nil];
notFoundMarker: nil];
return [identities flattenedArray];
}

View File

@@ -130,6 +130,12 @@ extern NSString *SOGoWeekStartFirstFullWeek;
- (void) setMailSignaturePlacement: (NSString *) newValue;
- (NSString *) mailSignaturePlacement;
- (void) setMailCustomFullName: (NSString *) newValue;
- (NSString *) mailCustomFullName;
- (void) setMailCustomEmail: (NSString *) newValue;
- (NSString *) mailCustomEmail;
- (void) setMailReplyTo: (NSString *) newValue;
- (NSString *) mailReplyTo;

View File

@@ -504,6 +504,8 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
- (void) setMailSignature: (NSString *) newValue
{
if ([newValue length] == 0)
newValue = nil;
[self setObject: newValue forKey: @"SOGoMailSignature"];
}
@@ -531,6 +533,30 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
return signaturePlacement;
}
- (void) setMailCustomFullName: (NSString *) newValue
{
if ([newValue length] == 0)
newValue = nil;
[self setObject: newValue forKey: @"SOGoMailCustomFullName"];
}
- (NSString *) mailCustomFullName
{
return [self stringForKey: @"SOGoMailCustomFullName"];
}
- (void) setMailCustomEmail: (NSString *) newValue
{
if ([newValue length] == 0)
newValue = nil;
[self setObject: newValue forKey: @"SOGoMailCustomEmail"];
}
- (NSString *) mailCustomEmail
{
return [self stringForKey: @"SOGoMailCustomEmail"];
}
- (void) setMailReplyTo: (NSString *) newValue
{
if ([newValue length] == 0)

View File

@@ -45,6 +45,7 @@
NSArray *daysOfWeek, *daysBetweenResponsesList;
NSArray *sieveFilters;
NSMutableDictionary *vacationOptions, *forwardOptions;
BOOL mailCustomFromEnabled;
BOOL hasChanged;
}

View File

@@ -106,6 +106,8 @@
forwardOptions = [NSMutableDictionary new];
}
mailCustomFromEnabled = [dd mailCustomFromEnabled];
hasChanged = NO;
}
@@ -1285,6 +1287,29 @@
if (!value)
value = @"";
[userDefaults setMailSignature: value];
if (mailCustomFromEnabled)
{
value = [[identity objectForKey: @"email"]
stringByTrimmingSpaces];
/* We make sure that the "custom" value is different from the values
returned by the user directory service. */
if ([value length] == 0
|| [[user allEmails] containsObject: value])
{
[userDefaults setMailCustomEmail: nil];
[userDefaults setMailCustomFullName: nil];
}
else
{
[userDefaults setMailCustomEmail: value];
value = [[identity objectForKey: @"fullName"]
stringByTrimmingSpaces];
[userDefaults setMailCustomFullName: value];
}
}
value = [[identity objectForKey: @"replyTo"]
stringByTrimmingSpaces];
[userDefaults setMailReplyTo: value];
@@ -1528,4 +1553,9 @@
return [accounts jsonRepresentation];
}
- (NSString *) mailCustomFromEnabled
{
return (mailCustomFromEnabled ? @"true" : @"false");
}
@end

View File

@@ -318,6 +318,11 @@
<input const:name="encryption" type="hidden" const:value="none"/>
</fieldset>
<script type="text/javascript">
var mailCustomFromEnabled = <var:string value="mailCustomFromEnabled" const:escapeHTML="NO"/>;
</script>
<fieldset const:id="identityInfo">
<label><var:string label:value="Full Name:"/>
<input const:name="fullName" const:id="fullName" type="text" const:value=""

View File

@@ -664,8 +664,10 @@ function displayMailAccount(mailAccount, readOnly) {
fieldSet = $("identityInfo");
inputs = $(fieldSet.getElementsByTagName("input"));
inputs.each(function (i) { i.mailAccount = mailAccount; });
for (var i = 0; i < 2; i++) {
inputs[i].disabled = readOnly;
if (!mailCustomFromEnabled) {
for (var i = 0; i < 2; i++) {
inputs[i].disabled = readOnly;
}
}
var form = $("mainForm");