2017-05-25 11:50:32 +00:00
|
|
|
/**
|
|
|
|
* This file contains shorcuts to ease access of common functions
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
2017-05-25 11:55:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a quick language access function shorcut
|
|
|
|
*
|
|
|
|
* @param {String} stringName The name of the string to show
|
|
|
|
* @param {Array} stringParams The optionnal parametres to include with the string
|
|
|
|
* @return {String} The string ready to show
|
|
|
|
*/
|
|
|
|
function lang(stringName, stringParams){
|
|
|
|
//Check if any params has been specified
|
|
|
|
if(!stringParams)
|
|
|
|
var stringParams = [];
|
|
|
|
|
|
|
|
//Call translate function
|
|
|
|
return ComunicWeb.common.langs.getTranslatedText(stringName, stringParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to change currently opened page
|
|
|
|
*
|
|
|
|
* @param {String} pageURI The URI to the page
|
|
|
|
* @param {Object} additionnalData Additionnal data to pass to the new page
|
|
|
|
* @return {Boolean} True for a success
|
|
|
|
*/
|
|
|
|
function openPage(pageURI, additionnalData){
|
|
|
|
return ComunicWeb.common.page.openPage(pageURI, additionnalData);
|
2017-06-13 09:58:08 +00:00
|
|
|
}
|
|
|
|
|
2017-12-17 18:17:03 +00:00
|
|
|
/**
|
|
|
|
* Open a user page quickly
|
|
|
|
*
|
|
|
|
* @param {String} user The ID of the user or its directory
|
|
|
|
* @return {Boolean} True for a success
|
|
|
|
*/
|
|
|
|
function openUserPage(user){
|
2018-07-14 12:18:21 +00:00
|
|
|
if(user.virtualDirectory == "")
|
|
|
|
openUserPageFromID(user.userID);
|
|
|
|
else
|
|
|
|
openPage(user.virtualDirectory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a user page quickly from its user ID
|
|
|
|
*
|
|
|
|
* @param {String} user The ID of the user or its directory
|
|
|
|
* @return {Boolean} True for a success
|
|
|
|
*/
|
|
|
|
function openUserPageFromID(user){
|
2017-12-17 18:17:03 +00:00
|
|
|
return openPage("user/" + user);
|
|
|
|
}
|
|
|
|
|
2018-07-16 13:13:17 +00:00
|
|
|
/**
|
|
|
|
* Open a group age
|
|
|
|
*
|
|
|
|
* @param {Object} info Information about the target group
|
|
|
|
*/
|
|
|
|
function openGroupPage(info){
|
|
|
|
|
|
|
|
if(info.virtual_directory != "null")
|
|
|
|
openPage(info.virtual_directory);
|
|
|
|
else
|
|
|
|
openPage("groups/" + info.id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-16 13:43:31 +00:00
|
|
|
/**
|
|
|
|
* Check if user is signed in or not
|
|
|
|
*
|
|
|
|
* @return {Boolean} True if the user is signed in / false else
|
|
|
|
*/
|
|
|
|
function signed_in(){
|
|
|
|
return ComunicWeb.user.userLogin.getUserLoginState();
|
|
|
|
}
|
|
|
|
|
2017-06-13 09:58:08 +00:00
|
|
|
/**
|
|
|
|
* Returns user ID (if logged in)
|
|
|
|
*
|
|
|
|
* @param Nothing
|
|
|
|
* @return {Integer} The ID of the user
|
|
|
|
*/
|
|
|
|
function userID(){
|
|
|
|
return ComunicWeb.user.userLogin.getUserID();
|
|
|
|
}
|
|
|
|
|
2018-01-21 19:20:10 +00:00
|
|
|
/**
|
|
|
|
* Returns the full name of a user
|
|
|
|
*
|
|
|
|
* @param {Object} infos Informations about the user
|
|
|
|
* @return {String} The full name of the user
|
|
|
|
*/
|
|
|
|
function userFullName(infos){
|
|
|
|
return infos.firstName + " " + infos.lastName;
|
|
|
|
}
|
|
|
|
|
2018-01-02 17:58:40 +00:00
|
|
|
/**
|
|
|
|
* Return the ID of a user, or its path, depending of what
|
|
|
|
* is available
|
|
|
|
*
|
|
|
|
* @param {Object} infos Informations about the user
|
|
|
|
* @return {String} The ID of the user, or it's path
|
|
|
|
*/
|
|
|
|
function userIDorPath(infos){
|
|
|
|
return ComunicWeb.user.userInfos.getIDorPath(infos);
|
|
|
|
}
|
|
|
|
|
2017-06-13 09:58:08 +00:00
|
|
|
/**
|
|
|
|
* Get multiple users informations
|
|
|
|
*
|
|
|
|
* @param {Array~Object} usersID User on which to make request (current to get connected user)
|
|
|
|
* @param {function} afterGetUserInfos What to do once users informations are available
|
|
|
|
* @param {Boolean} forceRequest Force the request to be made
|
|
|
|
* @return {Boolean} True for a success
|
|
|
|
*/
|
2017-06-13 14:42:09 +00:00
|
|
|
function getMultipleUsersInfos(usersID, afterGetUserInfos, forceRequest){
|
2017-06-13 09:58:08 +00:00
|
|
|
ComunicWeb.user.userInfos.getMultipleUsersInfos(usersID, afterGetUserInfos, forceRequest);
|
2017-12-10 09:57:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display message on browser console
|
|
|
|
*
|
|
|
|
* @param {String} message The message to show on browser console
|
|
|
|
*/
|
|
|
|
function log(message){
|
|
|
|
ComunicWeb.debug.logMessage(message);
|
2018-02-25 17:28:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a conversation specified by its ID
|
|
|
|
*
|
|
|
|
* @param {number} id The ID of the conversation to open
|
|
|
|
*/
|
|
|
|
function openConversation(id){
|
|
|
|
ComunicWeb.components.conversations.manager.addConversation({
|
|
|
|
conversationID: id
|
|
|
|
});
|
2018-04-11 08:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display a notification
|
|
|
|
*
|
|
|
|
* @param {string} message The message of the notification
|
|
|
|
* @param {string} type The type of the notification (danger, info, success, primary)
|
|
|
|
* @param {number} duration The notification duration
|
|
|
|
* @param {string} title The title of the notification
|
|
|
|
*/
|
|
|
|
function notify(message, type, duration, title){
|
|
|
|
ComunicWeb.common.notificationSystem.showNotification(message, type, duration, title)
|
2018-07-20 07:07:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get information about a single group
|
|
|
|
*
|
|
|
|
* @param {Number} id The ID of the group to fetch
|
|
|
|
* @param {Function} callback
|
|
|
|
*/
|
|
|
|
function getInfoGroup(id, callback){
|
|
|
|
ComunicWeb.components.groups.info.getInfo(id, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get information about multiple groups
|
|
|
|
*
|
|
|
|
* @param {Array} IDs The IDs of the groups to get information about
|
|
|
|
* @param {Function} callback Callback to call once we have information about the group
|
|
|
|
*/
|
|
|
|
function getInfoMultipleGroups(IDs, callback){
|
|
|
|
ComunicWeb.components.groups.info.getInfoMultiple(IDs, callback);
|
2017-05-25 11:55:49 +00:00
|
|
|
}
|