mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-03 22:22:19 +00:00
Created user-modal.js, code refactoring
Conflicts: UI/Common/UIxAclEditor.m UI/Common/UIxUserRightsEditor.m UI/Common/product.plist UI/Contacts/UIxContactsUserRightsEditor.m UI/Templates/ContactsUI/UIxContactFoldersView.wox UI/WebServerResources/js/Common/resource.js UI/WebServerResources/js/ContactsUI.js
This commit is contained in:
committed by
Francis Lachapelle
parent
ff5b25972f
commit
3f27e9bb57
@@ -1,10 +1,8 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
function AclUsers(addressbook) {
|
||||
this.addressbook_id = addressbook.id;
|
||||
this.addressbook_name = addressbook.name;
|
||||
this.addressbook_owner = addressbook.owner;
|
||||
function AclUsers(folder) {
|
||||
this.folder_id = folder.id;
|
||||
}
|
||||
|
||||
/* The factory we'll use to register with Angular */
|
||||
@@ -24,36 +22,29 @@
|
||||
/* Instance methods
|
||||
* Public method, assigned to prototype
|
||||
*/
|
||||
AclUsers.prototype.getUsers = function() {
|
||||
return AclUsers.$$resource.fetch(this.addressbook_id, "getUsersForObject");
|
||||
AclUsers.prototype.userRights = function(uid) {
|
||||
var param = {"uid": uid};
|
||||
return AclUsers.$$resource.fetch(this.folder_id, "userRights", param);
|
||||
};
|
||||
|
||||
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(uid) {
|
||||
var param = {"uid": uid};
|
||||
AclUsers.$$resource.fetch(this.folder_id, "addUserInAcls", param);
|
||||
};
|
||||
|
||||
AclUsers.prototype.addUser = function(user) {
|
||||
var param = "uid=" + user;
|
||||
AclUsers.$$resource.fetch(this.addressbook_id, "addUserInAcls", param);
|
||||
};
|
||||
|
||||
AclUsers.prototype.subscribeUsers = function(users) {
|
||||
var param = "uids=" + users;
|
||||
AclUsers.$$resource.fetch(this.addressbook_id, "subscribeUsers", param);
|
||||
};
|
||||
|
||||
AclUsers.prototype.removeUser = function(user) {
|
||||
var userId = "uid=" + user.uid;
|
||||
AclUsers.$$resource.fetch(this.addressbook_id, "removeUserFromAcls", userId);
|
||||
AclUsers.prototype.removeUser = function(uid) {
|
||||
var param = {"uid": uid};
|
||||
AclUsers.$$resource.fetch(this.folder_id, "removeUserFromAcls", param);
|
||||
};
|
||||
|
||||
AclUsers.prototype.saveUsersRights = function(dirtyObjects) {
|
||||
AclUsers.$$resource.saveAclUsers(this.addressbook_id, "saveUserRights", dirtyObjects);
|
||||
var param = {"action": "saveUserRights"};
|
||||
AclUsers.$$resource.save(this.folder_id, dirtyObjects, param);
|
||||
};
|
||||
|
||||
AclUsers.prototype.subscribeUsers = function(uids) {
|
||||
var param = {"uids": uids};
|
||||
AclUsers.$$resource.fetch(this.folder_id, "subscribeUsers", param);
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -84,10 +84,10 @@
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
Resource.prototype.save = function(uid, newValue, options) {
|
||||
Resource.prototype.save = function(id, newValue, options) {
|
||||
var deferred = this._q.defer(),
|
||||
action = (options && options.action)? options.action : 'save',
|
||||
path = this._path + '/' + uid + '/' + action;
|
||||
path = this._path + '/' + id + '/' + action;
|
||||
|
||||
this._http
|
||||
.post(path, newValue)
|
||||
@@ -108,4 +108,29 @@
|
||||
|
||||
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 {Object} params - Object parameters injected through the $http protocol
|
||||
*/
|
||||
Resource.prototype.fetch = function(folder_id, action, params) {
|
||||
var deferred = this._q.defer();
|
||||
var folder_id_path = folder_id ? ("/" + folder_id) : "";
|
||||
var action_path = action ? ("/" + action) : "";
|
||||
|
||||
var path = this._path + folder_id_path + action_path;
|
||||
|
||||
this._http({
|
||||
method: 'GET',
|
||||
url: path,
|
||||
params: params
|
||||
})
|
||||
.success(deferred.resolve)
|
||||
.error(deferred.reject);
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
* Public method, assigned to prototype
|
||||
*/
|
||||
User.prototype.$filter = function(search) {
|
||||
// return a collections of users for a filter
|
||||
// return a collections of users for a filter
|
||||
var param = {search: search};
|
||||
return User.$$resource.fetch(null, "usersSearch", param).then(function(results) {
|
||||
return User.$$resource.fetch(null, "usersSearch", param).then(function(results) {
|
||||
return results;
|
||||
})
|
||||
};
|
||||
})();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user