Fix prepareRightsForm, keep the highest role

userRights is sorted highest to lowest right so we have to assign
only the first right found for each type
This commit is contained in:
Jesús García Sáez
2016-02-23 15:08:15 +01:00
parent 12e952eb55
commit 698918abf9

View File

@@ -57,25 +57,24 @@
{
NSEnumerator *roles, *types;
NSString *role, *type;
unsigned int length;
roles = [userRights objectEnumerator];
role = [roles nextObject];
while (role)
types = [[self rightTypes] objectEnumerator];
type = [types nextObject];
while (type)
{
types = [[self rightTypes] objectEnumerator];
type = [types nextObject];
while (type)
{
if ([role hasPrefix: type])
{
length = [type length];
[rights setObject: [role substringFromIndex: length]
forKey: type];
}
type = [types nextObject];
}
roles = [userRights objectEnumerator];
role = [roles nextObject];
while (role)
{
if ([role hasPrefix: type])
{
[rights setObject: [role substringFromIndex: [type length]]
forKey: type];
break;
}
role = [roles nextObject];
}
type = [types nextObject];
}
}