(fix) simplified logic and improved code readability

pull/105/head
Ludovic Marcotte 2015-09-21 08:59:36 -04:00
parent 7692832672
commit 1c666e8ead
3 changed files with 18 additions and 27 deletions

View File

@ -71,6 +71,11 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
return self;
}
- (NSString *) modulePath
{
return @"Contacts";
}
- (void) _setupContext
{
SOGoUser *activeUser;

View File

@ -87,6 +87,11 @@
[super dealloc];
}
- (NSString *) modulePath
{
return @"Mail";
}
- (void) _setupContext
{
SOGoUser *activeUser;

View File

@ -360,38 +360,19 @@ static SoProduct *commonProduct = nil;
- (NSString *) modulePath
{
SOGoObject *currentClient, *parent;
BOOL found;
NSString *hostLessURL;
Class objectClass, userFolderClass;
if ([[self parent] respondsToSelector: @selector(modulePath)])
return [NSString stringWithFormat: @"%@/%@", [[self clientObject] baseURLInContext: context], [[self parent] modulePath]];
currentClient = [self clientObject];
if (currentClient
&& [currentClient isKindOfClass: [SOGoObject class]])
{
userFolderClass = [SOGoUserFolder class];
NSString *baseURL;
objectClass = [currentClient class];
found = (objectClass == userFolderClass);
while (!found && currentClient)
{
parent = [currentClient container];
objectClass = [parent class];
if (objectClass == userFolderClass)
found = YES;
else
currentClient = parent;
}
baseURL = [[self clientObject] baseURLInContext: context];
if ([baseURL hasSuffix: [NSString stringWithFormat: @"%@/", [[self parent] modulePath]]])
return baseURL;
return [NSString stringWithFormat: @"%@%@", baseURL, [[self parent] modulePath]];
}
else
currentClient = [WOApplication application];
hostLessURL = [[currentClient baseURLInContext: context] hostlessURL];
return [hostLessURL substringToIndex: [hostLessURL length] - 1];
return nil;
}
- (NSString *) ownPath