diff --git a/UI/Scheduler/UIxAppointmentEditor.m b/UI/Scheduler/UIxAppointmentEditor.m index c9fad63ab..be2f8421a 100644 --- a/UI/Scheduler/UIxAppointmentEditor.m +++ b/UI/Scheduler/UIxAppointmentEditor.m @@ -548,6 +548,7 @@ * @apiSuccess (Success 200) {String} endDate End date (ISO8601) * @apiSuccess (Success 200) {String} localizedEndDate Formatted end date * @apiSuccess (Success 200) {String} [localizedEndTime] Formatted end time + * @apiSuccess (Success 200) {Number} isReadOnly 1 if event is read-only * * From [iCalEvent+SOGo attributes] * @@ -669,6 +670,7 @@ [co nameInContainer], @"id", [componentCalendar nameInContainer], @"pid", [componentCalendar displayName], @"calendar", + [NSNumber numberWithBool: [self isReadOnly]], @"isReadOnly", [dateFormatter formattedDate: eventStartDate], @"localizedStartDate", [dateFormatter formattedDate: eventEndDate], @"localizedEndDate", nil]; diff --git a/UI/Scheduler/UIxComponentEditor.h b/UI/Scheduler/UIxComponentEditor.h index 5ce3d5855..a9744ef30 100644 --- a/UI/Scheduler/UIxComponentEditor.h +++ b/UI/Scheduler/UIxComponentEditor.h @@ -29,10 +29,12 @@ @interface UIxComponentEditor : UIxComponent { + id item; iCalRepeatableEntityObject *component; SOGoAppointmentFolder *componentCalendar; } +- (BOOL) isReadOnly; - (void) setAttributes: (NSDictionary *) attributes; + (NSArray *) reminderValues; diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 81fff249b..9de1eb26f 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -714,93 +714,92 @@ static NSArray *reminderValues = nil; // // return toolbarFilename; //} -// -// -//- (int) ownerIsAttendee: (SOGoUser *) ownerUser -// andClientObject: (SOGoContentObject -// *) clientObject -//{ -// BOOL isOrganizer; -// iCalPerson *ownerAttendee; -// int rc; -// -// rc = 0; -// -// isOrganizer = [component userIsOrganizer: ownerUser]; -// if (isOrganizer) -// isOrganizer = ![ownerUser hasEmail: [[component organizer] sentBy]]; -// -// if (!isOrganizer && ![[component tag] isEqualToString: @"VTODO"]) -// { -// ownerAttendee = [component userAsAttendee: ownerUser]; -// if (ownerAttendee) -// rc = 1; -// } -// -// return rc; -//} -// -//- (int) delegateIsAttendee: (SOGoUser *) ownerUser -// andClientObject: (SOGoContentObject -// *) clientObject -//{ -// SoSecurityManager *sm; -// iCalPerson *ownerAttendee; -// int rc; -// -// rc = 0; -// -// sm = [SoSecurityManager sharedSecurityManager]; -// if (![sm validatePermission: SOGoCalendarPerm_ModifyComponent -// onObject: clientObject -// inContext: context]) -// rc = [self ownerIsAttendee: ownerUser -// andClientObject: clientObject]; -// else if (![sm validatePermission: SOGoCalendarPerm_RespondToComponent -// onObject: clientObject -// inContext: context]) -// { -// ownerAttendee = [component userAsAttendee: ownerUser]; -// if ([[ownerAttendee rsvp] isEqualToString: @"true"] -// && ![component userIsOrganizer: ownerUser]) -// rc = 1; -// else -// rc = 2; -// } -// else -// rc = 2; // not invited, just RO -// -// return rc; -//} -// -//- (int) getEventRWType -//{ -// SOGoContentObject *clientObject; -// SOGoUser *ownerUser; -// int rc; -// -// clientObject = [self clientObject]; -// ownerUser -// = [SOGoUser userWithLogin: [clientObject ownerInContext: context]]; -// if ([componentCalendar isKindOfClass: [SOGoWebAppointmentFolder class]]) -// rc = 2; -// else -// { -// if ([ownerUser isEqual: [context activeUser]]) -// rc = [self ownerIsAttendee: ownerUser -// andClientObject: clientObject]; -// else -// rc = [self delegateIsAttendee: ownerUser -// andClientObject: clientObject]; -// } -// -// return rc; -//} -// -//- (BOOL) eventIsReadOnly -//{ -// return [self getEventRWType] != 0; -//} + + +- (int) ownerIsAttendee: (SOGoUser *) ownerUser + andClientObject: (SOGoContentObject + *) clientObject +{ + BOOL isOrganizer; + iCalPerson *ownerAttendee; + int rc; + + rc = 0; + + isOrganizer = [component userIsOrganizer: ownerUser]; + if (isOrganizer) + isOrganizer = ![ownerUser hasEmail: [[component organizer] sentBy]]; + + if (!isOrganizer && ![[component tag] isEqualToString: @"VTODO"]) + { + ownerAttendee = [component userAsAttendee: ownerUser]; + if (ownerAttendee) + rc = 1; + } + + return rc; +} + +- (int) delegateIsAttendee: (SOGoUser *) ownerUser + andClientObject: (SOGoContentObject + *) clientObject +{ + SoSecurityManager *sm; + iCalPerson *ownerAttendee; + int rc; + + rc = 0; + + sm = [SoSecurityManager sharedSecurityManager]; + if (![sm validatePermission: SOGoCalendarPerm_ModifyComponent + onObject: clientObject + inContext: context]) + rc = [self ownerIsAttendee: ownerUser + andClientObject: clientObject]; + else if (![sm validatePermission: SOGoCalendarPerm_RespondToComponent + onObject: clientObject + inContext: context]) + { + ownerAttendee = [component userAsAttendee: ownerUser]; + if ([[ownerAttendee rsvp] isEqualToString: @"true"] + && ![component userIsOrganizer: ownerUser]) + rc = 1; + else + rc = 2; + } + else + rc = 2; // not invited, just RO + + return rc; +} + +- (int) getEventRWType +{ + SOGoContentObject *clientObject; + SOGoUser *ownerUser; + int rc; + + clientObject = [self clientObject]; + ownerUser = [SOGoUser userWithLogin: [clientObject ownerInContext: context]]; + if ([componentCalendar isKindOfClass: [SOGoWebAppointmentFolder class]]) + rc = 2; + else + { + if ([ownerUser isEqual: [context activeUser]]) + rc = [self ownerIsAttendee: ownerUser + andClientObject: clientObject]; + else + rc = [self delegateIsAttendee: ownerUser + andClientObject: clientObject]; + } + + return rc; +} + +- (BOOL) isReadOnly +{ + return [self getEventRWType] != 0; +} // //- (NSString *) emailAlarmsEnabled //{ diff --git a/UI/Scheduler/UIxTaskEditor.m b/UI/Scheduler/UIxTaskEditor.m index c3c74a445..75aa6e507 100644 --- a/UI/Scheduler/UIxTaskEditor.m +++ b/UI/Scheduler/UIxTaskEditor.m @@ -402,6 +402,7 @@ * @apiSuccess (Success 200) {String} completedTime Formatted completed time * @apiSuccess (Success 200) {String} status Status (needs-action, in-process, completed, or cancelled) * @apiSuccess (Success 200) {Number} percentComplete Percent completion + * @apiSuccess (Success 200) {Number} isReadOnly 1 if task is read-only * * From [iCalEntityObject+SOGo attributes] * @@ -519,6 +520,7 @@ [co nameInContainer], @"id", [thisFolder nameInContainer], @"pid", [thisFolder displayName], @"calendar", + [NSNumber numberWithBool: [self isReadOnly]], @"isReadOnly", nil]; if (startDate)