(fix) fixed default values for many prefs

pull/91/head
Ludovic Marcotte 2015-04-10 09:44:30 -04:00 committed by Francis Lachapelle
parent e8acb225e4
commit d581054214
9 changed files with 138 additions and 40 deletions

View File

@ -51,6 +51,8 @@
SOGoTimeFormat = "%H:%M";
SOGoFirstDayOfWeek = 0;
SOGoFirstWeekOfYear = "January1";
SOGoShortDateFormat = "default";
SOGoLongDateFormat = "default";
SOGoIMAPServer = "localhost";
SOGoMailDomain = "localhost";
@ -67,6 +69,8 @@
SOGoSentFolderName = "Sent";
SOGoDraftsFolderName = "Drafts";
SOGoTrashFolderName = "Trash";
SOGoMailComposeMessageType = "html";
SOGoMailDisplayRemoteInlineImages = "never";
SOGoMailAutoSave = "5";
@ -74,9 +78,11 @@
SOGoCalendarEventsDefaultClassification = "PUBLIC";
SOGoCalendarTasksDefaultClassification = "PUBLIC";
SOGoCalendarDefaultReminder = "NONE";
SOGoDefaultCalendar = "selected";
SOGoFreeBusyDefaultInterval = ( 7, 7 );
SOGoSelectedAddressBook = "personal";
SOGoSearchMinimumWordLength = 2;
SOGoMailLabelsColors = {

View File

@ -1,6 +1,5 @@
/*
Copyright (C) 2008-2009 Inverse inc.
Copyright (C) 2005 SKYRIX Software AG
Copyright (C) 2008-2015 Inverse inc.
This file is part of SOGo.
@ -81,6 +80,7 @@ typedef enum _SOGoUserProfileType {
/* saving changes */
- (BOOL) dirty;
- (BOOL) synchronize;
@end

View File

@ -1,6 +1,5 @@
/*
Copyright (C) 2008-2009 Inverse inc.
Copyright (C) 2005 SKYRIX Software AG
Copyright (C) 2008-2015 Inverse inc.
This file is part of SOGo.
@ -323,6 +322,10 @@
}
/* saving changes */
- (BOOL) dirty
{
return defFlags.modified;
}
- (BOOL) synchronize
{

View File

@ -1,8 +1,6 @@
/* WODirectAction+SOGo.h - this file is part of SOGo
*
* Copyright (C) 2007 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* 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

View File

@ -1,8 +1,6 @@
/* WODirectAction+SOGo.m - this file is part of SOGo
*
* Copyright (C) 2007-2012 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* 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

View File

@ -20,6 +20,7 @@
#import <Foundation/NSDictionary.h>
#import <NGObjWeb/SoObjects.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <NGObjWeb/WODirectAction.h>
#import <NGObjWeb/WOResponse.h>
@ -37,6 +38,8 @@
#import "UIxJSONPreferences.h"
static SoProduct *preferencesProduct = nil;
@implementation UIxJSONPreferences
- (WOResponse *) _makeResponse: (NSDictionary *) values
@ -55,39 +58,87 @@
{
NSMutableDictionary *values;
SOGoUserDefaults *defaults;
NSMutableArray *accounts;
NSArray *categoryLabels;
BOOL dirty;
defaults = [[context activeUser] userDefaults];
dirty = NO;
if (!preferencesProduct)
{
preferencesProduct = [[SoProduct alloc] initWithBundle:
[NSBundle bundleForClass: NSClassFromString(@"PreferencesUIProduct")]];
}
defaults = [[context activeUser] userDefaults];
//
// Default General preferences
//
if (![[defaults source] objectForKey: @"SOGoLanguage"])
[[defaults source] setObject: [defaults language] forKey: @"SOGoLanguage"];
if (![[defaults source] objectForKey: @"SOGoTimeZone"])
[[defaults source] setObject: [defaults timeZoneName] forKey: @"SOGoTimeZone"];
if (![[defaults source] objectForKey: @"SOGoShortDateFormat"])
[[defaults source] setObject: @"default" forKey: @"SOGoShortDateFormat"];
[[defaults source] setObject: [defaults shortDateFormat] forKey: @"SOGoShortDateFormat"];
if (![[defaults source] objectForKey: @"SOGoLongDateFormat"])
[[defaults source] setObject: @"default" forKey: @"SOGoLongDateFormat"];
[[defaults source] setObject: [defaults longDateFormat] forKey: @"SOGoLongDateFormat"];
if (![[defaults source] objectForKey: @"SOGoTimeFormat"])
[[defaults source] setObject: [defaults timeFormat] forKey: @"SOGoTimeFormat"];
if (![[defaults source] objectForKey: @"SOGoLoginModule"])
[[defaults source] setObject: [defaults loginModule] forKey: @"SOGoLoginModule"];
if (![[defaults source] objectForKey: @"SOGoRefreshViewCheck"])
[[defaults source] setObject: [defaults refreshViewCheck] forKey: @"SOGoRefreshViewCheck"];
//
// Default Calendar preferences
//
if (![[defaults source] objectForKey: @"SOGoFirstDayOfWeek"])
[[defaults source] setObject: [NSNumber numberWithInt: [defaults firstDayOfWeek]] forKey: @"SOGoFirstDayOfWeek"];
if (![[defaults source] objectForKey: @"SOGoDayStartTime"])
[[defaults source] setObject: [NSString stringWithFormat: @"%02d:00", [defaults dayStartHour]] forKey: @"SOGoDayStartTime"];
if (![[defaults source] objectForKey: @"SOGoDayEndTime"])
[[defaults source] setObject: [NSString stringWithFormat: @"%02d:00", [defaults dayEndHour]] forKey: @"SOGoDayEndTime"];
if (![[defaults source] objectForKey: @"SOGoFirstWeekOfYear"])
[[defaults source] setObject: [defaults firstWeekOfYear] forKey: @"SOGoFirstWeekOfYear"];
if (![[defaults source] objectForKey: @"SOGoDefaultCalendar"])
[[defaults source] setObject: [defaults defaultCalendar] forKey: @"SOGoDefaultCalendar"];
if (![[defaults source] objectForKey: @"SOGoCalendarEventsDefaultClassification"])
[[defaults source] setObject: [defaults calendarEventsDefaultClassification] forKey: @"SOGoCalendarEventsDefaultClassification"];
if (![[defaults source] objectForKey: @"SOGoSelectedAddressBook"])
[[defaults source] setObject: @"personal" forKey: @"SOGoSelectedAddressBook"];
if (![[defaults source] objectForKey: @"SOGoCalendarTasksDefaultClassification"])
[[defaults source] setObject: [defaults calendarTasksDefaultClassification] forKey: @"SOGoCalendarTasksDefaultClassification"];
if (![[defaults source] objectForKey: @"SOGoCalendarDefaultReminder"])
[[defaults source] setObject: [defaults calendarDefaultReminder] forKey: @"SOGoCalendarDefaultReminder"];
// Populate default calendar categories, based on the user's preferred language
if (![defaults calendarCategories])
{
categoryLabels = [[[self labelForKey: @"calendar_category_labels"]
categoryLabels = [[[self labelForKey: @"calendar_category_labels" withResourceManager: [preferencesProduct resourceManager]]
componentsSeparatedByString: @","]
sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
[defaults setCalendarCategories: categoryLabels];
dirty = YES;
}
//
// Default Contacts preferences
//
// Populate default contact categories, based on the user's preferred language
//
if (![defaults contactsCategories])
{
categoryLabels = [[[self labelForKey: @"contacts_category_labels"]
categoryLabels = [[[self labelForKey: @"contacts_category_labels" withResourceManager: [preferencesProduct resourceManager]]
componentsSeparatedByString: @","]
sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
@ -95,8 +146,28 @@
categoryLabels = [NSArray array];
[defaults setContactsCategories: categoryLabels];
dirty = YES;
}
//
// Default Mail preferences
//
if (![[defaults source] objectForKey: @"SOGoSelectedAddressBook"])
[[defaults source] setObject: [defaults selectedAddressBook] forKey: @"SOGoSelectedAddressBook"];
if (![[defaults source] objectForKey: @"SOGoMailMessageForwarding"])
[[defaults source] setObject: [defaults mailMessageForwarding] forKey: @"SOGoMailMessageForwarding"];
if (![[defaults source] objectForKey: @"SOGoMailReplyPlacement"])
[[defaults source] setObject: [defaults mailReplyPlacement] forKey: @"SOGoMailReplyPlacement"];
if (![[defaults source] objectForKey: @"SOGoMailSignaturePlacement"])
[[defaults source] setObject: [defaults mailSignaturePlacement] forKey: @"SOGoMailSignaturePlacement"];
if (![[defaults source] objectForKey: @"SOGoMailComposeMessageType"])
[[defaults source] setObject: [defaults mailComposeMessageType] forKey: @"SOGoMailComposeMessageType"];
if (![[defaults source] objectForKey: @"SOGoMailDisplayRemoteInlineImages"])
[[defaults source] setObject: [defaults mailDisplayRemoteInlineImages] forKey: @"SOGoMailDisplayRemoteInlineImages"];
// Populate default mail lablels, based on the user's preferred language
if (![[defaults source] objectForKey: @"SOGoMailLabelsColors"])
@ -119,17 +190,19 @@
}
[defaults setMailLabelsColors: v];
dirty = YES;
}
if (dirty)
if ([[defaults source] dirty])
[defaults synchronize];
// We inject our default mail account, something we don't want to do before we
// call -synchronize on our defaults.
values = [[[[defaults source] values] mutableCopy] autorelease];
[[values objectForKey: @"AuxiliaryMailAccounts"] insertObject: [[[context activeUser] mailAccounts] objectAtIndex: 0]
atIndex: 0];
accounts = [NSMutableArray arrayWithArray: [values objectForKey: @"AuxiliaryMailAccounts"]];
[accounts insertObject: [[[context activeUser] mailAccounts] objectAtIndex: 0]
atIndex: 0];
[values setObject: accounts forKey: @"AuxiliaryMailAccounts"];
return [self _makeResponse: values];
}

View File

@ -67,7 +67,8 @@ static NSArray *reminderValues = nil;
if (!reminderItems && !reminderValues)
{
reminderItems = [NSArray arrayWithObjects:
@"5_MINUTES_BEFORE",
@"NONE",
@"5_MINUTES_BEFORE",
@"10_MINUTES_BEFORE",
@"15_MINUTES_BEFORE",
@"30_MINUTES_BEFORE",
@ -83,7 +84,8 @@ static NSArray *reminderValues = nil;
@"1_WEEK_BEFORE",
nil];
reminderValues = [NSArray arrayWithObjects:
@"-PT5M",
@"NONE",
@"-PT5M",
@"-PT10M",
@"-PT15M",
@"-PT30M",
@ -575,9 +577,9 @@ static NSArray *reminderValues = nil;
//
// Used by wox template
//
- (NSArray *) reminderList
- (NSArray *) reminderValues
{
return reminderItems;
return reminderValues;
}
//
@ -587,10 +589,19 @@ static NSArray *reminderValues = nil;
{
NSString *text;
if ([item isEqualToString: @"-"])
text = item;
if ([item isEqualToString: @""])
text = @"-";
else
text = [self labelForKey: [NSString stringWithFormat: @"reminder_%@", item]];
{
NSUInteger index;
index = [reminderValues indexOfObject: item];
if (index != NSNotFound)
text = [self labelForKey: [NSString stringWithFormat: @"reminder_%@", [reminderItems objectAtIndex: index]]];
else
text = @"NONE";
}
return text;
}
@ -2087,12 +2098,17 @@ static NSArray *reminderValues = nil;
NSArray *allKeys, *accounts, *addresses;
NSMutableDictionary *sanitizedLabels;
NSDictionary *newLabels;
NSString *name;
NSString *name, *reminder;
NSUInteger index;
int i;
// We convert our object into a mutable one
v = [[v mutableCopy] autorelease];
//
// We sanitize mail labels
//
newLabels = [v objectForKey: @"SOGoMailLabelsColors"];
if (newLabels && [newLabels isKindOfClass: [NSDictionary class]])
{
@ -2116,12 +2132,9 @@ static NSArray *reminderValues = nil;
[v setObject: sanitizedLabels forKey: @"SOGoMailLabelsColors"];
}
// We sanitize our autoreply email addresses
addresses = [NSArray arrayWithArray: [[[[v objectForKey: @"Vacation"] objectForKey: @"autoReplyEmailAddresses"]
componentsSeparatedByString: @","] trimmedComponents]];
[[v objectForKey: @"Vacation"] setObject: addresses forKey: @"autoReplyEmailAddresses"];
//
// We sanitize our auxilary mail accounts
//
accounts = [v objectForKey: @"AuxiliaryMailAccounts"];
if (accounts && [accounts isKindOfClass: [NSArray class]])
{

View File

@ -386,7 +386,7 @@
<div><var:string label:value="Default reminder :"/></div>
<div>
<md-select ng-model="preferences.defaults.SOGoCalendarDefaultReminder">
<var:foreach list="reminderList" item="item">
<var:foreach list="reminderValues" item="item">
<md-option var:value="item">
<var:string value="itemReminderText"/>
</md-option>

View File

@ -26,6 +26,10 @@
}));
data.SOGoMailLabelsColors = labels;
// We convert our list of autoReplyEmailAddresses into a string.
if (data.Vacation && data.Vacation.autoReplyEmailAddresses)
data.Vacation.autoReplyEmailAddresses = data.Vacation.autoReplyEmailAddresses.join(",");
angular.extend(_this.defaults, data);
});
@ -105,6 +109,9 @@
preferences.defaults.SOGoMailLabelsColors = labels;
if (preferences.defaults.Vacation && preferences.defaults.Vacation.autoReplyEmailAddresses)
preferences.defaults.Vacation.autoReplyEmailAddresses = preferences.defaults.Vacation.autoReplyEmailAddresses.split(",");
return preferences;
};