X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=UI%2FSOGoUI%2FUIxComponent.m;h=50e6bf253c28cc32521870927b9aae8003c7bafd;hb=819c57de7f7711f25af4abc552f5168aec12f03a;hp=9332a7e5c3fa487de4b79b76b3bb778fcaaca5fe;hpb=8477d0162a92327cd6f855c06f15700e6d2b97d3;p=scalable-opengroupware.org diff --git a/UI/SOGoUI/UIxComponent.m b/UI/SOGoUI/UIxComponent.m index 9332a7e5..50e6bf25 100644 --- a/UI/SOGoUI/UIxComponent.m +++ b/UI/SOGoUI/UIxComponent.m @@ -24,23 +24,29 @@ #import #import #import + #import #import #import #import +#import #import #import #import #import + +#import +#import #import #import +#import #import -#import -#import +#import -#import "UIxComponent.h" #import "UIxJSClose.h" +#import "UIxComponent.h" + @interface UIxComponent (PrivateAPI) - (void)_parseQueryString:(NSString *)_s; - (NSMutableDictionary *)_queryParameters; @@ -129,9 +135,8 @@ static BOOL uixDebugEnabled = NO; - (void) dealloc { - [self->queryParameters release]; - if (_selectedDate) - [_selectedDate release]; + [queryParameters release]; + [_selectedDate release]; [super dealloc]; } @@ -161,7 +166,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 +200,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 +217,7 @@ static BOOL uixDebugEnabled = NO; /* add form values */ [self addKeepAliveFormValuesToQueryParameters]; - return self->queryParameters; + return queryParameters; } - (NSDictionary *) queryParameters @@ -247,7 +252,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 +270,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 +299,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 +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 = [self context]; - - return [[currentClient baseURLInContext:ctx] hostlessURL]; + return [[currentClient baseURLInContext: context] hostlessURL]; } - (NSString *) resourcesPath @@ -352,7 +360,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 +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 @@ -417,37 +425,26 @@ static BOOL uixDebugEnabled = NO; return jsClose; } -/* SoUser */ - -- (SoUser *) user +/* common conditions */ +- (BOOL) canCreateOrModify { - WOContext *ctx; - - ctx = [self context]; + SoSecurityManager *sm; - return [[[self clientObject] authenticatorInContext: ctx] userInContext: ctx]; + sm = [SoSecurityManager sharedSecurityManager]; + + return (![sm validatePermission: SoPerm_ChangeImagesAndFiles + onObject: [self clientObject] + inContext: context]); } +/* SoUser */ + - (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 +461,7 @@ static BOOL uixDebugEnabled = NO; /* lookup languages */ - languages = [[self context] resourceLookupLanguages]; + languages = [context resourceLookupLanguages]; /* find resource manager */ @@ -492,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 @@ -531,7 +522,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 +539,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 +562,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 +584,16 @@ static BOOL uixDebugEnabled = NO; return url; } +- (WOResponse *) responseWith204 +{ + WOResponse *response; + + response = [context response]; + [response setStatus: 204]; + + return response; +} + /* debugging */ - (BOOL)isUIxDebugEnabled {