diff --git a/ChangeLog b/ChangeLog index b3a3b9cce..ed7a86d8d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2010-08-09 Wolfgang Sourdeau + * UI/Common/UIxPageFrame.m (-setUserDefaultsKeys:) + (-hasUserDefaultsKeys, -setUserSettingsKeys:) + (-hasUserSettingsKeys): new accessor for determining explicitly + which user defaults/settings keys are returned. The new + corresponding ivars are "udKeys" and "usKeys" respectively. + (-userDefaults, -userSettings): rewrote methods to create a + dictionary containing only the requested keys (see above). Since + the source are now explicitly queried, the values can now be + inherited from the domain and system defaults. + * UI/WebServerResources/UIxFilterEditor.js (loadMailboxes): the first account is now always identitied with "0", therefore we no longer need the "firstMailAccount" variable. diff --git a/UI/Common/UIxPageFrame.h b/UI/Common/UIxPageFrame.h index 080f949bb..331db446f 100644 --- a/UI/Common/UIxPageFrame.h +++ b/UI/Common/UIxPageFrame.h @@ -40,6 +40,8 @@ NSString *toolbar; id item; BOOL isPopup; + NSArray *udKeys; + NSArray *usKeys; NSMutableArray *additionalCSSFiles; NSMutableArray *additionalJSFiles; } diff --git a/UI/Common/UIxPageFrame.m b/UI/Common/UIxPageFrame.m index cc81a8e3f..e7dddc636 100644 --- a/UI/Common/UIxPageFrame.m +++ b/UI/Common/UIxPageFrame.m @@ -25,6 +25,7 @@ #import +#import #import #import #import @@ -44,6 +45,8 @@ item = nil; title = nil; toolbar = nil; + udKeys = nil; + usKeys = nil; additionalJSFiles = nil; additionalCSSFiles = nil; } @@ -56,6 +59,8 @@ [item release]; [title release]; [toolbar release]; + [udKeys release]; + [usKeys release]; [additionalJSFiles release]; [additionalCSSFiles release]; [super dealloc]; @@ -453,30 +458,67 @@ return [ud language]; } -- (NSString *) userSettings +/* UserDefaults, UserSettings */ +- (NSString *) _dictionaryWithKeys: (NSArray *) keys + fromSource: (SOGoDefaultsSource *) source { - SOGoUserSettings *us; - NSString *jsonResult; + NSString *key; + int count, max; + NSMutableDictionary *dict; - us = [[context activeUser] userSettings]; - jsonResult = [[us source] jsonRepresentation]; - if (!jsonResult) - jsonResult = @"{}"; + max = [keys count]; - return jsonResult; + dict = [NSMutableDictionary dictionaryWithCapacity: max]; + for (count = 0; count < max; count++) + { + key = [keys objectAtIndex: count]; + [dict setObject: [source objectForKey: key] + forKey: key]; + } + + return [dict jsonRepresentation]; +} + +- (void) setUserDefaultsKeys: (NSString *) newKeys +{ + [udKeys release]; + udKeys = [[newKeys componentsSeparatedByString: @","] trimmedComponents]; + [udKeys retain]; +} + +- (BOOL) hasUserDefaultsKeys +{ + return ([udKeys count] > 0); } - (NSString *) userDefaults { SOGoUserDefaults *ud; - NSString *jsonResult; ud = [[context activeUser] userDefaults]; - jsonResult = [[ud source] jsonRepresentation]; - if (!jsonResult) - jsonResult = @"{}"; - return jsonResult; + return [self _dictionaryWithKeys: udKeys fromSource: ud]; +} + +- (void) setUserSettingsKeys: (NSString *) newKeys +{ + [usKeys release]; + usKeys = [[newKeys componentsSeparatedByString: @","] trimmedComponents]; + [usKeys retain]; +} + +- (BOOL) hasUserSettingsKeys +{ + return ([usKeys count] > 0); +} + +- (NSString *) userSettings +{ + SOGoUserSettings *us; + + us = [[context activeUser] userSettings]; + + return [self _dictionaryWithKeys: usKeys fromSource: us]; } /* browser/os identification */ diff --git a/UI/Templates/MailerUI/UIxMailEditor.wox b/UI/Templates/MailerUI/UIxMailEditor.wox index a74617252..41e07d8e9 100644 --- a/UI/Templates/MailerUI/UIxMailEditor.wox +++ b/UI/Templates/MailerUI/UIxMailEditor.wox @@ -10,6 +10,7 @@ className="UIxPageFrame" title="panelTitle" const:popup="YES" + const:userDefaultsKeys="SOGoMailComposeMessageType,SOGoMailReplyPlacement,SOGoMailSignature" const:jsFiles="UIxMailToSelection.js,ckeditor/ckeditor.js,SOGoAutoCompletion.js"> + +
+ @@ -127,8 +138,7 @@ >var UserFolderURL = ''; var UserLogin = ''; var UserLanguage = ''; - var UserSettings = ; - var UserDefaults = ; +