Improve JSON getters for events
parent
56607a1baf
commit
862068eeb5
|
@ -73,7 +73,7 @@ NSNumber *iCalDistantFutureNumber = nil;
|
|||
- (NSDictionary *) attributes
|
||||
{
|
||||
NSArray *elements;
|
||||
NSMutableArray *attendees, *categories;
|
||||
NSMutableArray *attendees;
|
||||
NSDictionary *organizerData;
|
||||
NSMutableDictionary *data, *attendeeData, *alarmData;
|
||||
NSEnumerator *attendeesList;
|
||||
|
@ -81,7 +81,6 @@ NSNumber *iCalDistantFutureNumber = nil;
|
|||
iCalAlarm *alarm;
|
||||
iCalTrigger *trigger;
|
||||
id value;
|
||||
unsigned int i, max;
|
||||
|
||||
data = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
[[self tag] lowercaseString], @"component",
|
||||
|
@ -93,22 +92,14 @@ NSNumber *iCalDistantFutureNumber = nil;
|
|||
if (value) [data setObject: value forKey: @"location"];
|
||||
if ([self comment]) [data setObject: [self comment] forKey: @"comment"];
|
||||
if ([self attach]) [data setObject: [[self attach] absoluteString] forKey: @"attachUrl"];
|
||||
if ([self accessClass]) [data setObject: [self accessClass] forKey: @"classification"];
|
||||
if ([self accessClass]) [data setObject: [[self accessClass] lowercaseString] forKey: @"classification"];
|
||||
if ([self status]) [data setObject: [self status] forKey: @"status"];
|
||||
if ([self createdBy]) [data setObject: [self createdBy] forKey: @"createdBy"];
|
||||
|
||||
// Categories
|
||||
elements = [self childrenWithTag: @"categories"];
|
||||
max = [elements count];
|
||||
if (max > 0)
|
||||
{
|
||||
categories = [NSMutableArray arrayWithCapacity: max];
|
||||
for (i = 0; i < max; i++)
|
||||
{
|
||||
[categories addObject: [[elements objectAtIndex: i] flattenedValuesForKey: @""]];
|
||||
}
|
||||
[data setObject: categories forKey: @"categories"];
|
||||
}
|
||||
elements = [self categories];
|
||||
if ([elements count])
|
||||
[data setObject: elements forKey: @"categories"];
|
||||
|
||||
// Send appointment notifications
|
||||
value = [self firstChildWithTag: @"X-SOGo-Send-Appointment-Notifications"];
|
||||
|
|
|
@ -313,4 +313,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see [iCalEntityObject+SOGo attributes]
|
||||
* @see [UIxAppointmentEditor viewAction]
|
||||
*/
|
||||
- (NSDictionary *) attributes
|
||||
{
|
||||
NSMutableDictionary *data;
|
||||
|
||||
data = [NSMutableDictionary dictionaryWithDictionary: [super attributes]];
|
||||
|
||||
[data setObject: [NSNumber numberWithBool: [self isAllDay]] forKey: @"isAllDay"];
|
||||
[data setObject: [NSNumber numberWithBool: ![self isOpaque]] forKey: @"isTransparent"];
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
|
||||
/**
|
||||
* @see [iCalEntityObject+SOGo attributes]
|
||||
* @see [iCalEvent+SOGo attributes]
|
||||
* @see [UIxAppointmentEditor viewAction]
|
||||
*/
|
||||
- (NSDictionary *) attributes
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* UIxAppointmentEditor.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007-2014 Inverse inc.
|
||||
* Copyright (C) 2007-2015 Inverse inc.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -200,27 +200,25 @@
|
|||
ASSIGN (componentCalendar, _componentCalendar);
|
||||
}
|
||||
|
||||
- (NSString *) formattedDateString: (NSCalendarDate *) date
|
||||
{
|
||||
char buf[22];
|
||||
NSNumber *day, *month, *year;
|
||||
|
||||
day = [NSNumber numberWithInt: [date dayOfMonth]];
|
||||
month = [NSNumber numberWithInt: [date monthOfYear]];
|
||||
year = [NSNumber numberWithInt: [date yearOfCommonEra]];
|
||||
|
||||
sprintf(buf, "%04d-%02d-%02d",
|
||||
[year intValue],
|
||||
[month intValue],
|
||||
[day intValue]);
|
||||
|
||||
return [NSString stringWithCString:buf];
|
||||
}
|
||||
|
||||
|
||||
/* read-only event */
|
||||
- (NSString *) aptStartDateText
|
||||
{
|
||||
return [dateFormatter formattedDate: aptStartDate];
|
||||
}
|
||||
|
||||
- (NSString *) aptStartDateTimeText
|
||||
{
|
||||
return [dateFormatter formattedDateAndTime: aptStartDate];
|
||||
}
|
||||
|
||||
- (NSString *) aptEndDateText
|
||||
{
|
||||
return [dateFormatter formattedDate: aptEndDate];
|
||||
}
|
||||
|
||||
- (NSString *) aptEndDateTimeText
|
||||
{
|
||||
return [dateFormatter formattedDateAndTime: aptEndDate];
|
||||
}
|
||||
|
||||
- (BOOL) startDateIsEqualToEndDate
|
||||
{
|
||||
return [aptStartDate isEqualToDate: aptEndDate];
|
||||
|
@ -586,9 +584,11 @@
|
|||
* @apiSuccess (Success 200) {String} id Event ID
|
||||
* @apiSuccess (Success 200) {String} pid Calendar ID (event's folder)
|
||||
* @apiSuccess (Success 200) {String} calendar Human readable name of calendar
|
||||
* @apiSuccess (Success 200) {String} startDate Formatted start date
|
||||
* @apiSuccess (Success 200) {String} startDate Start date (YYYY-MM-DD)
|
||||
* @apiSuccess (Success 200) {String} localizedStartDate Formatted start date
|
||||
* @apiSuccess (Success 200) {String} startTime Formatted start time
|
||||
* @apiSuccess (Success 200) {String} endDate Formatted end date
|
||||
* @apiSuccess (Success 200) {String} endDate End date (YYYY-MM-DD)
|
||||
* @apiSuccess (Success 200) {String} localizedEndDate Formatted end date
|
||||
* @apiSuccess (Success 200) {String} endTime Formatted end time
|
||||
* @apiSuccess (Success 200) {Number} isAllDay 1 if event is all-day
|
||||
* @apiSuccess (Success 200) {Number} isTransparent 1 if the event is not opaque
|
||||
|
@ -600,8 +600,10 @@
|
|||
* @apiSuccess (Success 200) {String} summary Summary
|
||||
* @apiSuccess (Success 200) {String} location Location
|
||||
* @apiSuccess (Success 200) {String} comment Comment
|
||||
* @apiSuccess (Success 200) {String} [attachUrl] Attached URL
|
||||
* @apiSuccess (Success 200) {String} createdBy Value of custom header X-SOGo-Component-Created-By or organizer's "SENT-BY"
|
||||
* @apiSuccess (Success 200) {Number} priority Priority
|
||||
* @apiSuccess (Success 200) {NSString} classification Either public, confidential or private
|
||||
* @apiSuccess (Success 200) {String[]} [categories] Categories
|
||||
* @apiSuccess (Success 200) {Object} [organizer] Appointment organizer
|
||||
* @apiSuccess (Success 200) {String} organizer.name Organizer's name
|
||||
|
@ -705,32 +707,21 @@
|
|||
[co nameInContainer], @"id",
|
||||
[componentCalendar nameInContainer], @"pid",
|
||||
[componentCalendar displayName], @"calendar",
|
||||
[dateFormatter formattedDate: eventStartDate], @"startDate",
|
||||
[self formattedDateString: eventStartDate], @"startDate",
|
||||
[dateFormatter formattedDate: eventStartDate], @"localizedStartDate",
|
||||
[dateFormatter formattedTime: eventStartDate], @"startTime",
|
||||
[dateFormatter formattedDate: eventEndDate], @"endDate",
|
||||
[self formattedDateString: eventEndDate], @"endDate",
|
||||
[dateFormatter formattedDate: eventEndDate], @"localizedEndDate",
|
||||
[dateFormatter formattedTime: eventEndDate], @"endTime",
|
||||
[NSNumber numberWithBool: [event isAllDay]], @"isAllDay",
|
||||
[NSNumber numberWithBool: ![event isOpaque]], @"isTransparent",
|
||||
nil];
|
||||
|
||||
// Add attributes from iCalEntityObject+SOGo and iCalRepeatableEntityObject+SOGo
|
||||
// Add attributes from iCalEvent+SOGo, iCalEntityObject+SOGo and iCalRepeatableEntityObject+SOGo
|
||||
[data addEntriesFromDictionary: [event attributes]];
|
||||
|
||||
// Return JSON representation
|
||||
return [self responseWithStatus: 200 andJSONRepresentation: data];
|
||||
}
|
||||
|
||||
- (BOOL) shouldTakeValuesFromRequest: (WORequest *) request
|
||||
inContext: (WOContext*) context
|
||||
{
|
||||
NSString *actionName;
|
||||
|
||||
actionName = [[request requestHandlerPath] lastPathComponent];
|
||||
|
||||
return ([[self clientObject] conformsToProtocol: @protocol (SOGoComponentOccurence)]
|
||||
&& ([actionName hasPrefix: @"save"] || [actionName hasPrefix: @"rsvp"]));
|
||||
}
|
||||
|
||||
- (void) takeValuesFromRequest: (WORequest *) _rq
|
||||
inContext: (WOContext *) _ctx
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue