Monotone-Parent: eb3a293c7b6e644d0c97e3f1954550bb78ebb5ef

Monotone-Revision: 57c23145f32ca331b252396523bd85f31ce56f35

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-10-26T00:16:56
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2006-10-26 00:16:56 +00:00
parent 21799d8e1f
commit ad44460f9f
3 changed files with 128 additions and 0 deletions
+7
View File
@@ -1,5 +1,12 @@
2006-10-25 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/MainUI/SOGoUserHomePage.m ([SOGoUserHomePage
-readFreeBusyAction]): new method that returns an array of numbers
corresponding to the state in the freebusy of each "quarter of an
hour" between the "sday" and "eday" date parameters passed in the
url. This permits to handle the display of the freebusy with Ajax
mechanisms.
* UI/Contacts/UIxContactFoldersView.m ([UIxContactFoldersView
-contactSearchAction]): new action that returns the uid and the
username + email of the user whose name contain the value of the
+111
View File
@@ -19,6 +19,11 @@
02111-1307, USA.
*/
#import <NGObjWeb/WOResponse.h>
#import <SoObjects/Appointments/SOGoFreeBusyObject.h>
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
#import <NGExtensions/NSCalendarDate+misc.h>
#import <SOGoUI/UIxComponent.h>
#import <Scheduler/UIxComponent+Agenor.h>
@@ -233,4 +238,110 @@ static NSArray *internetAccessStates = nil;
return [NSException exceptionWithHTTPStatus:200 /* OK */];
}
- (void) _fillFreeBusyItems: (NSMutableArray *) items
withRecords: (NSEnumerator *) records
fromStartDate: (NSCalendarDate *) startDate
toEndDate: (NSCalendarDate *) endDate
{
NSDictionary *record;
unsigned int count, startInterval, endInterval, value;
NSNumber *status;
NSCalendarDate *currentDate;
record = [records nextObject];
while (record)
{
status = [record objectForKey: @"status"];
value = [[record objectForKey: @"startdate"] intValue];
currentDate = [NSCalendarDate dateWithTimeIntervalSince1970: value];
if ([currentDate earlierDate: startDate] == currentDate)
startInterval = 0;
else
startInterval
= ([currentDate timeIntervalSinceDate: startDate] / 900);
value = [[record objectForKey: @"enddate"] intValue];
currentDate = [NSCalendarDate dateWithTimeIntervalSince1970: value];
if ([currentDate earlierDate: endDate] == endDate)
endInterval = [items count] - 1;
else
endInterval = ([currentDate timeIntervalSinceDate: startDate] / 900);
for (count = startInterval; count < endInterval; count++)
[items replaceObjectAtIndex: count withObject: status];
record = [records nextObject];
}
}
- (NSString *) _freeBusyAsTextFromStartDate: (NSCalendarDate *) startDate
toEndDate: (NSCalendarDate *) endDate
forFreeBusy: (SOGoFreeBusyObject *) fb
{
NSEnumerator *records;
NSMutableArray *freeBusyItems;
NSTimeInterval interval;
unsigned int count, intervals;
interval = [endDate timeIntervalSinceDate: startDate] + 60;
intervals = interval / 900; /* slices of 15 minutes */
freeBusyItems = [NSMutableArray arrayWithCapacity: intervals];
for (count = 0; count < intervals - 1; count++)
[freeBusyItems addObject: @"0"];
records = [[fb fetchFreebusyInfosFrom: startDate to: endDate] objectEnumerator];
[self _fillFreeBusyItems: freeBusyItems withRecords: records
fromStartDate: startDate toEndDate: endDate];
return [freeBusyItems componentsJoinedByString: @","];
}
- (NSString *) _freeBusyAsText
{
SOGoFreeBusyObject *co;
NSCalendarDate *startDate, *endDate;
NSString *queryDay;
NSTimeZone *uTZ;
co = [self clientObject];
uTZ = [co userTimeZone];
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];
return [self _freeBusyAsTextFromStartDate: startDate toEndDate: endDate
forFreeBusy: co];
}
- (id <WOActionResults>) readFreeBusyAction
{
WOResponse *response;
response = [context response];
[response setStatus: 200];
[response setHeader: @"text/plain; charset=iso-8859-1"
forKey: @"Content-Type"];
[response appendContentString: [self _freeBusyAsText]];
return response;
}
@end /* SOGoUserHomePage */
+10
View File
@@ -77,6 +77,16 @@
};
};
};
SOGoFreeBusyObject = {
superclass = "SOGoObject";
methods = {
ajaxRead = {
protectedBy = "View";
pageName = "SOGoUserHomePage";
actionName = "readFreeBusy";
};
};
};
SOGoCustomGroupFolder = {
superclass = "SOGoGroupFolder";
methods = {