From 72c2de38dd7bb3c8a7e27b6f1590488fe6043e98 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Fri, 8 Feb 2008 16:21:28 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1364 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 18 ++ .../Appointments/SOGoAppointmentFolders.m | 100 +++++++ SoObjects/Mailer/SOGoMailAccount.m | 4 +- SoObjects/Mailer/SOGoMailBaseObject.h | 2 +- SoObjects/Mailer/SOGoMailBaseObject.m | 24 +- SoObjects/Mailer/SOGoMailBodyPart.m | 2 +- SoObjects/Mailer/SOGoMailObject.m | 2 +- SoObjects/SOGo/SOGoObject.m | 12 + SoObjects/SOGo/SOGoUserFolder.m | 44 +-- UI/WebServerResources/UIxRecurrenceEditor.js | 263 ++++++++++-------- 10 files changed, 321 insertions(+), 150 deletions(-) diff --git a/ChangeLog b/ChangeLog index 84bb6628..8cd7fe1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2008-02-08 Wolfgang Sourdeau + + * SoObjects/Mailer/SOGoMailAccount.m ([SOGoMailAccount + -_urlHostString]): replace "@" with %40 AFTER invoking + stringByEscapingURL. + + * SoObjects/Mailer/SOGoMailBaseObject.m ([SOGoMailBaseObject + -isBodyPartKey:key]): hacked a little bit to test for the length + of the key trimmed from its bordering digits. So if the key + contains only digits, we consider it to be a body part key. There + is room for improvement but we can consider this will be accurate + in 99.99% of the cases. Also, removed the context parameter which + was useless. + + * SoObjects/SOGo/SOGoObject.m ([SOGoObject + -davComplianceClassesInContext:localContext]): new method, + declaring "access-control" in the compliance classes. + 2008-02-07 Wolfgang Sourdeau * SoObjects/Mailer/SOGoMailAccount.m ([SOGoMailAccount diff --git a/SoObjects/Appointments/SOGoAppointmentFolders.m b/SoObjects/Appointments/SOGoAppointmentFolders.m index 151f66fc..dbb0277e 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolders.m +++ b/SoObjects/Appointments/SOGoAppointmentFolders.m @@ -20,6 +20,7 @@ * Boston, MA 02111-1307, USA. */ +#import #import #import "SOGoAppointmentFolder.h" @@ -43,4 +44,103 @@ return @"Personal calendar"; } +// /* CalDAV support */ +// - (NSArray *) davComplianceClassesInContext: (WOContext *) localContext +// { +// NSMutableArray *newClasses; + +// newClasses +// = [NSMutableArray arrayWithArray: +// [super davComplianceClassesInContext: localContext]]; +// [newClasses addObject: @"calendar-access"]; + +// return newClasses; +// } + +// - (NSArray *) davCalendarHomeSet +// { +// /* +// +// http://cal.example.com/home/bernard/calendars/ +// + +// Note: this is the *container* for calendar collections, not the +// collections itself. So for use its the home folder, the +// public folder and the groups folder. +// */ +// NSArray *tag; + +// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D", +// [self davURL], nil]; + +// return [NSArray arrayWithObject: tag]; +// } + +// - (NSArray *) davCalendarUserAddressSet +// { +// NSArray *tag, *allEmails; +// NSMutableArray *addresses; +// NSEnumerator *emails; +// NSString *currentEmail; + +// addresses = [NSMutableArray array]; + +// allEmails = [[context activeUser] allEmails]; +// emails = [allEmails objectEnumerator]; +// while ((currentEmail = [emails nextObject])) +// { +// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D", +// [NSString stringWithFormat: @"mailto:%@", currentEmail], +// nil]; +// [addresses addObject: tag]; +// } + +// return addresses; +// } + +// - (NSArray *) davCalendarScheduleInboxURL +// { +// NSArray *tag; + +// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D", +// [NSString stringWithFormat: @"%@personal/", [self davURL]], +// nil]; + +// return [NSArray arrayWithObject: tag]; +// } + +// - (NSString *) davCalendarScheduleOutboxURL +// { +// NSArray *tag; + +// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D", +// [NSString stringWithFormat: @"%@personal/", [self davURL]], +// nil]; + +// return [NSArray arrayWithObject: tag]; +// } + +// - (NSString *) davDropboxHomeURL +// { +// NSArray *tag; + +// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D", +// [NSString stringWithFormat: @"%@personal/", [self davURL]], +// nil]; + +// return [NSArray arrayWithObject: tag]; +// } + +// - (NSString *) davNotificationsURL +// { +// NSArray *tag; + +// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D", +// [NSString stringWithFormat: @"%@personal/", [self davURL]], +// nil]; + +// return [NSArray arrayWithObject: tag]; +// } + @end diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index 7270874e..976f3f98 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -256,8 +256,8 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default { username = [mailAccount objectForKey: @"userName"]; escUsername - = [[username stringByReplacingString: @"@" withString: @"%40"] - stringByEscapingURL]; + = [[username stringByEscapingURL] stringByReplacingString: @"@" + withString: @"%40"]; hostString = [NSString stringWithFormat: @"%@@%@", escUsername, [mailAccount objectForKey: @"serverName"]]; } diff --git a/SoObjects/Mailer/SOGoMailBaseObject.h b/SoObjects/Mailer/SOGoMailBaseObject.h index 1faecb77..8d596742 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.h +++ b/SoObjects/Mailer/SOGoMailBaseObject.h @@ -74,7 +74,7 @@ /* IMAP4 names */ -- (BOOL) isBodyPartKey: (NSString *) _key inContext: (id) _ctx; +- (BOOL) isBodyPartKey: (NSString *) key; @end diff --git a/SoObjects/Mailer/SOGoMailBaseObject.m b/SoObjects/Mailer/SOGoMailBaseObject.m index ebe59462..cfeda797 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SoObjects/Mailer/SOGoMailBaseObject.m @@ -19,6 +19,9 @@ 02111-1307, USA. */ +#import +#import + #import #import #import @@ -205,18 +208,15 @@ static BOOL debugOn = YES; /* IMAP4 names */ -- (BOOL)isBodyPartKey:(NSString *)_key inContext:(id)_ctx { - /* - Every key starting with a digit is considered an IMAP4 mime part key, used in - SOGoMailObject and SOGoMailBodyPart. - */ - if ([_key length] == 0) - return NO; - - if (isdigit([_key characterAtIndex:0])) - return YES; - - return NO; +#warning we could improve this by simply testing if the reference is the filename of an attachment or if the body part mentionned actually exists in the list of body parts. Another way is to use a prefix such as "attachment-*" to declare attachments. +- (BOOL) isBodyPartKey: (NSString *) key +{ + NSString *trimmedKey; + + trimmedKey = [key stringByTrimmingCharactersInSet: + [NSCharacterSet decimalDigitCharacterSet]]; + + return (![trimmedKey length]); } - (NSArray *) aclsForUser: (NSString *) uid diff --git a/SoObjects/Mailer/SOGoMailBodyPart.m b/SoObjects/Mailer/SOGoMailBodyPart.m index 970abbb8..3afd10e0 100644 --- a/SoObjects/Mailer/SOGoMailBodyPart.m +++ b/SoObjects/Mailer/SOGoMailBodyPart.m @@ -206,7 +206,7 @@ static BOOL debugOn = NO; if (!obj) { /* lookup body part */ - if ([self isBodyPartKey:_key inContext:_ctx]) + if ([self isBodyPartKey:_key]) obj = [self lookupImap4BodyPartKey:_key inContext:_ctx]; else if ([_key isEqualToString: @"asAttachment"]) [self setAsAttachment]; diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index ec0c2803..d1493a50 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -866,7 +866,7 @@ static BOOL debugSoParts = NO; /* lookup body part */ - if ([self isBodyPartKey:_key inContext:_ctx]) { + if ([self isBodyPartKey:_key]) { if ((obj = [self lookupImap4BodyPartKey:_key inContext:_ctx]) != nil) { if (debugSoParts) [self logWithFormat: @"mail looked up part %@: %@", _key, obj]; diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 9c5fbcee..748461d9 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -1099,4 +1099,16 @@ static BOOL kontactGroupDAV = YES; [self nameInContainer]]; } +- (NSArray *) davComplianceClassesInContext: (WOContext *) localContext +{ + NSMutableArray *newClasses; + + newClasses + = [NSMutableArray arrayWithArray: + [super davComplianceClassesInContext: localContext]]; + [newClasses addObject: @"access-control"]; + + return newClasses; +} + @end /* SOGoObject */ diff --git a/SoObjects/SOGo/SOGoUserFolder.m b/SoObjects/SOGo/SOGoUserFolder.m index efd551e7..1df3b304 100644 --- a/SoObjects/SOGo/SOGoUserFolder.m +++ b/SoObjects/SOGo/SOGoUserFolder.m @@ -462,28 +462,28 @@ return YES; } -/* CalDAV support */ -- (NSArray *) davCalendarHomeSet -{ - /* - - http://cal.example.com/home/bernard/calendars/ - - - Note: this is the *container* for calendar collections, not the - collections itself. So for use its the home folder, the - public folder and the groups folder. - */ - NSArray *tag; - SOGoAppointmentFolders *parent; - - parent = [self privateCalendars: @"Calendar" inContext: context]; - tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D", - [parent davURL], nil]; - - return [NSArray arrayWithObject: tag]; -} +// /* CalDAV support */ +// - (NSArray *) davCalendarHomeSet +// { +// /* +// +// http://cal.example.com/home/bernard/calendars/ +// + +// Note: this is the *container* for calendar collections, not the +// collections itself. So for use its the home folder, the +// public folder and the groups folder. +// */ +// NSArray *tag; +// SOGoAppointmentFolders *parent; + +// parent = [self privateCalendars: @"Calendar" inContext: context]; +// tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D", +// [parent davURL], nil]; + +// return [NSArray arrayWithObject: tag]; +// } // - (NSArray *) davCalendarUserAddressSet // { diff --git a/UI/WebServerResources/UIxRecurrenceEditor.js b/UI/WebServerResources/UIxRecurrenceEditor.js index 06856f57..24364984 100644 --- a/UI/WebServerResources/UIxRecurrenceEditor.js +++ b/UI/WebServerResources/UIxRecurrenceEditor.js @@ -3,9 +3,9 @@ var RecurrenceEditor = { currentRepeatType: 0 } -function onRepeatTypeChange(event) { - setRepeatType(parseInt(this.value)); -} + function onRepeatTypeChange(event) { + setRepeatType(parseInt(this.value)); + } function setRepeatType(type) { var elements; @@ -29,7 +29,7 @@ function getSelectedDays(element) { var elementsArray = $A(element.getElementsByTagName('DIV')); var days = new Array(); elementsArray.each(function(item) { - if (isNodeSelected(item)) + if (isNodeSelected(item)) days.push(item.readAttribute("name")); }); return days.join(","); @@ -62,13 +62,15 @@ function initializeSelectors() { } function initializeWindowButtons() { - var okButton = $("okButton"); - var cancelButton = $("cancelButton"); + var okButton = $("okButton"); + var cancelButton = $("cancelButton"); - Event.observe(okButton, "click", onEditorOkClick, false); - Event.observe(cancelButton, "click", onEditorCancelClick, false); + Event.observe(okButton, "click", onEditorOkClick, false); + Event.observe(cancelButton, "click", onEditorCancelClick, false); - $("repeatType").observe("change", onRepeatTypeChange, false); + var repeatType = $("repeatType"); + setRepeatType(parseInt(repeatType.value)); + repeatType.observe("change", onRepeatTypeChange, false); } function initializeFormValues() { @@ -145,112 +147,151 @@ function initializeFormValues() { $("range_of_recurrence").show(); } +function handleDailyRecurrence() { + var validate = false; + + var radioValue = $('recurrence_form').getRadioValue('dailyRadioButtonName'); + + // We check if the dailyDaysField really contains an integer + if (radioValue == 0) { + var v = "" + $('dailyDaysField').value; + if (v.length > 0) { + v = parseInt(v); + if (isNaN(v) || v <= 1) + window.alert("Please specify a numerical value in the Days field greater or equal to 1."); + else + validate = true; + } + } + else + validate = true; + + if (validate) { + parent$("repeat1").value = radioValue; + parent$("repeat2").value = v; + } + + return validate; +} + +function handleWeeklyRecurrence() { + var validate = false; + + var fieldValue = "" + $('weeklyWeeksField').value; + + // We check if the weeklyWeeksField really contains an integer + var v = parseInt(fieldValue); + if (isNaN(v) || v <= 0) + window.alert("Please specify a numerical value in the Week(s) field greater or equal to 1."); + else { + validate = true; + parent$("repeat1").value = fieldValue; + parent$("repeat2").value = getSelectedDays($('week')); + } + + return validate; +} + +function handleMonthlyRecurrence() { + var validate = false; + + var radioValue = $('recurrence_form').getRadioValue('monthlyRadioButtonName'); + + // FIXME - right now we do not support rules + // such as The Second Tuesday... + if (radioValue == 0) + window.alert("This type of recurrence is currently unsupported."); + else { + // We check if the monthlyMonthsField really contains an integer + var fieldValue = $('monthlyMonthsField').value; + var v = parseInt(fieldValue); + if (isNaN(v) || v <= 0) + window.alert("Please specify a numerical value in the Month(s) field greater or equal to 1."); + else { + parent$("repeat1").value = fieldValue; + parent$("repeat2").value = radioValue; + parent$("repeat3").value = $('monthlyRepeat').value; + parent$("repeat4").value = $('monthlyDay').value; + parent$("repeat5").value = getSelectedDays($('month')); + } + } + + return validate; +} + +function handleYearlyRecurrence() { + var validate = true; + + parent$("repeat1").value = $('yearlyYearsField').value; + parent$("repeat2").value = $('recurrence_form').getRadioValue('yearlyRadioButtonName'); + parent$("repeat3").value = $('yearlyDayField').value; + parent$("repeat4").value = $('yearlyMonth1').value; + parent$("repeat5").value = $('yearlyRepeat').value; + parent$("repeat6").value = $('yearlyDay').value; + parent$("repeat7").value = $('yearlyMonth2').value; + + // FIXME - right now we do not support rules + // such as Every Second Tuesday of February + if (parent$("repeat2").value == 1) { + window.alert("This type of recurrence is currently unsupported."); + validate = false; + } + + // We check if the yearlyYearsField really contains an integer + var v = parseInt(parent$("repeat1").value); + if (isNaN(v) || v <= 0) { + window.alert("Please specify a numerical value in the Year(s) field greater or equal to 1."); + validate = false; + } + + return validate; +} + +function validateRange() { + var validate = true; + + var range = $('recurrence_form').getRadioValue('rangeRadioButtonName'); + parent$("range1").value = range; + + if (range == 1) { + parent$("range2").value = $('rangeAppointmentsField').value; + + // We check if the rangeAppointmentsField really contains an integer + var v = parseInt(parent$("range2").value); + if (isNaN(v) || v <= 0) { + window.alert("Please specify a numerical value in the Appointment(s) field greater or equal to 1."); + validate = false; + } + } + else if (range == 2) + parent$("range2").value = $('endDate_date').value; + + return validate; +} + function onEditorOkClick(event) { - preventDefault(event); - var repeatType = $("repeatType").value; - var v; - - parent$("repeatType").value = repeatType; - - if (repeatType == 0) { - // Repeat daily - v = $('recurrence_form').getRadioValue('dailyRadioButtonName') - parent$("repeat1").value = v; - - // We check if the dailyDaysField really contains an integer - if (v == 0) { - parent$("repeat2").value = $('dailyDaysField').value; - v = parseInt(parent$("repeat2").value); - if (isNaN(v) || v <= 0) { - window.alert("Please specify a numerical value in the Days field greater or equal to 1."); - return false; - } - } - } - else if (repeatType == 1) { - // Repeat weekly - v = $('weeklyWeeksField').value; - parent$("repeat1").value = v; - parent$("repeat2").value = getSelectedDays($('week')); - - // We check if the weeklyWeeksField really contains an integer - v = parseInt(v); - if (isNaN(v) || v <= 0) { - window.alert("Please specify a numerical value in the Week(s) field greater or equal to 1."); - return false; - } - } - else if (repeatType == 2) { - // Repeat monthly - v = $('monthlyMonthsField').value; - parent$("repeat1").value = v; - parent$("repeat2").value = $('recurrence_form').getRadioValue('monthlyRadioButtonName'); - parent$("repeat3").value = $('monthlyRepeat').value; - parent$("repeat4").value = $('monthlyDay').value; - parent$("repeat5").value = getSelectedDays($('month')); - - // FIXME - right now we do not support rules - // such as The Second Tuesday... - if (parent$("repeat2").value == 0) { - window.alert("This type of recurrence is currently unsupported."); - return false; - } - - // We check if the monthlyMonthsField really contains an integer - v = parseInt(v); - if (isNaN(v) || v <= 0) { - window.alert("Please specify a numerical value in the Month(s) field greater or equal to 1."); - return false; - } - } - else { - // Repeat yearly - parent$("repeat1").value = $('yearlyYearsField').value; - parent$("repeat2").value = $('recurrence_form').getRadioValue('yearlyRadioButtonName'); - parent$("repeat3").value = $('yearlyDayField').value; - parent$("repeat4").value = $('yearlyMonth1').value; - parent$("repeat5").value = $('yearlyRepeat').value; - parent$("repeat6").value = $('yearlyDay').value; - parent$("repeat7").value = $('yearlyMonth2').value; - - // FIXME - right now we do not support rules - // such as Every Second Tuesday of February - if (parent$("repeat2").value == 1) { - window.alert("This type of recurrence is currently unsupported."); - return false; - } - - // We check if the yearlyYearsField really contains an integer - v = parseInt(parent$("repeat1").value); - if (isNaN(v) || v <= 0) { - window.alert("Please specify a numerical value in the Year(s) field greater or equal to 1."); - return false; - } - } - - var range = $('recurrence_form').getRadioValue('rangeRadioButtonName'); - parent$("range1").value = range; - - if (range == 1) { - parent$("range2").value = $('rangeAppointmentsField').value; - - // We check if the rangeAppointmentsField really contains an integer - v = parseInt(parent$("range2").value); - if (isNaN(v) || v <= 0) { - window.alert("Please specify a numerical value in the Appointment(s) field greater or equal to 1."); - return false; - } - } - else if (range == 2) { - parent$("range2").value = $('endDate_date').value; - } - - window.close(); + preventDefault(event); + var repeatType = $("repeatType").value; + parent$("repeatType").value = repeatType; + + var validate; + if (repeatType == 0) + validate = handleDailyRecurrence(); + else if (repeatType == 1) + validate = handleWeeklyRecurrence(); + else if (repeatType == 2) + validate = handleMonthlyRecurrence(); + else + validate = handleYearlyRecurrence(); + + if (validate + && validateRange()) + window.close(); } function onEditorCancelClick(event) { - preventDefault(event); - window.close(); + preventDefault(event); + window.close(); } function onRecurrenceLoadHandler() { -- 2.39.5