]> err.no Git - scalable-opengroupware.org/blobdiff - UI/SOGoUI/UIxComponent.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1212 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / SOGoUI / UIxComponent.m
index 9332a7e5c3fa487de4b79b76b3bb778fcaaca5fe..273d3e20b9ffd48936b5fd88ef4743a66727ec21 100644 (file)
@@ -129,9 +129,8 @@ static BOOL uixDebugEnabled = NO;
 
 - (void) dealloc
 {
-  [self->queryParameters release];
-  if (_selectedDate)
-    [_selectedDate release];
+  [queryParameters release];
+  [_selectedDate release];
   [super dealloc];
 }
 
@@ -161,7 +160,7 @@ static BOOL uixDebugEnabled = NO;
           value = [[part substringFromIndex:(r.location + r.length)] 
                     stringByUnescapingURL];
         }
-      [self->queryParameters setObject:value forKey:key];
+      [queryParameters setObject:value forKey:key];
       part = [e nextObject];
     }
 }
@@ -195,12 +194,12 @@ static BOOL uixDebugEnabled = NO;
   NSRange   r;
   NSString *qs;
   
-  if (self->queryParameters)
-    return self->queryParameters;
+  if (queryParameters)
+    return queryParameters;
 
-  self->queryParameters = [[NSMutableDictionary alloc] initWithCapacity:8];
+  queryParameters = [[NSMutableDictionary alloc] initWithCapacity:8];
 
-  req = [[self context] request];
+  req = [context request];
   uri = [req uri];
   r   = [uri rangeOfString:@"?" options:NSBackwardsSearch];
   if (r.length > 0)
@@ -212,7 +211,7 @@ static BOOL uixDebugEnabled = NO;
   /* add form values */
   [self addKeepAliveFormValuesToQueryParameters];
 
-  return self->queryParameters;
+  return queryParameters;
 }
 
 - (NSDictionary *) queryParameters
@@ -247,7 +246,7 @@ static BOOL uixDebugEnabled = NO;
   qp = [self queryParameters];
   if ([qp count] > 0)
     {
-      ctx = [self context];
+      ctx = context;
       qps = [ctx queryPathSeparator];
       [ctx setQueryPathSeparator: @"&"];
       qs = [ctx queryStringFromDictionary: qp];
@@ -265,7 +264,7 @@ static BOOL uixDebugEnabled = NO;
   NSString *uri;
   NSRange  r;
     
-  uri = [[[self context] request] uri];
+  uri = [[context request] uri];
     
   /* first: cut off query parameters */
     
@@ -294,7 +293,7 @@ static BOOL uixDebugEnabled = NO;
   SOGoObject *currentObject;
   BOOL found;
 
-  ctx = [self context];
+  ctx = context;
   objects = [[ctx objectTraversalStack] objectEnumerator];
   currentObject = [objects nextObject];
   found = NO;
@@ -313,28 +312,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 = [self context];
-
-  return [[currentClient baseURLInContext:ctx] hostlessURL];
+  return [[currentClient baseURLInContext: context] hostlessURL];
 }
 
 - (NSString *) resourcesPath
@@ -352,7 +354,7 @@ static BOOL uixDebugEnabled = NO;
   NSString *uri;
   NSRange  r;
   
-  uri = [[[self context] request] uri];
+  uri = [[context request] uri];
   
   /* first: cut off query parameters */
   
@@ -398,7 +400,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
@@ -419,35 +421,12 @@ static BOOL uixDebugEnabled = NO;
 
 /* SoUser */
 
-- (SoUser *) user
-{
-  WOContext *ctx;
-  
-  ctx = [self context];
-
-  return [[[self clientObject] authenticatorInContext: ctx] userInContext: ctx];
-}
-
 - (NSString *) shortUserNameForDisplay
 {
-  // TODO: better use a SoUser formatter?
-  // TODO: who calls that?
-  NSString *s;
-  NSRange  r;
-  
-  // TODO: USE USER MANAGER INSTEAD!
-  
-  s = [[self user] login];
-  if ([s length] < 10)
-    return s;
-    
-  // TODO: algorithm might be inappropriate, depends on the actual UID
-    
-  r = [s rangeOfString:@"."];
-  if (r.length == 0)
-    return s;
-    
-  return [s substringToIndex:r.location];
+  if ([context activeUser] == nil)
+    return @"wrongusernamepassword";
+
+  return [[context activeUser] login];
 }
 
 /* labels */
@@ -464,7 +443,7 @@ static BOOL uixDebugEnabled = NO;
   
   /* lookup languages */
     
-  languages = [[self context] resourceLookupLanguages];
+  languages = [context resourceLookupLanguages];
     
   /* find resource manager */
     
@@ -531,7 +510,7 @@ static BOOL uixDebugEnabled = NO;
   // TODO: move to WORequest?
   NSString *m;
   
-  m = [[[self context] request] method];
+  m = [[context request] method];
   if ([m isEqualToString:@"GET"])  return YES;
   if ([m isEqualToString:@"HEAD"]) return YES;
   return NO;
@@ -548,7 +527,7 @@ static BOOL uixDebugEnabled = NO;
 {
   WOResourceManager *rm;
   
-  if ((rm = [[[self context] page] resourceManager]) == nil)
+  if ((rm = [[context page] resourceManager]) == nil)
     rm = [[WOApplication application] resourceManager];
 
   return rm;
@@ -571,12 +550,12 @@ static BOOL uixDebugEnabled = NO;
       if (!url)
         {
           rm = [self pageResourceManager];
-          page = [[self context] page];
+          page = [context page];
           pageBundle = [NSBundle bundleForClass: [page class]];
           url = [rm urlForResourceNamed: filename
                     inFramework: [pageBundle bundlePath]
                     languages: nil
-                    request: [[self context] request]];
+                    request: [context request]];
           if (!url)
             url = @"";
           else
@@ -593,6 +572,16 @@ static BOOL uixDebugEnabled = NO;
   return url;
 }
 
+- (WOResponse *) responseWith204
+{
+  WOResponse *response;
+
+  response = [context response];
+  [response setStatus: 204];
+
+  return response;
+}
+
 /* debugging */
 
 - (BOOL)isUIxDebugEnabled {