mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-04 21:08:51 +00:00
Improve ACL editor (Scheduler & Contacts)
This commit is contained in:
@@ -84,7 +84,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /so/:username/:folderPath/acls Get ACLs
|
||||
* @api {get} /so/:username/:folderPath/acls List users with rights
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName GetAcls
|
||||
* @apiGroup Common
|
||||
|
||||
@@ -184,19 +184,22 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /so/:username/:folderPath/acls Get ACLs
|
||||
* @api {get} /so/:username/:folderPath/userRights?uid=:uid Get user's rights
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName GetAcls
|
||||
* @apiName GetUserRights
|
||||
* @apiGroup Common
|
||||
* @apiExample {curl} Example usage:
|
||||
* curl -i http://localhost/SOGo/so/sogo1/Calendar/personal/acls
|
||||
* curl -i http://localhost/SOGo/so/sogo1/Calendar/personal/userRights?uid=sogo2
|
||||
*
|
||||
* @apiSuccess (Success 200) {Object[]} users List of users with ACL for the folder
|
||||
* @apiSuccess (Success 200) {String} users.uid User ID
|
||||
* @apiSuccess (Success 200) {String} users.userClass Either 'normal-user', 'normal-group' or 'public-access'
|
||||
* @apiSuccess (Success 200) {Number} users.isSubscribed 1 if the user is subscribed to the folder
|
||||
* @apiSuccess (Success 200) {String} [users.cn] User fullname
|
||||
* @apiSuccess (Success 200) {String} [users.c_email] User main email address
|
||||
* @apiSuccess (Success 200) {String} [Public] Calendar: either None, DAndTViewer, Viewer, Responder, or Modifier
|
||||
* @apiSuccess (Success 200) {String} [Confidential] Calendar: either None, DAndTViewer, Viewer, Responder, or Modifier
|
||||
* @apiSuccess (Success 200) {Number} [Private] Calendar: either None, DAndTViewer, Viewer, Responder, or Modifier
|
||||
* @apiSuccess (Success 200) {Number} [canCreateObjects] Calendar: can create events and tasks
|
||||
* @apiSuccess (Success 200) {Number} [canEraseObjects] Calendar: can erase events and tasks
|
||||
* @apiSuccess (Success 200) {Number} [canCreateObjects] Address Book: can create cards
|
||||
* @apiSuccess (Success 200) {Number} [canEraseObjects] Address Book: can erase cards
|
||||
* @apiSuccess (Success 200) {Number} [canViewObjects] Address Book: can view cards
|
||||
* @apiSuccess (Success 200) {Number} [canEditObjects] Address Book: can modify cards
|
||||
*/
|
||||
- (id <WOActionResults>) userRightsAction
|
||||
{
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/* UIxCalUserRightsEditor.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
* Copyright (C) 2007-2015 Inverse inc.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -32,7 +30,6 @@
|
||||
@interface UIxCalUserRightsEditor : UIxUserRightsEditor
|
||||
{
|
||||
NSString *currentRight;
|
||||
NSString *currentRightType;
|
||||
NSMutableDictionary *rights;
|
||||
}
|
||||
|
||||
@@ -41,11 +38,6 @@
|
||||
- (NSString *) currentRight;
|
||||
|
||||
- (NSArray *) rightTypes;
|
||||
- (void) setCurrentRightType: (NSString *) newCurrentRightType;
|
||||
- (NSString *) currentRightType;
|
||||
- (NSString *) currentRightTypeLabel;
|
||||
- (NSString *) currentRightTypeName;
|
||||
- (NSString *) currentRightSelection;
|
||||
|
||||
- (void) setUserCanCreateObjects: (BOOL) userCanCreateObjects;
|
||||
- (BOOL) userCanCreateObjects;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/* UIxCalUserRightsEditor.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007-2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
* Copyright (C) 2007-2015 Inverse inc.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -36,7 +34,6 @@
|
||||
if ((self = [super init]))
|
||||
{
|
||||
currentRight = nil;
|
||||
currentRightType = nil;
|
||||
rights = [NSMutableDictionary new];
|
||||
[rights setObject: @"None" forKey: @"Public"];
|
||||
[rights setObject: @"None" forKey: @"Private"];
|
||||
@@ -49,7 +46,6 @@
|
||||
- (void) dealloc
|
||||
{
|
||||
[currentRight release];
|
||||
[currentRightType release];
|
||||
[rights release];
|
||||
[super dealloc];
|
||||
}
|
||||
@@ -95,6 +91,9 @@
|
||||
return rightsForType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see [UIxUserRightsEditor userRightsAction]
|
||||
*/
|
||||
- (NSDictionary *) userRightsForObject
|
||||
{
|
||||
NSMutableDictionary *d;
|
||||
@@ -111,6 +110,9 @@
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see [UIxUserRightsEditor saveUserRightsAction]
|
||||
*/
|
||||
- (void) updateRights: (NSDictionary *) newRights
|
||||
{
|
||||
NSEnumerator *types;
|
||||
@@ -163,62 +165,10 @@
|
||||
return currentRight;
|
||||
}
|
||||
|
||||
- (NSArray *) rightTypes
|
||||
{
|
||||
return
|
||||
[NSArray arrayWithObjects: @"Public", @"Confidential", @"Private", nil];
|
||||
}
|
||||
|
||||
- (void) setCurrentRightType: (NSString *) newCurrentRightType
|
||||
{
|
||||
ASSIGN (currentRightType, newCurrentRightType);
|
||||
}
|
||||
|
||||
- (NSString *) currentRightType
|
||||
{
|
||||
return currentRightType;
|
||||
}
|
||||
|
||||
- (NSString *) currentRightLabel
|
||||
{
|
||||
return [self labelForKey:
|
||||
[NSString stringWithFormat: @"label_%@", currentRight]];
|
||||
}
|
||||
|
||||
- (NSString *) currentRightTypeLabel
|
||||
{
|
||||
return [self labelForKey:
|
||||
[NSString stringWithFormat: @"label_%@", currentRightType]];
|
||||
}
|
||||
|
||||
- (NSString *) currentRightTypeName
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@Right", currentRightType];
|
||||
}
|
||||
|
||||
- (NSString *) currentRightSelection
|
||||
{
|
||||
return [rights objectForKey: currentRightType];
|
||||
}
|
||||
|
||||
- (void) setUserCanCreateObjects: (BOOL) userCanCreateObjects
|
||||
{
|
||||
[self appendRight: SOGoRole_ObjectCreator];
|
||||
}
|
||||
|
||||
- (BOOL) userCanCreateObjects
|
||||
{
|
||||
return [userRights containsObject: SOGoRole_ObjectCreator];
|
||||
}
|
||||
|
||||
- (void) setUserCanEraseObjects: (BOOL) userCanEraseObjects
|
||||
{
|
||||
[self appendRight: SOGoRole_ObjectEraser];
|
||||
}
|
||||
|
||||
- (BOOL) userCanEraseObjects
|
||||
{
|
||||
return [userRights containsObject: SOGoRole_ObjectEraser];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,35 +9,35 @@
|
||||
<div class="addressbookUserRights" layout="column">
|
||||
|
||||
<md-checkbox name="canViewObjects"
|
||||
ng-model="selectedUser.rights.canViewObjects"
|
||||
ng-change="confirmChange(selectedUser)"
|
||||
ng-model="acl.selectedUser.rights.canViewObjects"
|
||||
ng-change="acl.confirmChange(acl.selectedUser)"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0">
|
||||
<var:string label:value="This person can read the cards of this addressbook." />
|
||||
</md-checkbox>
|
||||
|
||||
<md-checkbox name="canCreateObjects"
|
||||
ng-model="selectedUser.rights.canCreateObjects"
|
||||
ng-change="confirmChange(selectedUser)"
|
||||
ng-hide="selectedUser.$isAnonymous()"
|
||||
ng-model="acl.selectedUser.rights.canCreateObjects"
|
||||
ng-change="acl.confirmChange(acl.selectedUser)"
|
||||
ng-hide="acl.selectedUser.$isAnonymous()"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0">
|
||||
<var:string label:value="This person can add cards to this addressbook." />
|
||||
</md-checkbox>
|
||||
|
||||
<md-checkbox name="canEditObjects"
|
||||
ng-model="selectedUser.rights.canEditObjects"
|
||||
ng-change="confirmChange(selectedUser)"
|
||||
ng-hide="selectedUser.$isAnonymous()"
|
||||
ng-model="acl.selectedUser.rights.canEditObjects"
|
||||
ng-change="acl.confirmChange(acl.selectedUser)"
|
||||
ng-hide="acl.selectedUser.$isAnonymous()"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0">
|
||||
<var:string label:value="This person can edit the cards of this addressbook." />
|
||||
</md-checkbox>
|
||||
|
||||
<md-checkbox name="canEraseObjects"
|
||||
ng-model="selectedUser.rights.canEraseObjects"
|
||||
ng-change="confirmChange(selectedUser)"
|
||||
ng-hide="selectedUser.$isAnonymous()"
|
||||
ng-model="acl.selectedUser.rights.canEraseObjects"
|
||||
ng-change="acl.confirmChange(acl.selectedUser)"
|
||||
ng-hide="acl.selectedUser.$isAnonymous()"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0">
|
||||
<var:string label:value="This person can erase cards from this addressbook." />
|
||||
|
||||
@@ -11,20 +11,13 @@
|
||||
const:toolbar="none"
|
||||
const:popup="YES">
|
||||
|
||||
<div class="calendarUserRights" layout="column">
|
||||
<!-- <var:foreach list="rightTypes" item="currentRightType">
|
||||
<div><span><var:string value="currentRightTypeLabel"/></span>
|
||||
<var:popup list="objectRights" item="currentRight"
|
||||
var:name="currentRightTypeName"
|
||||
var:value="currentRight"
|
||||
string="currentRightLabel"
|
||||
selection="currentRightSelection"
|
||||
/></div>
|
||||
</var:foreach>
|
||||
-->
|
||||
<div layout="column">
|
||||
|
||||
<div layout="row" layout-align="space-between center">
|
||||
<var:string label:value="Public"/>
|
||||
<md-select flex="50" ng-model="selectedUser.rights.Public">
|
||||
<label><var:string label:value="label_Public"/></label>
|
||||
<md-select flex="50" label:aria-label="Public"
|
||||
ng-model="acl.selectedUser.rights.Public"
|
||||
ng-change="acl.confirmChange(acl.selectedUser)">
|
||||
<var:foreach list="objectRights" item="currentRight">
|
||||
<md-option var:value="currentRight">
|
||||
<var:string value="currentRightLabel"/>
|
||||
@@ -34,8 +27,10 @@
|
||||
</div>
|
||||
|
||||
<div layout="row" layout-align="space-between center">
|
||||
<var:string label:value="Confidential"/>
|
||||
<md-select flex="50" ng-model="selectedUser.rights.Confidential">
|
||||
<var:string label:value="label_Confidential"/>
|
||||
<md-select flex="50" label:aria-label="Confidential"
|
||||
ng-model="acl.selectedUser.rights.Confidential"
|
||||
ng-change="acl.confirmChange(acl.selectedUser)">
|
||||
<var:foreach list="objectRights" item="currentRight">
|
||||
<md-option var:value="currentRight">
|
||||
<var:string value="currentRightLabel"/>
|
||||
@@ -45,8 +40,10 @@
|
||||
</div>
|
||||
|
||||
<div layout="row" layout-align="space-between center">
|
||||
<var:string label:value="Private"/>
|
||||
<md-select flex="50" ng-model="selectedUser.rights.Private">
|
||||
<var:string label:value="label_Private"/>
|
||||
<md-select flex="50" label:aria-label="Private"
|
||||
ng-model="acl.selectedUser.rights.Private"
|
||||
ng-change="acl.confirmChange(acl.selectedUser)">
|
||||
<var:foreach list="objectRights" item="currentRight">
|
||||
<md-option var:value="currentRight">
|
||||
<var:string value="currentRightLabel"/>
|
||||
@@ -56,24 +53,25 @@
|
||||
</div>
|
||||
|
||||
<md-checkbox name="canCreateObjects"
|
||||
ng-model="selectedUser.rights.canCreateObjects"
|
||||
ng-change="confirmChange(selectedUser)"
|
||||
ng-hide="selectedUser.$isAnonymous()"
|
||||
ng-model="acl.selectedUser.rights.canCreateObjects"
|
||||
ng-change="acl.confirmChange(acl.selectedUser)"
|
||||
ng-hide="acl.selectedUser.$isAnonymous()"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0">
|
||||
ng-false-value="0"
|
||||
label:aria-label="This person can create objects in my calendar.">
|
||||
<var:string label:value="This person can create objects in my calendar." />
|
||||
</md-checkbox>
|
||||
|
||||
<md-checkbox name="canEraseObjects"
|
||||
ng-model="selectedUser.rights.canEraseObjects"
|
||||
ng-change="confirmChange(selectedUser)"
|
||||
ng-hide="selectedUser.$isAnonymous()"
|
||||
ng-model="acl.selectedUser.rights.canEraseObjects"
|
||||
ng-change="acl.confirmChange(acl.selectedUser)"
|
||||
ng-hide="acl.selectedUser.$isAnonymous()"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0">
|
||||
ng-false-value="0"
|
||||
label:aria-label="This person can erase objects from my calendar.">
|
||||
<var:string label:value="This person can erase objects from my calendar." />
|
||||
</md-checkbox>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</var:component>
|
||||
|
||||
@@ -53,13 +53,14 @@
|
||||
<div class="md-actions">
|
||||
<md-autocomplete
|
||||
class="md-flex"
|
||||
md-input-name="addUser"
|
||||
md-search-text="acl.searchText"
|
||||
md-selected-item="acl.userToAdd"
|
||||
md-selected-item-change="acl.addUser(user)"
|
||||
md-items="user in acl.userFilter(acl.searchText)"
|
||||
md-min-length="3"
|
||||
md-no-cache="true"
|
||||
label:placeholder="Add">
|
||||
label:md-floating-label="Add User">
|
||||
<span class="md-contact-suggestion" layout="row" layout-align="space-between center">
|
||||
<span class="md-contact-name"
|
||||
md-highlight-text="acl.searchText"
|
||||
@@ -68,7 +69,7 @@
|
||||
md-highlight-flags="^i">{{user.c_email}}</span>
|
||||
</span>
|
||||
</md-autocomplete>
|
||||
<md-button ng-click="acl.closeModal()"><var:string label:value="Close"/></md-button>
|
||||
<md-button ng-click="acl.closeModal()"><var:string label:value="Cancel"/></md-button>
|
||||
<md-button class="md-primitive" ng-click="acl.saveModal()"><var:string label:value="Save"/></md-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
|
||||
@@ -225,7 +225,10 @@
|
||||
if (zero) {
|
||||
// Disable all rights
|
||||
_.map(_.keys(this.rights), function(key) {
|
||||
_this.rights[key] = 0;
|
||||
if (angular.isString(_this.rights[key]))
|
||||
_this.rights[key] = 'None';
|
||||
else
|
||||
_this.rights[key] = 0;
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -141,6 +141,7 @@
|
||||
|
||||
vm.users = usersWithACL; // ACL users
|
||||
vm.folder = folder;
|
||||
vm.selectedUser = null;
|
||||
vm.userToAdd = '';
|
||||
vm.searchText = '';
|
||||
vm.userFilter = userFilter;
|
||||
@@ -171,9 +172,8 @@
|
||||
function confirmChange(user) {
|
||||
var confirmation = user.$confirmRights();
|
||||
if (confirmation) {
|
||||
Dialog.confirm(l('Warning'), confirmation).then(function(res) {
|
||||
if (!res)
|
||||
user.$resetRights(true);
|
||||
Dialog.confirm(l('Warning'), confirmation).catch(function() {
|
||||
user.$resetRights(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
$mdDialog.show({
|
||||
templateUrl: calendar.id + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox
|
||||
controller: CalendarACLController,
|
||||
controllerAs: 'acl',
|
||||
clickOutsideToClose: true,
|
||||
escapeToClose: true,
|
||||
locals: {
|
||||
@@ -106,59 +107,74 @@
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
CalendarACLController.$inject = ['$scope', '$mdDialog', 'usersWithACL', 'User', 'folder'];
|
||||
function CalendarACLController($scope, $mdDialog, usersWithACL, User, folder) {
|
||||
$scope.users = usersWithACL; // ACL users
|
||||
$scope.folder = folder;
|
||||
$scope.selectedUser = null;
|
||||
$scope.userToAdd = '';
|
||||
$scope.searchText = '';
|
||||
$scope.userFilter = function($query) {
|
||||
return User.$filter($query);
|
||||
};
|
||||
$scope.closeModal = function() {
|
||||
CalendarACLController.$inject = ['$mdDialog', 'usersWithACL', 'User', 'folder'];
|
||||
function CalendarACLController($mdDialog, usersWithACL, User, folder) {
|
||||
var vm = this;
|
||||
|
||||
vm.users = usersWithACL; // ACL users
|
||||
vm.folder = folder;
|
||||
vm.selectedUser = null;
|
||||
vm.userToAdd = '';
|
||||
vm.searchText = '';
|
||||
vm.userFilter = userFilter;
|
||||
vm.closeModal = closeModal;
|
||||
vm.saveModal = saveModal;
|
||||
vm.confirmChange = confirmChange;
|
||||
vm.removeUser = removeUser;
|
||||
vm.addUser = addUser;
|
||||
vm.selectUser = selectUser;
|
||||
|
||||
function userFilter($query) {
|
||||
return User.$filter($query, folder.$acl.users);
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
folder.$acl.$resetUsersRights(); // cancel changes
|
||||
$mdDialog.hide();
|
||||
};
|
||||
$scope.saveModal = function() {
|
||||
}
|
||||
|
||||
function saveModal() {
|
||||
folder.$acl.$saveUsersRights().then(function() {
|
||||
$mdDialog.hide();
|
||||
}, function(data, status) {
|
||||
Dialog.alert(l('Warning'), l('An error occured please try again.'));
|
||||
});
|
||||
};
|
||||
$scope.confirmChange = function(user) {
|
||||
}
|
||||
|
||||
function confirmChange(user) {
|
||||
var confirmation = user.$confirmRights();
|
||||
if (confirmation) {
|
||||
Dialog.confirm(l('Warning'), confirmation).then(function(res) {
|
||||
if (!res)
|
||||
user.$resetRights(true);
|
||||
Dialog.confirm(l('Warning'), confirmation).catch(function() {
|
||||
user.$resetRights(true);
|
||||
});
|
||||
}
|
||||
};
|
||||
$scope.removeUser = function(user) {
|
||||
}
|
||||
|
||||
function removeUser(user) {
|
||||
folder.$acl.$removeUser(user.uid).then(function() {
|
||||
if (user.uid == $scope.selectedUser.uid)
|
||||
$scope.selectedUser = null;
|
||||
if (user.uid == vm.selectedUser.uid)
|
||||
vm.selectedUser = null;
|
||||
}, function(data, status) {
|
||||
Dialog.alert(l('Warning'), l('An error occured please try again.'))
|
||||
});
|
||||
};
|
||||
$scope.addUser = function(data) {
|
||||
}
|
||||
|
||||
function addUser(data) {
|
||||
if (data) {
|
||||
folder.$acl.$addUser(data).then(function() {
|
||||
$scope.userToAdd = '';
|
||||
$scope.searchText = '';
|
||||
vm.userToAdd = '';
|
||||
vm.searchText = '';
|
||||
}, function(error) {
|
||||
Dialog.alert(l('Warning'), error);
|
||||
});
|
||||
}
|
||||
};
|
||||
$scope.selectUser = function(user) {
|
||||
}
|
||||
|
||||
function selectUser(user) {
|
||||
// Check if it is a different user
|
||||
if ($scope.selectedUser != user) {
|
||||
$scope.selectedUser = user;
|
||||
$scope.selectedUser.$rights();
|
||||
if (vm.selectedUser != user) {
|
||||
vm.selectedUser = user;
|
||||
vm.selectedUser.$rights();
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -174,6 +190,6 @@
|
||||
}
|
||||
|
||||
angular
|
||||
.module('SOGo.SchedulerUI')
|
||||
.controller('CalendarsController', CalendarsController);
|
||||
.module('SOGo.SchedulerUI')
|
||||
.controller('CalendarsController', CalendarsController);
|
||||
})();
|
||||
|
||||
@@ -14,8 +14,12 @@ md-card {
|
||||
}
|
||||
|
||||
&.sg-collapsed {
|
||||
border-radius: 0;
|
||||
margin-top: 0;
|
||||
margin-bottom: 1px;
|
||||
margin-bottom: 0;
|
||||
> .md-button {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&.sg-expanded {
|
||||
|
||||
Reference in New Issue
Block a user