2018-07-07 13:27:27 +00:00
|
|
|
/**
|
|
|
|
* Groups utilities
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
|
|
|
|
|
|
|
ComunicWeb.components.groups.utils = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extract users ids from members list
|
|
|
|
*
|
|
|
|
* @param {Array} list The list of members to process
|
|
|
|
* @return {Array} The list of the IDs of the members of group
|
|
|
|
*/
|
|
|
|
getMembersIDs: function(list){
|
|
|
|
|
|
|
|
var IDs = [];
|
|
|
|
|
|
|
|
//Process the list of IDs
|
|
|
|
list.forEach(function(member){
|
|
|
|
IDs.push(member.user_id);
|
|
|
|
});
|
|
|
|
|
|
|
|
return IDs;
|
|
|
|
|
2018-07-16 07:13:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether a user can create posts for a group or not
|
|
|
|
*
|
|
|
|
* @param {Object} info Information about the target group
|
|
|
|
* @return {boolean} TRUE if the user can create a post / FALSE else
|
|
|
|
*/
|
|
|
|
canCreatePosts: function(info){
|
|
|
|
|
|
|
|
//Administrator and moderators can always create posts
|
|
|
|
if(info.membership == "administrator" || info.membership == "moderator")
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if(info.membership == "member" && info.posts_level == "members")
|
|
|
|
return true;
|
|
|
|
|
|
|
|
//In all the other case, the user can not create posts
|
|
|
|
return false;
|
|
|
|
|
|
|
|
},
|
2018-07-07 13:27:27 +00:00
|
|
|
|
|
|
|
}
|