Created search user function

This commit is contained in:
Pierre 2017-06-05 14:35:28 +02:00
parent b7eb77b928
commit c66b40a137
2 changed files with 34 additions and 0 deletions

View File

@ -352,6 +352,11 @@ var ComunicWeb = {
* Remove all entries from user informations cache
*/
emptyUserInfosCache: function(){},
/**
* Given a query, search for users and return the result
*/
search: function(query, afterSearch){},
},
},

View File

@ -136,4 +136,33 @@ ComunicWeb.user.userInfos = {
return true;
},
/**
* Given a query, search for users and return the result
*
* @param {String} query The query to search
* @param {Function} afterSearch What to do once we got results
* @return {Boolean} True for a success
*/
search: function(query, afterSearch){
//Perform a request on the server
apiURI = "user/search";
params = {
query: query,
};
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(response){
//Continue only in case of success
if(response.error){
afterSearch(false);
return false;
}
//Preload users informations
ComunicWeb.user.userInfos.getMultipleUsersInfos(response, function(usersInfos){
//Go to next action
afterSearch(usersInfos);
});
});
}
}