Display when the user is a moderator, a administrator or a member of a group.

This commit is contained in:
Pierre HUBERT 2018-07-05 08:38:52 +02:00
parent 9866298f19
commit a100d4a403
5 changed files with 65 additions and 0 deletions

View File

@ -1247,6 +1247,12 @@ var ComunicWeb = {
//TODO : implement
},
/**
* Membership block
*/
membershipBlock: {
//TODO : implement
},
},
},

View File

@ -90,5 +90,12 @@ ComunicWeb.pages.groups.pages.forbidden = {
innerHTML: result.name,
class: "group-name"
});
//Add a notice
add_p(boxBody, "A registration is required to access this group contents.");
//Append membership block (if the user is signed in)
if(signed_in())
ComunicWeb.pages.groups.sections.membershipBlock.display(result);
},
}

View File

@ -72,6 +72,10 @@ ComunicWeb.pages.groups.sections.header = {
innerHTML: '<i class="fa fa-group"></i> '+ info.number_members+' members'
});
//Display membership level
if(signed_in())
ComunicWeb.pages.groups.sections.membershipBlock.display(info, secondColumn);
//If the user is an admin, add a link to configure the page
if(signed_in() && info.membership == "administrator"){

View File

@ -0,0 +1,47 @@
/**
* Membership information block
*
* @author Pierre HUBERT
*/
ComunicWeb.pages.groups.sections.membershipBlock = {
/**
* Display membership block
*
* @param {Object} info Information about the membership
* @param {HTMLElement} target The target where the block will be applied
*/
display: function(info, target){
//Membership container
var container = createElem2({
appendTo: target,
type: "div"
});
//Check if the user is an administrator / moderator / member
if(info.membership == "administrator")
return createElem2({
appendTo: container,
type: "span",
innerHTML: "<i class='fa fa-check'></i> Administrator"
});
if(info.membership == "moderator")
return createElem2({
appendTo: container,
type: "span",
innerHTML: "<i class='fa fa-check'></i> Moderator"
});
if(info.membership == "member")
return createElem2({
appendTo: container,
type: "span",
innerHTML: "<i class='fa fa-check'></i> Member"
});
}
};

View File

@ -432,6 +432,7 @@ class Dev {
//Groups sections
"js/pages/groups/sections/header.js",
"js/pages/groups/sections/membershipBlock.js",
//User settings page