mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-21 11:25:24 +00:00
Fixed issues, ajaxified import process
Monotone-Parent: 80ad9ff70fe3d4130d99bbd2590349b71c85b9f3 Monotone-Revision: 33b6c38a250d6ae49e26dd7de548708c132d5c34 Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-09-03T17:53:38 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -20,6 +20,11 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <SoObjects/SOGo/NSArray+Utilities.h>
|
||||
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
|
||||
#import <SoObjects/SOGo/NSString+Utilities.h>
|
||||
|
||||
#import <NGObjWeb/SoSecurityManager.h>
|
||||
#import <NGObjWeb/SoUser.h>
|
||||
#import <NGObjWeb/WOResponse.h>
|
||||
@@ -697,20 +702,25 @@ static BOOL shouldDisplayWeekend = NO;
|
||||
- (WOResponse *) importAction
|
||||
{
|
||||
SOGoAppointmentFolder *folder;
|
||||
NSMutableDictionary *rc;
|
||||
NSArray *components;
|
||||
WORequest *request;
|
||||
WOResponse *response;
|
||||
NSString *fileContent;
|
||||
NSData *data;
|
||||
iCalCalendar *additions;
|
||||
int i, count;
|
||||
int i, count, imported;
|
||||
|
||||
imported = 0;
|
||||
rc = [NSMutableDictionary dictionary];
|
||||
request = [context request];
|
||||
folder = [self clientObject];
|
||||
data = (NSData *)[request formValueForKey: @"calendarFile"];
|
||||
fileContent = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
|
||||
[fileContent autorelease];
|
||||
|
||||
if (fileContent && [fileContent length])
|
||||
if (fileContent && [fileContent length]
|
||||
&& [fileContent hasPrefix: @"BEGIN:"])
|
||||
{
|
||||
additions = [iCalCalendar parseSingleFromSource: fileContent];
|
||||
if (additions)
|
||||
@@ -718,22 +728,39 @@ static BOOL shouldDisplayWeekend = NO;
|
||||
components = [additions events];
|
||||
count = [components count];
|
||||
for (i = 0; i < count; i++)
|
||||
[folder importComponent: [components objectAtIndex: i]];
|
||||
if ([folder importComponent: [components objectAtIndex: i]])
|
||||
imported++;
|
||||
components = [additions todos];
|
||||
count = [components count];
|
||||
for (i = 0; i < count; i++)
|
||||
[folder importComponent: [components objectAtIndex: i]];
|
||||
if ([folder importComponent: [components objectAtIndex: i]])
|
||||
imported++;
|
||||
components = [additions journals];
|
||||
count = [components count];
|
||||
for (i = 0; i < count; i++)
|
||||
[folder importComponent: [components objectAtIndex: i]];
|
||||
if ([folder importComponent: [components objectAtIndex: i]])
|
||||
imported++;
|
||||
components = [additions freeBusys];
|
||||
count = [components count];
|
||||
for (i = 0; i < count; i++)
|
||||
[folder importComponent: [components objectAtIndex: i]];
|
||||
if ([folder importComponent: [components objectAtIndex: i]])
|
||||
imported++;
|
||||
}
|
||||
}
|
||||
return [self redirectToLocation: @"../view"];
|
||||
|
||||
[rc setObject: [NSNumber numberWithInt: imported]
|
||||
forKey: @"imported"];
|
||||
if (imported <= 0)
|
||||
[rc setObject: [self labelForKey: @"An error occured while importing calendar."]
|
||||
forKey: @"message"];
|
||||
else
|
||||
[rc setObject: [NSString stringWithFormat: @"%@ %d",
|
||||
[self labelForKey: @"Imported events:"], imported]
|
||||
forKey: @"message"];
|
||||
|
||||
response = [self responseWithStatus: 200];
|
||||
[(WOResponse*)response appendContentString: [rc jsonRepresentation]];
|
||||
return response;
|
||||
}
|
||||
|
||||
@end /* UIxCalView */
|
||||
|
||||
Reference in New Issue
Block a user