View Issue Details

IDProjectCategoryView StatusLast Update
0000253SOGoWeb Preferencespublic2009-12-22 17:12
Reporterayearout Assigned Toludovic  
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Product Version1.1.0 
Fixed in Version1.2.0 
Summary0000253: Specify default categories for preferences and calendar module
Description

I needed a way to specify a default set of categories and category colors using the defaults tool. Attached is my patch that alleviates this problem. This patch references two new available preferences, SOGoCalendarCategories and SOGoCalendarCategoriesColors. In the future, sanity checking to insure that the number of colors matches the number of categories would probably be good.

TagsNo tags attached.

Activities

2009-11-19 05:25

 

sogo-default-categories.diff (2,037 bytes)   
--- SOGo-1.1.0.orig/UI/PreferencesUI/UIxPreferences.m	2009-11-18 19:30:17.000000000 -0800
+++ SOGo-1.1.0/UI/PreferencesUI/UIxPreferences.m	2009-11-18 21:03:54.000000000 -0800
@@ -984,17 +984,28 @@
   NSDictionary *element;
   NSArray *k, *v, *names;
   NSMutableArray *rc, *colors;
+  NSUserDefaults *standardDefaults;
+
   int i, count;
 
+  standardDefaults = [NSUserDefaults standardUserDefaults];
+
   names = [userDefaults arrayForKey: @"CalendarCategories"];
-  if (names)
-    colors = [NSMutableArray arrayWithArray: 
-                  [userDefaults arrayForKey: @"CalendarCategoriesColors"]];
-  else
+  colors = [NSMutableArray arrayWithArray: 
+                [userDefaults arrayForKey: @"CalendarCategoriesColors"]];
+  if (!names)
     {
+      names = [standardDefaults arrayForKey: @"SOGoCalendarCategories"];
+      colors = [NSMutableArray arrayWithArray:
+                    [standardDefaults arrayForKey: @"SOGoCalendarCategoriesColors"]];
+    } 
+
+  if (!names)
       names = [[self labelForKey: @"category_labels"]
                 componentsSeparatedByString: @","];
       
+  if (!colors)
+    {
       count = [names count];
       colors = [NSMutableArray arrayWithCapacity: count];
       for (i = 0; i < count; i++)
--- SOGo-1.1.0.orig/UI/Scheduler/UIxComponentEditor.m	2009-11-18 19:30:17.000000000 -0800
+++ SOGo-1.1.0/UI/Scheduler/UIxComponentEditor.m	2009-11-18 20:33:48.000000000 -0800
@@ -825,11 +825,14 @@
 {
   NSMutableArray *categoryList;
   NSArray *categoryLabels;
-  NSUserDefaults *defaults;
+  NSUserDefaults *defaults, *standardDefaults;
 
   defaults = [[context activeUser] userDefaults];
+  standardDefaults = [NSUserDefaults standardUserDefaults];
   categoryLabels = [defaults arrayForKey: @"CalendarCategories"];
   if (!categoryLabels)
+    categoryLabels = [standardDefaults arrayForKey: @"SOGoCalendarCategories"];
+  if (!categoryLabels) 
     categoryLabels = [[self labelForKey: @"category_labels"]
                        componentsSeparatedByString: @","];
   categoryList
sogo-default-categories.diff (2,037 bytes)   
ludovic

ludovic

2009-12-22 17:12

administrator   ~0000368

This is now supported with the recent refactorings (for preferences handling).

Issue History

Date Modified Username Field Change
2009-11-19 05:25 ayearout New Issue
2009-11-19 05:25 ayearout File Added: sogo-default-categories.diff
2009-12-22 17:12 ludovic Note Added: 0000368
2009-12-22 17:12 ludovic Status new => resolved
2009-12-22 17:12 ludovic Fixed in Version => 1.2.0
2009-12-22 17:12 ludovic Resolution open => fixed
2009-12-22 17:12 ludovic Assigned To => ludovic