Preferences saving support

pull/91/head
Ludovic Marcotte 2015-03-21 15:34:18 -04:00 committed by Francis Lachapelle
parent 2edfd1863b
commit 96d2a4cea8
6 changed files with 34 additions and 24 deletions

View File

@ -1,8 +1,6 @@
/* SOGoDefaultsSource.h - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Copyright (C) 2009-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 @@
/* SOGoDefaultsSource.m - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Copyright (C) 2009-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,6 +1,6 @@
/* SOGoUserDefaults.m - this file is part of SOGo
*
* Copyright (C) 2009-2014 Inverse inc.
* Copyright (C) 2009-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,6 +1,6 @@
/* UIxPreferences.h - this file is part of SOGo
*
* Copyright (C) 2007-2013 Inverse inc.
* 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
@ -61,7 +61,7 @@
}
- (NSString *) userLongDateFormat;
//- (NSString *) userLongDateFormat;
- (BOOL) isSieveServerAvailable;
- (id) sieveClient;

View File

@ -58,14 +58,6 @@
#import "UIxPreferences.h"
#warning this class is not finished
/* remaining:
default event length
default snooze length
refresh calendar every X minutes
workweek = from -> to
identities */
static NSArray *reminderItems = nil;
static NSArray *reminderValues = nil;
@ -1889,7 +1881,24 @@ static NSArray *reminderValues = nil;
- (id <WOActionResults>) saveAction
{
//return [self responseWithStatus: 200 andJSONRepresentation: data];
SOGoUser *user;
id o, v;
o = [[[context request] contentAsString] objectFromJSONString];
user = [[self context] activeUser];
if ((v = [o objectForKey: @"defaults"]))
{
[[[user userDefaults] source] setValues: v];
[[user userDefaults] synchronize];
}
if ((v = [o objectForKey: @"settings"]))
{
[[[user userSettings] source] setValues: v];
[[user userSettings] synchronize];
}
return [self responseWithStatus: 200];
}

View File

@ -88,18 +88,23 @@
Preferences.prototype.$omit = function(deep) {
var preferences = {};
angular.forEach(this, function(value, key) {
if (key == 'refs') {
preferences.refs = _.map(value, function(o) {
return o.$omit(deep);
});
}
else if (key != 'constructor' && key[0] != '$') {
if (key != 'constructor' && key[0] != '$') {
if (deep)
preferences[key] = angular.copy(value);
else
preferences[key] = value;
}
});
// We swap _$key -> $key to avoid an Angular bug (https://github.com/angular/angular.js/issues/6266)
var labels = _.object(_.map(preferences.defaults.SOGoMailLabelsColors, function(value, key) {
if (key.charAt(0) == '_' && key.charAt(1) == '$')
return [key.substring(1), value];
return [key, value];
}));
preferences.defaults.SOGoMailLabelsColors = labels;
return preferences;
};