Allow disabling Gravatar

Resolves #3600
This commit is contained in:
Francis Lachapelle
2016-05-25 16:04:58 -04:00
parent 9fc22f2689
commit a9ee261eff
12 changed files with 100 additions and 35 deletions
+33 -20
View File
@@ -686,7 +686,7 @@ static NSArray *reminderValues = nil;
// SOGoUserSettings *us;
// NSMutableDictionary *moduleSettings;
// NSArray *whiteList;
// us = [user userSettings];
// moduleSettings = [us objectForKey: @"Calendar"];
// whiteList = [moduleSettings objectForKey:@"PreventInvitationsWhitelist"];
@@ -697,7 +697,7 @@ static NSArray *reminderValues = nil;
// {
// SOGoUserSettings *us;
// NSMutableDictionary *moduleSettings;
// us = [user userSettings];
// moduleSettings = [us objectForKey: @"Calendar"];
// [moduleSettings setObject: whiteListString forKey: @"PreventInvitationsWhitelist"];
@@ -890,7 +890,7 @@ static NSArray *reminderValues = nil;
value = @"every_minute";
else if (interval == 60)
value = @"once_per_hour";
else if (interval == 2 || interval == 5 || interval == 10
else if (interval == 2 || interval == 5 || interval == 10
|| interval == 20 || interval == 30)
value = [NSString stringWithFormat: @"every_%d_minutes", interval];
else
@@ -1417,6 +1417,11 @@ static NSArray *reminderValues = nil;
return [self labelForKey: item];
}
- (BOOL) externalAvatarsEnabled
{
return [[user domainDefaults] externalAvatarsEnabled];
}
- (NSArray *) alternateAvatar
{
// See: https://en.gravatar.com/site/implement/images/
@@ -1795,7 +1800,7 @@ static NSArray *reminderValues = nil;
//
- (void) _extractMainIdentity: (NSDictionary *) identity
inDictionary: (NSMutableDictionary *) target
{
/* We perform some validation here as we have no guaranty on the input
validity. */
@@ -1825,7 +1830,7 @@ static NSArray *reminderValues = nil;
[target setObject: value forKey: @"SOGoMailCustomEmail"];
else
[target removeObjectForKey: @"SOGoMailCustomEmail"];
value = [[identity objectForKey: @"fullName"]
stringByTrimmingSpaces];
if ([value length] == 0
@@ -1878,11 +1883,11 @@ static NSArray *reminderValues = nil;
action = [receipts objectForKey: @"receiptNonRecipientAction"];
if ([self _validateReceiptAction: action])
[target setObject: action forKey: @"SOGoMailReceiptNonRecipientAction"];
action = [receipts objectForKey: @"receiptOutsideDomainAction"];
if ([self _validateReceiptAction: action])
[target setObject: action forKey: @"SOGoMailReceiptOutsideDomainAction"];
action = [receipts objectForKey: @"receiptAnyAction"];
if ([self _validateReceiptAction: action])
[target setObject: action forKey: @"SOGoMailReceiptAnyAction"];
@@ -2128,10 +2133,10 @@ static NSArray *reminderValues = nil;
{
id <WOActionResults> results;
id o, v;
o = [[[context request] contentAsString] objectFromJSONString];
results = nil;
// Proceed with data sanitization of the "defaults"
if ((v = [o objectForKey: @"defaults"]))
{
@@ -2156,7 +2161,15 @@ static NSArray *reminderValues = nil;
if ([[v objectForKey: @"SOGoLongDateFormat"] isEqualToString: @"default"])
[v removeObjectForKey: @"SOGoLongDateFormat"];
if (![self externalAvatarsEnabled])
{
[v removeObjectForKey: @"SOGoGravatarEnabled"];
[[[user userDefaults] source] removeObjectForKey: @"SOGoGravatarEnabled"];
[v removeObjectForKey: @"SOGoAlternateAvatar"];
[[[user userDefaults] source] removeObjectForKey: @"SOGoAlternateAvatar"];
}
//
// We sanitize mail labels
//
@@ -2166,20 +2179,20 @@ static NSArray *reminderValues = nil;
// We encode correctly our keys
sanitizedLabels = [NSMutableDictionary dictionary];
allKeys = [newLabels allKeys];
for (i = 0; i < [allKeys count]; i++)
{
name = [allKeys objectAtIndex: i];
if (![name is7bitSafe])
name = [name stringByEncodingImap4FolderName];
name = [name lowercaseString];
[sanitizedLabels setObject: [newLabels objectForKey: [allKeys objectAtIndex: i]]
forKey: name];
}
[v setObject: sanitizedLabels forKey: @"SOGoMailLabelsColors"];
}
@@ -2202,23 +2215,23 @@ static NSArray *reminderValues = nil;
}
[[[user userDefaults] source] setValues: v];
if ([[user userDefaults] synchronize])
{
SOGoMailAccount *account;
SOGoMailAccounts *folder;
SOGoDomainDefaults *dd;
dd = [[context activeUser] domainDefaults];
// We check if the Sieve server is available *ONLY* if at least one of the option is enabled
if (!([dd sieveScriptsEnabled] || [dd vacationEnabled] || [dd forwardEnabled]) || [self _isSieveServerAvailable])
{
folder = [[[context activeUser] homeFolderInContext: context] mailAccountsFolder: @"Mail"
inContext: context];
account = [folder lookupName: @"0" inContext: context acquire: NO];
if (![account updateFilters])
{
results = (id <WOActionResults>) [self responseWithStatus: 502
@@ -2230,7 +2243,7 @@ static NSArray *reminderValues = nil;
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Service temporarily unavailable", @"message", nil]];
}
}
if ((v = [o objectForKey: @"settings"]))
{
[[[user userSettings] source] setValues: v];