file lost through rebasing

This commit is contained in:
Alexandre Cloutier
2014-10-01 14:27:58 -04:00
committed by Francis Lachapelle
parent edbd661104
commit 3bf1224c9b
8 changed files with 260 additions and 87 deletions
@@ -0,0 +1,54 @@
(function() {
'use strict';
function AclUsers(addressbook) {
this.addressbook_id = addressbook.id;
this.addressbook_name = addressbook.name;
this.addressbook_owner = addressbook.owner;
}
/* The factory we'll use to register with Angular */
AclUsers.factory = ['$q', '$timeout', 'sgSettings', 'sgResource', function($q, $timeout, Settings, Resource) {
angular.extend(AclUsers, {
$q: $q,
$timeout: $timeout,
$$resource: new Resource(Settings.baseURL)
});
return AclUsers; // return constructor
}];
/* Factory registration in Angular module */
angular.module('SOGo.Common').factory('sgAclUsers', AclUsers.factory);
/* Instance methods
* Public method, assigned to prototype
*/
AclUsers.prototype.getUsers = function() {
return AclUsers.$$resource.fetch(this.addressbook_id, "getUsersForObject");
};
AclUsers.prototype.searchUsers = function(inputText) {
var param = "search=" + inputText;
return AclUsers.$$resource.fetch(null, "usersSearch", param);
};
AclUsers.prototype.openRightsForUserId = function(user) {
var param = "uid=" + user;
return AclUsers.$$resource.fetch(this.addressbook_id, "userRights", param);
};
AclUsers.prototype.addUser = function(user) {
var param = "uid=" + user;
AclUsers.$$resource.fetch(this.addressbook_id, "addUserInAcls", param);
};
AclUsers.prototype.removeUser = function(user) {
var userId = "uid=" + user.UID;
AclUsers.$$resource.fetch(this.addressbook_id, "removeUserFromAcls", userId);
};
AclUsers.prototype.saveUsersRights = function(dirtyObjects) {
AclUsers.$$resource.saveAclUsers(this.addressbook_id, "saveUserRights", dirtyObjects);
};
})();
+13 -1
View File
@@ -173,7 +173,19 @@
$scope.share = function() {
var modal = $modal.open({
templateUrl: 'addressbookSharing.html',
controller: function($scope, $modalInstance) {
controller: function($scope, $http, $modalInstance, sgAclUsers) {
/* Variables for the scope */
$scope.AclUsers = new sgAclUsers($rootScope.addressbook);
$scope.userObjects = {};
$scope.AclUsers.getUsers().then(function(data) {
$scope.users = data;
});
var dirtyObjects = {};
/* Functions */
$scope.removeButton = function() {
return ($scope.userSelected && $scope.userSelected.userClass != "public-user") ? false : true;
};
$scope.closeModal = function() {
$modalInstance.close();
};