diff --git a/UI/Scheduler/UIxCalView.h b/UI/Scheduler/UIxCalView.h index 26e5e3537..e3ccebfe2 100644 --- a/UI/Scheduler/UIxCalView.h +++ b/UI/Scheduler/UIxCalView.h @@ -12,11 +12,13 @@ a SOPE clientObject (which usually is an SOGoAppointmentFolder). */ -@class NSString, NSArray, NSDictionary, NSCalendarDate, SOGoAptFormatter; +@class NSString, NSArray, NSDictionary, NSMutableDictionary, NSCalendarDate, SOGoAptFormatter; +@class SOGoAppointmentFolder; @interface UIxCalView : UIxComponent { NSArray *appointments; + NSMutableDictionary *componentsData; NSArray *tasks; NSArray *allDayApts; id appointment; @@ -100,6 +102,7 @@ /* calendarUIDs */ - (NSString *)formattedCalendarUIDs; +- (SOGoAppointmentFolder *) calendarFolderForUID: (NSString *) uid; /* CSS related */ diff --git a/UI/Scheduler/UIxCalView.m b/UI/Scheduler/UIxCalView.m index 7ed1b94a8..81121f25b 100644 --- a/UI/Scheduler/UIxCalView.m +++ b/UI/Scheduler/UIxCalView.m @@ -1,15 +1,22 @@ // $Id: UIxCalView.m 885 2005-07-21 16:41:34Z znek $ -#import "UIxCalView.h" #import "common.h" //#import -#import "SoObjects/Appointments/SOGoAppointmentFolder.h" + +#import #import -#import #import #import + +#import #import "UIxComponent+Agenor.h" +#import "SoObjects/Appointments/SOGoAppointmentFolder.h" +#import +#import + +#import "UIxCalView.h" + @interface UIxCalView (PrivateAPI) - (NSString *) _userFolderURI; @end @@ -47,12 +54,14 @@ static BOOL shouldDisplayWeekend = NO; privateAptTooltipFormatter = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: tz]; [self configureFormatters]; + componentsData = [NSMutableDictionary new]; } return self; } - (void) dealloc { + [componentsData release]; [appointments release]; [allDayApts release]; [appointment release]; @@ -431,11 +440,85 @@ static BOOL shouldDisplayWeekend = NO; return [[self startDate] tomorrow]; } +- (SOGoAppointmentFolder *) calendarFolderForUID: (NSString *) uid +{ + SOGoFolder *upperContainer; + SOGoUserFolder *userFolder; + SOGoAppointmentFolder *calendarFolder; + SoSecurityManager *securityManager; + + upperContainer = [[[self clientObject] container] container]; + userFolder = [SOGoUserFolder objectWithName: uid + inContainer: upperContainer]; + calendarFolder = [SOGoAppointmentFolder objectWithName: @"Calendar" + inContainer: userFolder]; + [calendarFolder + setOCSPath: [NSString stringWithFormat: @"/Users/%@/Calendar", uid]]; + [calendarFolder setOwner: uid]; + + securityManager = [SoSecurityManager sharedSecurityManager]; + + return (([securityManager validatePermission: SoPerm_AccessContentsInformation + onObject: calendarFolder + inContext: context] == nil) + ? calendarFolder : nil); +} + +- (NSArray *) activeCalendarFolders +{ + NSUserDefaults *ud; + NSEnumerator *calendarUIDs; + SOGoAppointmentFolder *currentFolder; + NSMutableArray *folders; + NSString *currentUID; + + folders = [NSMutableArray array]; + ud = [[context activeUser] userDefaults]; + calendarUIDs = [[[ud stringForKey: @"calendaruids"] + componentsSeparatedByString: @","] objectEnumerator]; + currentUID = [calendarUIDs nextObject]; + while (currentUID) + { + if (![currentUID hasPrefix: @"-"]) + { + currentFolder = [self calendarFolderForUID: currentUID]; + if (currentFolder) + [folders addObject: currentFolder]; + } + currentUID = [calendarUIDs nextObject]; + } + + return folders; +} + - (NSArray *) _fetchCoreInfosForComponent: (NSString *) component { - return [[self clientObject] fetchCoreInfosFrom: [[self startDate] beginOfDay] - to: [[self endDate] endOfDay] - component: component]; + NSArray *currentInfos; + NSMutableArray *infos; + NSEnumerator *folders; + SOGoAppointmentFolder *currentFolder; + + infos = [componentsData objectForKey: component]; + if (!infos) + { + infos = [NSMutableArray array]; + folders = [[self activeCalendarFolders] objectEnumerator]; + currentFolder = [folders nextObject]; + while (currentFolder) + { + currentInfos = [currentFolder fetchCoreInfosFrom: [[self startDate] beginOfDay] + to: [[self endDate] endOfDay] + component: component]; + [currentInfos makeObjectsPerform: @selector (setObject:forKey:) + withObject: [currentFolder ownerInContext: nil] + withObject: @"owner"]; + [infos addObjectsFromArray: currentInfos]; + currentFolder = [folders nextObject]; + } + [componentsData setObject: infos forKey: component]; + } + + return infos; } - (NSArray *) fetchCoreAppointmentsInfos diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 64cf62d76..689053f6b 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -597,12 +597,10 @@ - (NSCalendarDate *) newStartDate { NSCalendarDate *newStartDate, *now; - BOOL hmSpecified; int hour; newStartDate = [self selectedDate]; - hmSpecified = ([[self queryParameterForKey: @"hm"] length] > 0); - if (!hmSpecified) + if ([[self queryParameterForKey: @"hm"] length] == 0) { now = [NSCalendarDate calendarDate]; [now setTimeZone: [[self clientObject] userTimeZone]]; diff --git a/UI/Scheduler/product.plist b/UI/Scheduler/product.plist index 1b52a82b8..c0fdd8b38 100644 --- a/UI/Scheduler/product.plist +++ b/UI/Scheduler/product.plist @@ -96,7 +96,12 @@ updateCalendars = { protectedBy = "View"; pageName = "UIxCalMainView"; - actionName = "updateCalendars"; + actionName = "updateCalendars"; + }; + checkRights = { + protectedBy = "View"; + pageName = "UIxCalMainView"; + actionName = "checkRights"; }; freeBusyTable = { protectedBy = "View"; diff --git a/UI/Templates/SchedulerUI/UIxCalCalendarsListView.wox b/UI/Templates/SchedulerUI/UIxCalCalendarsListView.wox index a1be32646..52f01c743 100644 --- a/UI/Templates/SchedulerUI/UIxCalCalendarsListView.wox +++ b/UI/Templates/SchedulerUI/UIxCalCalendarsListView.wox @@ -20,7 +20,6 @@

' + ' ' - + ' ' + + ' ' + contactName + ''); + var listElems = names.childNodesWithTag("li"); + var input = listElems.childNodesWithTag("input")[0]; + input.addEventListener("change", updateCalendarStatus, false); var styles = document.getElementsByTagName("style"); styles[0].innerHTML += ('.ownerIs' + contactId + ' {' - + ' background-color: ' + colorDef + + ' background-color: ' + + indexColor(listElems.length - 1) + ' !important; }'); } } @@ -1060,6 +1051,37 @@ function initCalendarContactsSelector() { inhibitMyCalendarEntry(); updateCalendarStatus(); selector.changeNotification = updateCalendarsList; + + var rights; + var http = createHTTPClient(); + if (http) { +// log ("url: " + url); + // TODO: add parameter to signal that we are only interested in OK + http.url = ApplicationBaseURL + "checkRights"; + http.open("GET", http.url, false /* not async */); + http.send(""); + if (http.status == 200 + && http.responseText.length > 0) + rights = http.responseText.split(","); + } + + var list = $("uixselector-calendarsList-display").childNodesWithTag("li"); + for (var i = 0; i < list.length; i++) { + var input = list[i].childNodesWithTag("input")[0]; + if (rights) { + if (rights[i] == "1") { + input.addEventListener("change", updateCalendarStatus, false); + list[i].removeClassName("denied"); + } + else { + input.checked = false; + input.disabled = true; + list[i].addClassName("denied"); + } + } else { + input.addEventListener("change", updateCalendarStatus, false); + } + } } function initCalendars() {