]> err.no Git - scalable-opengroupware.org/commitdiff
improved error handling in mail-view
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 6 Jul 2005 15:50:40 +0000 (15:50 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 6 Jul 2005 15:50:40 +0000 (15:50 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@670 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/UI/MailerUI/ChangeLog
SOGo/UI/MailerUI/README
SOGo/UI/MailerUI/UIxMailMainFrame.m
SOGo/UI/MailerUI/UIxMailView.m
SOGo/UI/Templates/MailerUI/UIxMailMainFrame.wox

index 48862a75ae16797b9bda14106aa10c84bb966e46..ce1bdbb7a498d9e3ee8c933ecad04fa7d223d3ba 100644 (file)
@@ -1,3 +1,14 @@
+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
index 60b6beb3bee32869dec774cbc50859ada8972a09..7d61fac70e568d3a823dc8fff4082af42f122ce3 100644 (file)
@@ -20,6 +20,45 @@ UIxMailMainFrame.wox
 UIxMailTree.wox
 UIxMailView.wox
 
+Class Hierarchy
+===============
+
+[NSObject]
+  MailerUIProduct
+  [WOComponent]
+    [SoComponent]
+      <UIxComponent>
+        UIxFilterList
+        UIxMailAccountView
+        UIxMailAccountsView
+        UIxMailAddressbook
+        UIxMailEditor
+        (Scheduler_Privates)
+        UIxMailListView
+        UIxMailMainFrame
+        UIxMailToSelection
+        UIxMailToolbar
+        UIxMailTree
+        UIxMailView
+        UIxSieveEditor
+      UIxMailSortableTableHeader
+    UIxMailEditorAttach.m
+    UIxMailFilterPanel
+    UIxMailMoveToPopUp
+    UIxMailWindowCloser
+  [WODirectAction]
+    UIxMailEditorAction
+      UIxMailForwardAction
+      UIxMailReplyAction
+  [NSFormatter]
+    UIxMailFormatter
+      UIxMailDateFormatter
+      UIxSubjectFormatter
+      UIxEnvelopeAddressFormatter
+  UIxMailTreeBlock
+  [WOContext]
+    (UIxMailer)
+
 Defaults
 ========
 
index 1917e7c4a5ac6274f8a8b13a8f88b5ba747953ff..5a4ced7efc54d83ccfe2f00874a97ba214c3bbe2 100644 (file)
@@ -158,4 +158,30 @@ static NSString *treeRootClassName = nil;
   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 */
index 917feebe67b2777b0ca4d41e5f891cc45b226c52..ffe89b1101fde8bbeefeddf2116c3320dbcd9ea0 100644 (file)
   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 {
index 6e80dcf96b205f0308c64d3f32e32bb18752b4df..8b1834156c9cf91527a06e103bf2740ac682a41a 100644 (file)
@@ -91,6 +91,8 @@
       </tr>
     </table>
    </form>
+
+   <var:string value="errorAlertJavaScript" const:escapeHTML="NO" />
   </body>
 </html>
    </var:if>