]> err.no Git - scalable-opengroupware.org/commitdiff
added support for a create-folder button at the account folder
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 18 Jul 2005 14:38:21 +0000 (14:38 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 18 Jul 2005 14:38:21 +0000 (14:38 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@793 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/UI/MailerUI/ChangeLog
SOGo/UI/MailerUI/UIxMailAccountView.m
SOGo/UI/MailerUI/UIxMailListView.m
SOGo/UI/MailerUI/Version
SOGo/UI/MailerUI/product.plist

index 99375a36cb66ae7097b71b3f816e922e15ccd1d3..6c372729b412e759d376bba108ae1f040e32ef66 100644 (file)
@@ -1,3 +1,10 @@
+2005-07-18  Helge Hess  <helge.hess@opengroupware.org>
+
+       * UIxMailAccountView.m: added method to check whether folder-create
+         button should be visible on the account folder view (checks INBOX for
+         the ACL, does check the alt-namespace default),
+         added method for folder-creation in root (v0.9.148)
+
 2005-07-18  Marcus Mueller  <znek@mulle-kybernetik.com>
 
         * v0.9.147
index 8042d15a1e82140775ed7f96088e42e40a5264e5..f6377686ad95bfcf84af1da187939b4a2f85371c 100644 (file)
 
 @interface UIxMailAccountView : UIxComponent
 {
+  id inbox;
 }
 
 @end
 
+#include <NGObjWeb/SoObject+SoDAV.h>
 #include "common.h"
 
 @interface NSString(DotCutting)
 
 @implementation UIxMailAccountView
 
+static BOOL useAltNamespace = NO;
+
++ (void)initialize {
+  NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+  
+  useAltNamespace = [ud boolForKey:@"SOGoSpecialFoldersInRoot"];
+}
+
+- (void)dealloc {
+  [self->inbox release];
+  [super dealloc];
+}
+
+/* notifications */
+
+- (void)sleep {
+  [super sleep];
+  [self->inbox release]; self->inbox = nil;
+}
+
 /* title */
 
 - (NSString *)objectTitle {
   return s;
 }
 
+- (BOOL)showFolderCreateButton {
+  if (!useAltNamespace) {
+    /* in a regular configuration everything must be created below INBOX */
+    return NO;
+  }
+  
+  /* 
+     A hack to manually check whether we have permission to create folders at
+     the root level. We do this by checking the permissions on the INBOX
+     folder (which is technically the root in Cyrus).
+     
+     See OGo bug #1472 for details.
+  */
+  
+  if (self->inbox == nil) {
+    id tmp;
+    
+    tmp = [[self clientObject] lookupName:@"INBOX" 
+                              inContext:[self context]
+                              acquire:NO];
+    if ([tmp isKindOfClass:[NSException class]] || tmp == nil)
+      tmp = [NSNull null];
+    
+    self->inbox = [tmp retain];
+  }
+  
+  if (![self->inbox isNotNull]) {
+    [self warnWithFormat:@"Found no INBOX folder!"];
+    return NO;
+  }
+  
+  return [self->inbox isCreateAllowed];
+}
+
+/* error redirects */
+
+- (id)redirectToViewWithError:(id)_error {
+  // TODO: DUP to UIxMailListView
+  // TODO: improve, localize
+  // TODO: there is a bug in the treeview which preserves the current URL for
+  //       the active object (displaying the error again)
+  id url;
+  
+  if (![_error isNotNull])
+    return [self redirectToLocation:@"view"];
+  
+  if ([_error isKindOfClass:[NSException class]])
+    _error = [_error reason];
+  else if ([_error isKindOfClass:[NSString class]])
+    _error = [_error stringValue];
+  
+  url = [_error stringByEscapingURL];
+  url = [@"view?error=" stringByAppendingString:url];
+  return [self redirectToLocation:url];
+}
+
+/* actions */
+
+- (id)createFolderAction {
+  NSException *error;
+  NSString    *folderName;
+  id client;
+  
+  folderName = [[[self context] request] formValueForKey:@"name"];
+  if ([folderName length] == 0) {
+    error = [NSException exceptionWithHTTPStatus:400 /* Bad Request */
+                        reason:@"missing 'name' query parameter!"];
+    return [self redirectToViewWithError:error];
+  }
+  
+  if ((client = [self clientObject]) == nil) {
+    error = [NSException exceptionWithHTTPStatus:404 /* Not Found */
+                        reason:@"did not find mail folder"];
+    return [self redirectToViewWithError:error];
+  }
+  
+  if ((error = [[self clientObject] davCreateCollection:folderName
+                                   inContext:[self context]]) != nil) {
+    return [self redirectToViewWithError:error];
+  }
+  
+  return [self redirectToLocation:[folderName stringByAppendingString:@"/"]];
+}
+
 @end /* UIxMailAccountView */
index 0963ce34262428962c5f7dc4b0e2556c57e42c60..15ec1aab5467f74372a55f7e1918eaeaf4ed8eb5 100644 (file)
@@ -428,6 +428,7 @@ static int attachmentFlagSize = 8096;
 /* error redirects */
 
 - (id)redirectToViewWithError:(id)_error {
+  // TODO: DUP in UIxMailAccountView
   // TODO: improve, localize
   // TODO: there is a bug in the treeview which preserves the current URL for
   //       the active object (displaying the error again)
index ad6ee95f36c18be4a67d8ac1256ab4be50cdd3f8..9d77989c57077d41f65779134f69e23ef2790ef5 100644 (file)
@@ -1,6 +1,6 @@
 # version file
 
-SUBMINOR_VERSION:=147
+SUBMINOR_VERSION:=148
 
 # v0.9.140 requires SoObjects/Mailer v0.9.100
 # v0.9.134 requires libSOGo          v0.9.41
index a65554e544bdf57e82a71d2b25a3c580b7205005..6efeec2fa074f38150c30f03485f3f7a13d7260f 100644 (file)
                 onclick  = "clickedCompose(this);return false;";
                 cssClass = "tbicon_compose"; label = "Write";
               },
+            ),
+            ( // fourth group (folders)
+              { link = "#"; onclick="return ctxFolderAdd(this)";
+                enabled  = "showFolderCreateButton";
+                isSafe = NO;
+                cssClass = "tbicon_folderadd"; label = "Create"; }
             )
           );
         };
           actionClass = "UIxMailEditorAction"; 
           actionName  = "compose";
         };
+        createFolder = {
+          protectedBy = "View";
+          pageName    = "UIxMailAccountView"; 
+          actionName  = "createFolder";
+        };
       };
     };