mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-09-15 02:18:00 +00:00
Monotone-Parent: 40b752e32c5a135beca554a131f9301c3e3afd72
Monotone-Revision: 19b0008e26816c6e8c6ccdb5329120a04a33f229 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-05-17T14:48:17 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
2010-05-17 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2010-05-17 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* UI/MainUI/SOGoUserHomePage.m (-readFreeBusyAction): simplified
|
||||||
|
method by using -[self responseWithStatus:andString:].
|
||||||
|
|
||||||
* UI/WebServerResources/generic.js (log): improved the method's
|
* UI/WebServerResources/generic.js (log): improved the method's
|
||||||
performance by making use of DOM methods on the "logConsole"
|
performance by making use of DOM methods on the "logConsole"
|
||||||
object.
|
object.
|
||||||
|
|||||||
@@ -152,79 +152,78 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) _freeBusyAsTextFromStartDate: (NSCalendarDate *) startDate
|
- (NSString *) _freeBusyFromStartDate: (NSCalendarDate *) startDate
|
||||||
toEndDate: (NSCalendarDate *) endDate
|
toEndDate: (NSCalendarDate *) endDate
|
||||||
forFreeBusy: (SOGoFreeBusyObject *) fb
|
forFreeBusy: (SOGoFreeBusyObject *) fb
|
||||||
{
|
{
|
||||||
NSMutableString *response;
|
NSMutableArray *freeBusy;
|
||||||
unsigned int *freeBusyItems;
|
unsigned int *freeBusyItems;
|
||||||
NSTimeInterval interval;
|
NSTimeInterval interval;
|
||||||
unsigned int count, intervals;
|
unsigned int count, intervals;
|
||||||
|
|
||||||
interval = [endDate timeIntervalSinceDate: startDate] + 60;
|
interval = [endDate timeIntervalSinceDate: startDate] + 60;
|
||||||
intervals = interval / intervalSeconds; /* slices of 15 minutes */
|
intervals = interval / intervalSeconds; /* slices of 15 minutes */
|
||||||
|
|
||||||
freeBusyItems = NSZoneCalloc (NULL, intervals, sizeof (int));
|
freeBusyItems = NSZoneCalloc (NULL, intervals, sizeof (int));
|
||||||
[self _fillFreeBusyItems: freeBusyItems count: intervals
|
[self _fillFreeBusyItems: freeBusyItems count: intervals
|
||||||
withRecords: [fb fetchFreeBusyInfosFrom: startDate to: endDate]
|
withRecords: [fb fetchFreeBusyInfosFrom: startDate to: endDate]
|
||||||
fromStartDate: startDate toEndDate: endDate];
|
fromStartDate: startDate toEndDate: endDate];
|
||||||
|
|
||||||
response = [NSMutableString string];
|
freeBusy = [NSMutableArray arrayWithCapacity: intervals];
|
||||||
for (count = 0; count < intervals; count++)
|
for (count = 0; count < intervals; count++)
|
||||||
[response appendFormat: @"%d,", *(freeBusyItems + count)];
|
[freeBusy
|
||||||
[response deleteCharactersInRange: NSMakeRange (intervals * 2 - 1, 1)];
|
addObject: [NSString stringWithFormat: @"%d", *(freeBusyItems + count)]];
|
||||||
NSZoneFree (NULL, freeBusyItems);
|
NSZoneFree (NULL, freeBusyItems);
|
||||||
|
|
||||||
return response;
|
return [freeBusy componentsJoinedByString: @","];
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *) _freeBusyAsText
|
|
||||||
{
|
|
||||||
SOGoFreeBusyObject *co;
|
|
||||||
NSCalendarDate *startDate, *endDate;
|
|
||||||
NSString *queryDay, *additionalDays;
|
|
||||||
NSTimeZone *uTZ;
|
|
||||||
SOGoUser *user;
|
|
||||||
|
|
||||||
co = [self clientObject];
|
|
||||||
user = [context activeUser];
|
|
||||||
uTZ = [[user userDefaults] timeZone];
|
|
||||||
|
|
||||||
queryDay = [self queryParameterForKey: @"sday"];
|
|
||||||
if ([queryDay length])
|
|
||||||
startDate = [NSCalendarDate dateFromShortDateString: queryDay
|
|
||||||
andShortTimeString: @"0000"
|
|
||||||
inTimeZone: uTZ];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
startDate = [NSCalendarDate calendarDate];
|
|
||||||
[startDate setTimeZone: uTZ];
|
|
||||||
startDate = [startDate hour: 0 minute: 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
queryDay = [self queryParameterForKey: @"eday"];
|
|
||||||
if ([queryDay length])
|
|
||||||
endDate = [NSCalendarDate dateFromShortDateString: queryDay
|
|
||||||
andShortTimeString: @"2359"
|
|
||||||
inTimeZone: uTZ];
|
|
||||||
else
|
|
||||||
endDate = [startDate hour: 23 minute: 59];
|
|
||||||
|
|
||||||
additionalDays = [self queryParameterForKey: @"additional"];
|
|
||||||
if ([additionalDays length] > 0)
|
|
||||||
endDate = [endDate dateByAddingYears: 0 months: 0
|
|
||||||
days: [additionalDays intValue]
|
|
||||||
hours: 0 minutes: 0 seconds: 0];
|
|
||||||
|
|
||||||
return [self _freeBusyAsTextFromStartDate: startDate toEndDate: endDate
|
|
||||||
forFreeBusy: co];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id <WOActionResults>) readFreeBusyAction
|
- (id <WOActionResults>) readFreeBusyAction
|
||||||
{
|
{
|
||||||
WOResponse *response;
|
WOResponse *response;
|
||||||
|
SOGoFreeBusyObject *co;
|
||||||
|
NSCalendarDate *startDate, *endDate;
|
||||||
|
NSString *queryDay;
|
||||||
|
NSTimeZone *uTZ;
|
||||||
|
SOGoUser *user;
|
||||||
|
|
||||||
response = [self responseWithStatus: 200];
|
user = [context activeUser];
|
||||||
[response appendContentString: [self _freeBusyAsText]];
|
uTZ = [[user userDefaults] timeZone];
|
||||||
|
|
||||||
|
queryDay = [self queryParameterForKey: @"sday"];
|
||||||
|
if ([queryDay length] == 8)
|
||||||
|
{
|
||||||
|
startDate = [NSCalendarDate dateFromShortDateString: queryDay
|
||||||
|
andShortTimeString: @"0000"
|
||||||
|
inTimeZone: uTZ];
|
||||||
|
queryDay = [self queryParameterForKey: @"eday"];
|
||||||
|
if ([queryDay length] == 8)
|
||||||
|
{
|
||||||
|
endDate = [NSCalendarDate dateFromShortDateString: queryDay
|
||||||
|
andShortTimeString: @"2359"
|
||||||
|
inTimeZone: uTZ];
|
||||||
|
|
||||||
|
if ([startDate earlierDate: endDate] == endDate)
|
||||||
|
response = [self responseWithStatus: 403
|
||||||
|
andString: @"Start date is later than end date."];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
co = [self clientObject];
|
||||||
|
response
|
||||||
|
= [self responseWithStatus: 200
|
||||||
|
andString: [self
|
||||||
|
_freeBusyFromStartDate: startDate
|
||||||
|
toEndDate: endDate
|
||||||
|
forFreeBusy: co]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
response = [self responseWithStatus: 403
|
||||||
|
andString: @"Invalid end date."];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
response = [self responseWithStatus: 403
|
||||||
|
andString: @"Invalid start date."];
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user