From 57791e384b7fb67c73b0098c1a8c7706aa38e5e7 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 8 Oct 2014 10:37:26 -0400 Subject: [PATCH] Revert "Creation of aclUsers window" This reverts commit ee5ef02f50d5f759f2ff985530bf8d78ca781aed. --- UI/Common/UIxUserRightsEditor.m | 103 ++++++------------ .../ContactsUI/UIxContactFoldersView.wox | 71 ------------ UI/WebServerResources/js/Common/resource.js | 37 ------- UI/WebServerResources/js/ContactsUI.js | 74 ------------- 4 files changed, 31 insertions(+), 254 deletions(-) diff --git a/UI/Common/UIxUserRightsEditor.m b/UI/Common/UIxUserRightsEditor.m index 2208c50c2..3519abc0e 100644 --- a/UI/Common/UIxUserRightsEditor.m +++ b/UI/Common/UIxUserRightsEditor.m @@ -119,62 +119,29 @@ if ([newUID length] > 0) { if (!defaultUserID) - ASSIGN (defaultUserID, [[self clientObject] defaultUserID]); + ASSIGN (defaultUserID, [[self clientObject] defaultUserID]); um = [SOGoUserManager sharedUserManager]; - if ([newUID isEqualToString: defaultUserID] || [newUID isEqualToString: @"anonymous"] - || [[um getEmailForUID: newUID] length] > 0) - { - if (![newUID hasPrefix: @"@"]) - { + if ([newUID isEqualToString: defaultUserID] + || [newUID isEqualToString: @"anonymous"] + || [[um getEmailForUID: newUID] length] > 0) + { + if (![newUID hasPrefix: @"@"]) + { domain = [[context activeUser] domain]; - group = [SOGoGroup groupWithIdentifier: newUID inDomain: domain]; - if (group) - newUID = [NSString stringWithFormat: @"@%@", newUID]; - } - ASSIGN (uid, newUID); - clientObject = [self clientObject]; - [userRights addObjectsFromArray: [clientObject aclsForUser: uid]]; + group = [SOGoGroup groupWithIdentifier: newUID inDomain: domain]; + if (group) + newUID = [NSString stringWithFormat: @"@%@", newUID]; + } - response = YES; - } + ASSIGN (uid, newUID); + clientObject = [self clientObject]; + [userRights addObjectsFromArray: [clientObject aclsForUser: uid]]; + + response = YES; + } } - return response; -} -- (BOOL) _initRightsWithParameter:(NSString *) newUID -{ - BOOL response; - NSString *domain; - SOGoUserManager *um; - SOGoObject *clientObject; - SOGoGroup *group; - - response = NO; - - if ([newUID length] > 0) - { - if (!defaultUserID) - ASSIGN (defaultUserID, [[self clientObject] defaultUserID]); - - um = [SOGoUserManager sharedUserManager]; - if ([newUID isEqualToString: defaultUserID] || [newUID isEqualToString: @"anonymous"] - || [[um getEmailForUID: newUID] length] > 0) - { - if (![newUID hasPrefix: @"@"]) - { - domain = [[context activeUser] domain]; - group = [SOGoGroup groupWithIdentifier: newUID inDomain: domain]; - if (group) - newUID = [NSString stringWithFormat: @"@%@", newUID]; - } - ASSIGN (uid, newUID); - clientObject = [self clientObject]; - [userRights addObjectsFromArray: [clientObject aclsForUser: uid]]; - - response = YES; - } - } return response; } @@ -219,32 +186,20 @@ - (id ) saveUserRightsAction { id response; - WORequest *value; SOGoDomainDefaults *dd; - NSDictionary *jsonObject, *currentObject; - NSEnumerator *enumerator; - NSArray *o; - id key; - value = [[self context] request]; - jsonObject = [[value contentAsString] objectFromJSONString]; - enumerator = [jsonObject keyEnumerator]; + if (![self _initRights]) + response = [NSException exceptionWithHTTPStatus: 403 + reason: @"No such user."]; + else + { + NSArray *o; - while((key = [enumerator nextObject])) - { - currentObject = [jsonObject objectForKey: key]; - if(![self _initRightsWithParameter: [currentObject objectForKey: @"UID"]]) - { - response = [self responseWithStatus: 403 - andString: @"No such user."]; - return response; - } - else - { - [self updateRights:[currentObject objectForKey: @"aclOptions"]]; - [[self clientObject] setRoles: userRights forUser: uid]; - o = [NSArray arrayWithArray: userRights]; + + [self updateRights]; + [[self clientObject] setRoles: userRights forUser: uid]; + dd = [[context activeUser] domainDefaults]; if (![o isEqualToArray: userRights] && [dd aclSendEMailNotifications]) [self sendACLAdvisoryTemplateForObject: [self clientObject]]; @@ -279,6 +234,10 @@ [userRights removeObjectsInArray: list]; } +- (void) prepareRightsForm +{ +} + - (void) updateRights { [self subclassResponsibility: _cmd]; diff --git a/UI/Templates/ContactsUI/UIxContactFoldersView.wox b/UI/Templates/ContactsUI/UIxContactFoldersView.wox index d009fe24b..48916b8df 100644 --- a/UI/Templates/ContactsUI/UIxContactFoldersView.wox +++ b/UI/Templates/ContactsUI/UIxContactFoldersView.wox @@ -61,77 +61,6 @@
- -
diff --git a/UI/WebServerResources/js/Common/resource.js b/UI/WebServerResources/js/Common/resource.js index f5ce3868e..2c78f7416 100644 --- a/UI/WebServerResources/js/Common/resource.js +++ b/UI/WebServerResources/js/Common/resource.js @@ -108,41 +108,4 @@ return deferred.promise; }; - - /** - * @function fetch - * @desc Fetch resources using a specific object, action and/or parameters - * @param {string} object_id - the object on which the action will be applied (ex: addressbook, calendar) - * @param {string} action - the action to be used in the URL - * @param {string} params - the url parameter - */ - Resource.prototype.fetch = function(object_id, action, params) { - var deferred = this._q.defer(); - var object_id_path = object_id ? ("/" + object_id) : ""; - var action_path = action ? ("/" + action) : ""; - var params_path = params ? ("?" + params) : ""; - - var path = this._path + object_id_path + action_path + params_path; - - this._http - .get(path) - .success(deferred.resolve) - .error(deferred.reject); - - return deferred.promise; - }; - - Resource.prototype.saveAclUsers = function(object_id, action, data) { - var deferred = this._q.defer(); - var object_id_path = object_id ? ("/" + object_id) : ""; - var action_path = action ? ("/" + action) : ""; - var path = this._path + object_id_path + action_path; - - this._http - .post(path, data) - .success(deferred.resolve) - .error(deferred.reject); - - return deferred.promise; - }; })(); diff --git a/UI/WebServerResources/js/ContactsUI.js b/UI/WebServerResources/js/ContactsUI.js index 7d57c291d..7a7c24a37 100644 --- a/UI/WebServerResources/js/ContactsUI.js +++ b/UI/WebServerResources/js/ContactsUI.js @@ -182,80 +182,6 @@ $scope.closeModal = function() { $modalInstance.close(); }; - $scope.saveModal = function() { - if(Object.keys(dirtyObjects).length > 0) { - $scope.AclUsers.saveUsersRights(dirtyObjects); - } - $modalInstance.close(); - }; - $scope.removeUser = function() { - if ($scope.userSelected) { - if(dirtyObjects[$scope.userSelected.UID]) - delete dirtyObjects[$scope.userSelected.UID]; - $scope.AclUsers.removeUser($scope.userSelected); - $scope.AclUsers.getUsers().then(function(data) { - $scope.users = data; - }); - $scope.userSelected = {}; - } - }; - $scope.addUser = function (user) { - if (user) { - angular.forEach($scope.userObjects, function(userObject) { - if (user.indexOf(userObject.uid) != -1) { - var test = true; - angular.forEach($scope.users, function(userData) { - if (user.indexOf(userData.UID) != -1) { - test = false; - } - }) - if (test) { - $scope.AclUsers.addUser(userObject.uid); - $scope.AclUsers.getUsers().then(function(data) { - $scope.users = data; - }); - } - else { - // TODO : Write a better msg and add the string inside the .string - Dialog.alert(l('Warning'), l('This user is already added to your AclUsers list')); - } - } - }); - } - }; - $scope.selectUser = function(index) { - // Check if it is a different user - if ($scope.userSelected != $scope.users[index]){ - $scope.userSelected = {}; - $scope.selected = index; - $scope.userSelected = $scope.users[index]; - - if (dirtyObjects[$scope.userSelected.UID]) { - $scope.userSelected.aclOptions = dirtyObjects[$scope.userSelected.UID].aclOptions; - } - else { - $scope.AclUsers.openRightsForUserId($scope.userSelected.UID).then(function(userRights) { - $scope.userSelected.aclOptions = userRights; - }); - } - } - }; - $scope.getContacts = function(value){ - return $scope.AclUsers.searchUsers(value).then(function(response) { - $scope.usersFound = []; - $scope.userObjects = response; - angular.forEach(response, function(userObject){ - $scope.usersFound.push(userObject.displayName + " <" + userObject.email + ">"); - }); - return $scope.usersFound; - }); - }; - $scope.dirtyObjects = function() { - dirtyObjects[$scope.userSelected.UID] = $scope.userSelected; - }; - $scope.displayUserRights = function() { - return ($scope.userSelected && $scope.userSelected.UID != "anonymous") ? true : false; - }; } }); };