applied comment and refactor code

pull/45/head
Alexandre Cloutier 2014-07-07 17:42:43 -04:00
parent f0b8eb8dfb
commit b5c0363400
4 changed files with 29 additions and 25 deletions

View File

@ -419,23 +419,23 @@
forEvent: (iCalEvent *) theEvent
{
iCalPerson *currentAttendee;
NSMutableArray *attendees, *unavailableAttendees;
NSMutableArray *attendees, *unavailableAttendees, *whiteList;
NSEnumerator *enumerator;
NSString *currentUID, *buffer;
NSPredicate *predicate;
NSString *currentUID, *ownerUID;
NSMutableString *reason;
NSDictionary *values;
NSMutableDictionary *value;
SOGoUser *user, *currentUser, *ownerUser;
NSMutableDictionary *value, *moduleSettings;
SOGoUser *user;
SOGoUserSettings *us;
NSException *e;
int count = 0, i = 0;
NSMutableArray *whiteList;
NSPredicate *predicate;
// Build list of the attendees uids without ressources
attendees = [NSMutableArray arrayWithCapacity: [theAttendees count]];
unavailableAttendees = [[NSMutableArray alloc] init];
enumerator = [theAttendees objectEnumerator];
ownerUID = [[[self context] activeUser] login];
while ((currentAttendee = [enumerator nextObject]))
{
@ -444,16 +444,16 @@
{
user = [SOGoUser userWithLogin: currentUID];
us = [user userSettings];
moduleSettings = [us objectForKey:@"Calendar"];
if (![user isResource])
{
// Check if the user prevented his account from beeing invited to events
if ([[us objectForKey:@"PreventInvitations"] boolValue])
if ([[moduleSettings objectForKey:@"PreventInvitations"] boolValue])
{
// Check if the user have a whiteList
whiteList = [NSMutableArray arrayWithObject:[us objectForKey:@"whiteListInvitations"]];
predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[cd] %@", @"sogo1"];
whiteList = [NSMutableArray arrayWithObject:[moduleSettings objectForKey:@"PreventInvitationsWhitelist"]];
predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[cd] %@", ownerUID];
[whiteList filterUsingPredicate:predicate];
// If the filter have a hit, do not add the currentUID to the unavailableAttendees array
if ([whiteList count] == 0)
{

View File

@ -33,7 +33,6 @@
{
id item;
SOGoUser *user;
SOGoUserSettings *us;
NGSieveClient *client;
// Addressbook

View File

@ -19,6 +19,7 @@
*/
#import <Foundation/NSCalendarDate.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSPropertyList.h>
#import <Foundation/NSString.h>
#import <Foundation/NSTimeZone.h>
@ -642,38 +643,42 @@ static NSArray *reminderValues = nil;
- (NSArray *) whiteListValue
{
SOGoUserSettings *us;
NSArray *whiteListValue;
NSMutableDictionary *moduleSettings;
NSArray *whiteList;
us = [user userSettings];
whiteListValue = [us objectForKey:@"whiteListInvitations"];
return whiteListValue;
moduleSettings = [us objectForKey: @"Calendar"];
whiteList = [moduleSettings objectForKey:@"PreventInvitationsWhitelist"];
return whiteList;
}
- (void) setWhiteListValue: (NSArray *) whiteList
{
SOGoUserSettings *us;
NSMutableDictionary *moduleSettings;
us = [user userSettings];
[us setObject: whiteList forKey: @"whiteListInvitations"];
moduleSettings = [us objectForKey: @"Calendar"];
[moduleSettings setObject: whiteList forKey: @"PreventInvitationsWhitelist"];
[us synchronize];
}
- (void) setPreventInvitations: (BOOL) preventInvitations
{
SOGoUserSettings *us;
NSMutableDictionary *moduleSettings;
us = [user userSettings];
[us setBool: preventInvitations forKey: @"PreventInvitations"];
moduleSettings = [us objectForKey: @"Calendar"];
[moduleSettings setObject: [NSNumber numberWithBool: preventInvitations] forKey: @"PreventInvitations"];
[us synchronize];
}
- (BOOL) preventInvitations
{
SOGoUserSettings *us;
NSMutableDictionary *moduleSettings;
us = [user userSettings];
return [[us objectForKey: @"PreventInvitations"] boolValue];
moduleSettings = [us objectForKey: @"Calendar"];
return [[moduleSettings objectForKey: @"PreventInvitations"] boolValue];
}
- (NSArray *) firstWeekList

View File

@ -229,9 +229,9 @@ function initPreferences() {
// Calendar whiteList
var whiteList = $("appointmentsWhiteListWrapper");
if(whiteList) {
var whiteListValue = $("whiteListValue").getValue().split(",");
if (whiteListValue.length != 0)
{
var whiteListValue = $("whiteListValue").getValue();
if (whiteListValue != "") {
whiteListValue = whiteListValue.split(",");
var tablebody = $("appointmentsWhiteListWrapper").childNodesWithTag("table")[0].tBodies[0];
for (i = 0; i < whiteListValue.length; i++)
{