X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=UI%2FScheduler%2FUIxCalendarSelector.m;h=1e49c8e247c12303c553623ff12f8a42f0ef130e;hb=4e6eeb543b90ae4551e7dbc24a82eb608696e1a7;hp=d28e94847ccb1666c25686ab5a8d1dff45a7be89;hpb=1c969c55faad6640893ab598ca6fba314bfab10b;p=scalable-opengroupware.org diff --git a/UI/Scheduler/UIxCalendarSelector.m b/UI/Scheduler/UIxCalendarSelector.m index d28e9484..1e49c8e2 100644 --- a/UI/Scheduler/UIxCalendarSelector.m +++ b/UI/Scheduler/UIxCalendarSelector.m @@ -22,35 +22,33 @@ #import #import -#import -#import +#import -#import -#import +#import + +#import -#import -#import -#import #import +#import #import "UIxCalendarSelector.h" -static inline char -darkenedColor (const char value) -{ - char newValue; - - if (value >= '0' && value <= '9') - newValue = ((value - '0') / 2) + '0'; - else if (value >= 'a' && value <= 'f') - newValue = ((value + 10 - 'a') / 2) + '0'; - else if (value >= 'A' && value <= 'F') - newValue = ((value + 10 - 'A') / 2) + '0'; - else - newValue = value; +// static inline char +// darkenedColor (const char value) +// { +// char newValue; - return newValue; -} +// if (value >= '0' && value <= '9') +// newValue = ((value - '0') / 2) + '0'; +// else if (value >= 'a' && value <= 'f') +// newValue = ((value + 10 - 'a') / 2) + '0'; +// else if (value >= 'A' && value <= 'F') +// newValue = ((value + 10 - 'A') / 2) + '0'; +// else +// newValue = value; + +// return newValue; +// } static inline NSString * colorForNumber (unsigned int number) @@ -91,8 +89,8 @@ colorForNumber (unsigned int number) { if ((self = [super init])) { - colors = nil; - currentCalendarFolder = nil; + calendars = nil; + currentCalendar = nil; } return self; @@ -100,77 +98,77 @@ colorForNumber (unsigned int number) - (void) dealloc { - [currentCalendarFolder release]; - [colors release]; + [calendars release]; + [currentCalendar release]; [super dealloc]; } -- (NSArray *) calendarFolders +- (NSArray *) calendars { - NSArray *calendarFolders; - NSEnumerator *newFolders; - NSDictionary *currentFolder; - unsigned int count; - - calendarFolders - = [[self clientObject] calendarFoldersInContext: context]; - if (!colors) + NSArray *folders, *roles; + SOGoAppointmentFolders *co; + SOGoAppointmentFolder *folder; + NSMutableDictionary *calendar; + unsigned int count, max; + NSString *folderName, *fDisplayName; + NSNumber *isActive; + SOGoUser *user; + + if (!calendars) { - colors = [NSMutableDictionary new]; - count = 0; - newFolders = [calendarFolders objectEnumerator]; - currentFolder = [newFolders nextObject]; - while (currentFolder) + co = [self clientObject]; + user = [[self context] activeUser]; + folders = [co subFolders]; + max = [folders count]; + calendars = [[NSMutableArray alloc] initWithCapacity: max]; + for (count = 0; count < max; count++) { - [colors setObject: colorForNumber (count) - forKey: [currentFolder objectForKey: @"folder"]]; - count++; - currentFolder = [newFolders nextObject]; + folder = [folders objectAtIndex: count]; + roles = [user rolesForObject: folder inContext: [self context]]; + calendar = [NSMutableDictionary dictionary]; + folderName = [folder nameInContainer]; + fDisplayName = [folder displayName]; + if ([fDisplayName isEqualToString: [co defaultFolderName]]) + fDisplayName = [self labelForKey: fDisplayName]; + [calendar setObject: [NSString stringWithFormat: @"/%@", folderName] + forKey: @"id"]; + [calendar setObject: fDisplayName forKey: @"displayName"]; + [calendar setObject: folderName forKey: @"folder"]; + [calendar setObject: colorForNumber (count) + forKey: @"color"]; + isActive = [NSNumber numberWithBool: [folder isActive]]; + [calendar setObject: isActive forKey: @"active"]; + [calendar setObject: [folder ownerInContext: context] + forKey: @"owner"]; + [calendar setObject: [roles componentsJoinedByString: @","] + forKey: @"roles"]; + [calendars addObject: calendar]; } } - return calendarFolders; + return calendars; } -- (void) setCurrentCalendarFolder: (NSDictionary *) newCurrentCalendarFolder +- (void) setCurrentCalendar: (NSDictionary *) newCalendar { - ASSIGN (currentCalendarFolder, newCurrentCalendarFolder); + ASSIGN (currentCalendar, newCalendar); } -- (NSDictionary *) currentCalendarFolder +- (NSDictionary *) currentCalendar { - return currentCalendarFolder; + return currentCalendar; } -- (NSString *) currentCalendarSpanBG +- (NSString *) currentCalendarClass { - NSString *colorKey; - - colorKey = [currentCalendarFolder objectForKey: @"folder"]; - - return [colors objectForKey: colorKey]; -} - -- (NSString *) currentCalendarLogin -{ - NSArray *parts; - - parts = [[currentCalendarFolder objectForKey: @"folder"] - componentsSeparatedByString: @":"]; - - return (([parts count] > 1) - ? [parts objectAtIndex: 0] - : [[context activeUser] login]); + return [currentCalendar + keysWithFormat: @"colorBox calendarFolder%{folder}"]; } - (NSString *) currentCalendarStyle { - NSString *color; - - color = [self currentCalendarSpanBG]; - - return [NSString stringWithFormat: @"color: %@; background-color: %@;", - color, color]; + return [currentCalendar + keysWithFormat: @"color: %{color}; background-color: %{color};"]; } @end /* UIxCalendarSelector */