+2005-07-06 Helge Hess <helge.hess@opengroupware.org>
+
+ * v0.9.124
+
+ * UIxMailView.m: improved error handling in case the delete flag could
+ not be set
+
+ * UIxMailMainFrame.m: added -hasErrorText / -errorText /
+ -errorAlertJavaScript methods to deal with errors encoded in the
+ 'error' form parameter
+
2005-03-24 Helge Hess <helge.hess@opengroupware.org>
* v0.9.123
return [[self userRootURL] stringByAppendingString:@"Contacts/"];
}
+/* error handling */
+
+- (BOOL)hasErrorText {
+ return [[[[self context] request] formValueForKey:@"error"] length] > 0
+ ? YES : NO;
+}
+- (NSString *)errorText {
+ return [[[self context] request] formValueForKey:@"error"];
+}
+
+- (NSString *)errorAlertJavaScript {
+ NSString *errorText;
+
+ if ([(errorText = [self errorText]) length] == 0)
+ return nil;
+
+ // TODO: proper JavaScript escaping
+ errorText = [errorText stringByEscapingHTMLString];
+ errorText = [errorText stringByReplacingString:@"\"" withString:@"'"];
+
+ return [NSString stringWithFormat:
+ @"<script language=\"JavaScript\">"
+ @"alert(\"%@\");"
+ @"</script>", errorText];
+}
+
@end /* UIxMailMainFrame */
return NO;
}
+- (id)redirectToParentFolder {
+ id url;
+
+ url = [[[self clientObject] container] baseURLInContext:[self context]];
+ return [self redirectToLocation:url];
+}
+
- (id)deleteAction {
NSException *ex;
-
+
if (![self isDeletableClientObject]) {
return [NSException exceptionWithHTTPStatus:400 /* Bad Request */
reason:@"method cannot be invoked on "
@"the specified object"];
}
+ if ([self isInvokedBySafeMethod]) {
+ // TODO: fix UI to use POST for unsafe actions
+ [self logWithFormat:@"WARNING: method is invoked using safe HTTP method!"];
+ }
+
if ((ex = [[self clientObject] delete]) != nil) {
// TODO: improve error handling
+ id url;
+
[self debugWithFormat:@"failed to delete: %@", ex];
- return ex;
+
+ url = [[ex reason] stringByEscapingURL];
+ url = [@"view?error=" stringByAppendingString:url];
+ return [self redirectToLocation:url];
+ //return ex;
}
if (![self isInlineViewer]) {
[page takeValue:@"YES" forKey:@"refreshOpener"];
return page;
}
- else {
- id url;
-
- url = [[[self clientObject] container] baseURLInContext:[self context]];
- return [self redirectToLocation:url];
- }
+
+ return [self redirectToParentFolder];
}
- (id)getMailAction {