(feat) improved ACLs handling for address book
parent
078ba95f8e
commit
26e8276b08
|
@ -284,13 +284,17 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
||||||
- (NSString *) contactFolders
|
- (NSString *) contactFolders
|
||||||
{
|
{
|
||||||
SOGoContactFolders *folderContainer;
|
SOGoContactFolders *folderContainer;
|
||||||
|
NSMutableDictionary *urls, *acls;
|
||||||
NSMutableArray *foldersAttrs;
|
NSMutableArray *foldersAttrs;
|
||||||
NSMutableDictionary *urls;
|
NSString *userLogin, *owner;
|
||||||
|
NSArray *folders, *allACLs;
|
||||||
NSDictionary *folderAttrs;
|
NSDictionary *folderAttrs;
|
||||||
NSArray *folders;
|
|
||||||
id currentFolder;
|
id currentFolder;
|
||||||
|
|
||||||
|
BOOL objectCreator, objectEditor, objectEraser;
|
||||||
int max, i;
|
int max, i;
|
||||||
|
|
||||||
|
userLogin = [[context activeUser] login];
|
||||||
folderContainer = [self clientObject];
|
folderContainer = [self clientObject];
|
||||||
folders = [folderContainer subFolders];
|
folders = [folderContainer subFolders];
|
||||||
|
|
||||||
|
@ -301,7 +305,9 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
||||||
for (i = 0; i < max; i++)
|
for (i = 0; i < max; i++)
|
||||||
{
|
{
|
||||||
currentFolder = [folders objectAtIndex: i];
|
currentFolder = [folders objectAtIndex: i];
|
||||||
|
owner = [currentFolder ownerInContext: context];
|
||||||
|
|
||||||
|
// We extract URLs for this address book
|
||||||
if ([currentFolder respondsToSelector: @selector(cardDavURL)])
|
if ([currentFolder respondsToSelector: @selector(cardDavURL)])
|
||||||
{
|
{
|
||||||
urls = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
urls = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
@ -313,6 +319,15 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We extract ACLs for this address book
|
||||||
|
allACLs = ([owner isEqualToString: userLogin] ? nil : [currentFolder aclsForUser: userLogin]);
|
||||||
|
objectCreator = ([owner isEqualToString: userLogin] || [allACLs containsObject: SOGoRole_ObjectCreator]);
|
||||||
|
objectEditor = ([owner isEqualToString: userLogin] || [allACLs containsObject: SOGoRole_ObjectEditor]);
|
||||||
|
objectEraser = ([owner isEqualToString: userLogin] || [allACLs containsObject: SOGoRole_ObjectEraser]);
|
||||||
|
acls = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool: objectCreator], @"objectCreator",
|
||||||
|
[NSNumber numberWithBool: objectEditor], @"objectEditor",
|
||||||
|
[NSNumber numberWithBool: objectEraser], @"objectEraser", nil];
|
||||||
|
|
||||||
// NOTE: keep urls as the last key/value here, to avoid chopping the dictionary
|
// NOTE: keep urls as the last key/value here, to avoid chopping the dictionary
|
||||||
// if it is not a GCS folder
|
// if it is not a GCS folder
|
||||||
folderAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
|
folderAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
@ -322,6 +337,7 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
||||||
[NSNumber numberWithBool: [currentFolder isKindOfClass: SOGoGCSFolderK]], @"isEditable",
|
[NSNumber numberWithBool: [currentFolder isKindOfClass: SOGoGCSFolderK]], @"isEditable",
|
||||||
[NSNumber numberWithBool: [currentFolder isKindOfClass: SOGoContactSourceFolderK]
|
[NSNumber numberWithBool: [currentFolder isKindOfClass: SOGoContactSourceFolderK]
|
||||||
&& ![currentFolder isPersonalSource]], @"isRemote",
|
&& ![currentFolder isPersonalSource]], @"isRemote",
|
||||||
|
acls, @"acls",
|
||||||
urls, @"urls",
|
urls, @"urls",
|
||||||
nil];
|
nil];
|
||||||
[foldersAttrs addObject: folderAttrs];
|
[foldersAttrs addObject: folderAttrs];
|
||||||
|
|
|
@ -409,6 +409,7 @@
|
||||||
</md-virtual-repeat-container>
|
</md-virtual-repeat-container>
|
||||||
<md-button class="md-fab md-fab-bottom-right md-accent"
|
<md-button class="md-fab md-fab-bottom-right md-accent"
|
||||||
label:aria-label="New Contact"
|
label:aria-label="New Contact"
|
||||||
|
ng-show="addressbook.selectedFolder.acls.objectCreator"
|
||||||
ng-click="addressbook.newComponent($event)">
|
ng-click="addressbook.newComponent($event)">
|
||||||
<md-icon>add</md-icon>
|
<md-icon>add</md-icon>
|
||||||
</md-button>
|
</md-button>
|
||||||
|
|
|
@ -35,13 +35,14 @@
|
||||||
</md-button>
|
</md-button>
|
||||||
<md-button class="sg-icon-button"
|
<md-button class="sg-icon-button"
|
||||||
label:aria-label="Edit"
|
label:aria-label="Edit"
|
||||||
ng-show="editor.currentFolder.isEditable"
|
ng-show="editor.currentFolder.acls.objectEditor"
|
||||||
ui-sref="app.addressbook.card.editor({addressbookId: editor.currentFolder.id, cardId: editor.card.id})">
|
ui-sref="app.addressbook.card.editor({addressbookId: editor.currentFolder.id, cardId: editor.card.id})">
|
||||||
<md-tooltip md-direction="left"><var:string label:value="Edit"/></md-tooltip>
|
<md-tooltip md-direction="left"><var:string label:value="Edit"/></md-tooltip>
|
||||||
<md-icon>mode_edit</md-icon>
|
<md-icon>mode_edit</md-icon>
|
||||||
</md-button>
|
</md-button>
|
||||||
<md-button class="sg-icon-button"
|
<md-button class="sg-icon-button"
|
||||||
label:aria-label="Delete"
|
label:aria-label="Delete"
|
||||||
|
ng-show="editor.currentFolder.acls.objectEraser"
|
||||||
ng-click="editor.confirmDelete(editor.card)">
|
ng-click="editor.confirmDelete(editor.card)">
|
||||||
<md-tooltip md-direction="left"><var:string label:value="Delete"/></md-tooltip>
|
<md-tooltip md-direction="left"><var:string label:value="Delete"/></md-tooltip>
|
||||||
<md-icon>delete</md-icon>
|
<md-icon>delete</md-icon>
|
||||||
|
|
Loading…
Reference in New Issue