]> err.no Git - scalable-opengroupware.org/blobdiff - UI/SOGoUI/UIxComponent.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1287 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / SOGoUI / UIxComponent.m
index 83eb9b18f3d4467a1c04ba3e743a81adcc1a925b..50e6bf253c28cc32521870927b9aae8003c7bafd 100644 (file)
 #import <Foundation/NSUserDefaults.h>
 #import <Foundation/NSKeyValueCoding.h>
 #import <Foundation/NSPathUtilities.h>
+
 #import <NGObjWeb/SoHTTPAuthenticator.h>
 #import <NGObjWeb/SoObjects.h>
 #import <NGObjWeb/WOResourceManager.h>
 #import <NGObjWeb/WORequest.h>
+#import <NGObjWeb/WOResponse.h>
 #import <NGObjWeb/WOContext+SoObjects.h>
 #import <NGExtensions/NSObject+Logs.h>
 #import <NGExtensions/NSString+misc.h>
 #import <NGExtensions/NSURL+misc.h>
+
+#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
+#import <SoObjects/SOGo/NSString+Utilities.h>
 #import <SoObjects/SOGo/SOGoUser.h>
 #import <SoObjects/SOGo/SOGoObject.h>
+#import <SoObjects/SOGo/SOGoContentObject.h>
 #import <SoObjects/SOGo/SOGoCustomGroupFolder.h>
-#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
-#import <SoObjects/SOGo/NSString+Utilities.h>
+#import <SoObjects/SOGo/SOGoPermissions.h>
 
-#import "UIxComponent.h"
 #import "UIxJSClose.h"
 
+#import "UIxComponent.h"
+
 @interface UIxComponent (PrivateAPI)
 - (void)_parseQueryString:(NSString *)_s;
 - (NSMutableDictionary *)_queryParameters;
@@ -312,28 +318,31 @@ static BOOL uixDebugEnabled = NO;
   SOGoObject *currentClient, *parent;
   BOOL found;
   Class objectClass, groupFolderClass, userFolderClass;
-  WOContext *ctx;
-
-  groupFolderClass = [SOGoCustomGroupFolder class];
-  userFolderClass = [SOGoUserFolder class];
 
   currentClient = [self clientObject];
-  objectClass = [currentClient class];
-  found = (objectClass == groupFolderClass || objectClass == userFolderClass);
-  while (!found && currentClient)
+  if (currentClient
+      && [currentClient isKindOfClass: [SOGoObject class]])
     {
-      parent = [currentClient container];
-      objectClass = [parent class];
-      if (objectClass == groupFolderClass
-          || objectClass == userFolderClass)
-        found = YES;
-      else
-        currentClient = parent;
+      groupFolderClass = [SOGoCustomGroupFolder class];
+      userFolderClass = [SOGoUserFolder class];
+
+      objectClass = [currentClient class];
+      found = (objectClass == groupFolderClass || objectClass == userFolderClass);
+      while (!found && currentClient)
+       {
+         parent = [currentClient container];
+         objectClass = [parent class];
+         if (objectClass == groupFolderClass
+             || objectClass == userFolderClass)
+           found = YES;
+         else
+           currentClient = parent;
+       }
     }
+  else
+    currentClient = [WOApplication application];
 
-  ctx = context;
-
-  return [[currentClient baseURLInContext:ctx] hostlessURL];
+  return [[currentClient baseURLInContext: context] hostlessURL];
 }
 
 - (NSString *) resourcesPath
@@ -397,7 +406,7 @@ static BOOL uixDebugEnabled = NO;
   userTimeZone = [[context activeUser] timeZone];
   [_date setTimeZone: userTimeZone];
 
-  return [_date descriptionWithCalendarFormat:@"%Y%m%d"];
+  return [_date descriptionWithCalendarFormat: @"%Y%m%d"];
 }
 
 - (BOOL) hideFrame
@@ -416,10 +425,25 @@ static BOOL uixDebugEnabled = NO;
   return jsClose;
 }
 
+/* common conditions */
+- (BOOL) canCreateOrModify
+{
+  SoSecurityManager *sm;
+
+  sm = [SoSecurityManager sharedSecurityManager];
+
+  return (![sm validatePermission: SoPerm_ChangeImagesAndFiles
+              onObject: [self clientObject]
+              inContext: context]);
+}
+
 /* SoUser */
 
 - (NSString *) shortUserNameForDisplay
 {
+  if ([context activeUser] == nil)
+    return @"wrongusernamepassword";
+
   return [[context activeUser] login];
 }
 
@@ -465,12 +489,6 @@ static BOOL uixDebugEnabled = NO;
   if ([lTable hasPrefix:@"$"])
     lTable = [self valueForKeyPath:[lTable substringFromIndex:1]];
   
-#if 0
-  if ([lVal hasPrefix:@"$"])
-    lVal = [self valueForKeyPath:[lVal substringFromIndex:1]];
-  
-#endif
-  
   /* lookup string */
   return [rm stringForKey: lKey
              inTableNamed: lTable
@@ -566,6 +584,16 @@ static BOOL uixDebugEnabled = NO;
   return url;
 }
 
+- (WOResponse *) responseWith204
+{
+  WOResponse *response;
+
+  response = [context response];
+  [response setStatus: 204];
+
+  return response;
+}
+
 /* debugging */
 
 - (BOOL)isUIxDebugEnabled {