From: helge Date: Tue, 2 Aug 2005 10:26:15 +0000 (+0000) Subject: moved partstat modification from UI to SoObject X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd19d96034d9beeb9db8d5d04f74a98a3dc7daac;p=scalable-opengroupware.org moved partstat modification from UI to SoObject git-svn-id: http://svn.opengroupware.org/SOGo/trunk@936 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SoObjects/Appointments/ChangeLog b/SoObjects/Appointments/ChangeLog index 7dd19f54..fed2c28b 100644 --- a/SoObjects/Appointments/ChangeLog +++ b/SoObjects/Appointments/ChangeLog @@ -1,3 +1,8 @@ +2005-08-02 Helge Hess + + * SOGoAppointmentObject.[hm]: added method to change participation + status of logged-in user (v0.9.50) + 2005-07-21 Marcus Mueller * SOGoAppointmentFolder.m: place a hint ('isRecurrent') into flattened diff --git a/SoObjects/Appointments/SOGoAppointmentObject.h b/SoObjects/Appointments/SOGoAppointmentObject.h index e7cedb72..ef2280c8 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.h +++ b/SoObjects/Appointments/SOGoAppointmentObject.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 SKYRIX Software AG + Copyright (C) 2004-2005 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __Appointments_SOGoAppointmentObject_H__ #define __Appointments_SOGoAppointmentObject_H__ @@ -65,6 +64,9 @@ - (NSException *)saveContentString:(NSString *)_iCalString; - (NSException *)delete; +- (NSException *)changeParticipationStatus:(NSString *)_status + inContext:(id)_ctx; + @end #endif /* __Appointments_SOGoAppointmentObject_H__ */ diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 7c1779f8..a563ceed 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -492,6 +492,52 @@ static NSString *mailTemplateDefaultLanguage = nil; return [self deleteWithBaseSequence:0]; } + +- (NSException *)changeParticipationStatus:(NSString *)_status + inContext:(id)_ctx +{ + SOGoAppointment *apt; + iCalPerson *p; + NSString *newContent; + NSException *ex; + NSString *myEMail; + + // TODO: do we need to use SOGoAppointment? (prefer iCalEvent?) + apt = [[SOGoAppointment alloc] initWithICalString:[self iCalString]]; + if (apt == nil) { + return [NSException exceptionWithHTTPStatus:500 /* Server Error */ + reason:@"unable to parse appointment record"]; + } + + myEMail = [[_ctx activeUser] email]; + if ((p = [apt findParticipantWithEmail:myEMail]) == nil) { + return [NSException exceptionWithHTTPStatus:404 /* Not Found */ + reason:@"user does not participate in this " + @"appointment"]; + } + + [p setPartStat:_status]; + newContent = [[[apt iCalString] copy] autorelease]; + + // TODO: send iMIP reply mails? + + [apt release]; apt = nil; + + if (newContent == nil) { + return [NSException exceptionWithHTTPStatus:500 /* Server Error */ + reason:@"Could not generate iCalendar data ..."]; + } + + if ((ex = [self saveContentString:newContent]) != nil) { + // TODO: why is the exception wrapped? + return [NSException exceptionWithHTTPStatus:500 /* Server Error */ + reason:[ex reason]]; + } + + return nil /* means: no error */; +} + + /* message type */ - (NSString *)outlookMessageClass { diff --git a/SoObjects/Appointments/Version b/SoObjects/Appointments/Version index c0a8a3e8..58ecf6d2 100644 --- a/SoObjects/Appointments/Version +++ b/SoObjects/Appointments/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=49 +SUBMINOR_VERSION:=50 # v0.9.42 requires libSOGo v0.9.54 # v0.9.32 requires libGDLContentStore v4.5.26 diff --git a/UI/Scheduler/ChangeLog b/UI/Scheduler/ChangeLog index 77d57ed6..91381651 100644 --- a/UI/Scheduler/ChangeLog +++ b/UI/Scheduler/ChangeLog @@ -1,3 +1,11 @@ +2005-08-02 Helge Hess + + * v0.9.147 + + * UIxComponent+Agenor.m: use SOGoUser methods to get email/cn + + * UIxAppointmentEditor.m: moved status change operation to SoObject + 2005-07-23 Helge Hess * UIxAppointmentPrintview.m, UIxCalDayListview.m: fixed include pathes diff --git a/UI/Scheduler/UIxAppointmentEditor.m b/UI/Scheduler/UIxAppointmentEditor.m index d0a12451..676a125d 100644 --- a/UI/Scheduler/UIxAppointmentEditor.m +++ b/UI/Scheduler/UIxAppointmentEditor.m @@ -749,6 +749,20 @@ respondsToSelector:@selector(saveContentString:)]; } +- (NSException *)validateObjectForStatusChange { + BOOL ok; + id co; + + co = [self clientObject]; + ok = [co respondsToSelector:@selector(changeParticipationStatus:inContext:)]; + if (!ok) { + return [NSException exceptionWithHTTPStatus:400 /* Bad Request */ + reason: + @"method cannot be invoked on the specified object"]; + } + return nil; +} + - (void)loadValuesFromAppointment:(SOGoAppointment *)_appointment { NSString *s; iCalRecurrenceRule *rrule; @@ -1053,53 +1067,15 @@ - (id)acceptOrDeclineAction:(BOOL)_accept { // TODO: this should live in the SoObjects - SOGoAppointment *apt; - iCalPerson *p; - NSString *iCal, *content; - NSException *ex; - - if (![self isWriteableClientObject]) { - /* 400 == Bad Request */ - return [NSException exceptionWithHTTPStatus:400 - reason:@"method cannot be invoked on " - @"the specified object"]; - } - iCal = [[self clientObject] valueForKey:@"iCalString"]; - apt = [[SOGoAppointment alloc] initWithICalString:iCal]; - if (apt == nil) { - /* 500 == Internal Server Error */ - return [NSException exceptionWithHTTPStatus:500 - reason:@"unable to parse appointment"]; - } - - if ((p = [apt findParticipantWithEmail:[self emailForUser]]) == nil) { - /* 404 == Not found */ - return [NSException exceptionWithHTTPStatus:404 - reason:@"user does not participate in this " - @"appointment"]; - } + NSException *ex; - // TODO: add tentative - if (_accept) - [p setParticipationStatus:iCalPersonPartStatAccepted]; - else - [p setParticipationStatus:iCalPersonPartStatDeclined]; - - content = [apt iCalString]; - [apt release]; - - if (content == nil) { - /* 500 == Internal Server Error */ - return [NSException exceptionWithHTTPStatus:500 - reason:@"Could not create iCalendar data ..."]; - } + if ((ex = [self validateObjectForStatusChange]) != nil) + return ex; - ex = [[self clientObject] saveContentString:content]; - if (ex != nil) { - /* 500 == Internal Server Error */ - return [NSException exceptionWithHTTPStatus:500 - reason:[ex reason]]; - } + ex = [[self clientObject] changeParticipationStatus: + _accept ? @"ACCEPTED" : @"DECLINED" + inContext:[self context]]; + if (ex != nil) return ex; return [self redirectToLocation:[self _completeURIForMethod:@"../view"]]; } diff --git a/UI/Scheduler/UIxComponent+Agenor.m b/UI/Scheduler/UIxComponent+Agenor.m index 9e3ae273..216dbc02 100644 --- a/UI/Scheduler/UIxComponent+Agenor.m +++ b/UI/Scheduler/UIxComponent+Agenor.m @@ -22,22 +22,17 @@ #include "UIxComponent+Agenor.h" #include #include +#include #include "common.h" @implementation UIxComponent(Agenor) - (NSString *)emailForUser { - NSString *uid; - - uid = [[self user] login]; - return [[AgenorUserManager sharedUserManager] getEmailForUID:uid]; + return [[[self context] activeUser] email]; } - (NSString *)cnForUser { - NSString *uid; - - uid = [[self user] login]; - return [[AgenorUserManager sharedUserManager] getCNForUID:uid]; + return [[[self context] activeUser] cn]; } - (BOOL)isAccessRestricted { diff --git a/UI/Scheduler/Version b/UI/Scheduler/Version index 6a20f8b8..03b6d385 100644 --- a/UI/Scheduler/Version +++ b/UI/Scheduler/Version @@ -1,7 +1,8 @@ # Version file -SUBMINOR_VERSION:=146 +SUBMINOR_VERSION:=147 +# v0.9.147 requires Appointments v0.9.50 # v0.9.136 requires SOGoUI v0.9.30 # v0.9.123 requires Appointments v0.9.35 # v0.9.123 requires SOGoUI v0.9.24 diff --git a/UI/Templates/MailerUI/UIxMailTree.wox b/UI/Templates/MailerUI/UIxMailTree.wox index f88e16ff..5f940b32 100644 --- a/UI/Templates/MailerUI/UIxMailTree.wox +++ b/UI/Templates/MailerUI/UIxMailTree.wox @@ -22,7 +22,8 @@ const:spaceIcon = "tbtv_space_17x17.gif" > + var:icon="item.iconName" + var:cornerIcon="item.iconName">