mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-19 05:25:55 +00:00
More cleanups, defaults values for mail/contact/calendar labels and data validation
This commit is contained in:
committed by
Francis Lachapelle
parent
818af41ea6
commit
0f2e3df164
@@ -27,6 +27,9 @@
|
||||
#import <SOGo/SOGoUserDefaults.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
#import <SOGo/SOGoUserProfile.h>
|
||||
#import <Mailer/SOGoMailLabel.h>
|
||||
|
||||
#import <SOGoUI/UIxComponent.h>
|
||||
|
||||
#import "UIxJSONPreferences.h"
|
||||
|
||||
@@ -47,9 +50,51 @@
|
||||
- (WOResponse *) jsonDefaultsAction
|
||||
{
|
||||
SOGoUserDefaults *defaults;
|
||||
NSArray *categoryLabels;
|
||||
|
||||
defaults = [[context activeUser] userDefaults];
|
||||
|
||||
if (![[defaults source] objectForKey: @"SOGoLongDateFormat"])
|
||||
[[defaults source] setObject: @"default" forKey: @"SOGoLongDateFormat"];
|
||||
|
||||
// Populate default calendar categories, based on the user's preferred language
|
||||
if (![defaults calendarCategories])
|
||||
{
|
||||
categoryLabels = [[[self labelForKey: @"calendar_category_labels"]
|
||||
componentsSeparatedByString: @","]
|
||||
sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
||||
|
||||
[defaults setCalendarCategories: categoryLabels];
|
||||
}
|
||||
|
||||
// Populate default contact categories, based on the user's preferred language
|
||||
if (![defaults contactsCategories])
|
||||
{
|
||||
categoryLabels = [[[self labelForKey: @"contacts_category_labels"]
|
||||
componentsSeparatedByString: @","]
|
||||
sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
||||
|
||||
if (!categoryLabels)
|
||||
categoryLabels = [NSArray array];
|
||||
|
||||
[defaults setContactsCategories: categoryLabels];
|
||||
}
|
||||
|
||||
// Populate default mail lablels, based on the user's preferred language
|
||||
if (![[defaults source] objectForKey: @"SOGoMailLabelsColors"])
|
||||
{
|
||||
NSDictionary *v;
|
||||
|
||||
v = [defaults mailLabelsColors];
|
||||
|
||||
// TODO - translate + refactor to not pass self since it's not a component
|
||||
//[defaults setMailLabelsColors: [SOGoMailLabel labelsFromDefaults: v component: self]];
|
||||
[defaults setMailLabelsColors: v];
|
||||
}
|
||||
|
||||
|
||||
[defaults synchronize];
|
||||
|
||||
return [self _makeResponse: [defaults source]];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user