From a100d4a4032623795852d8d6f2f199c3d8570557 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 5 Jul 2018 08:38:52 +0200 Subject: [PATCH] Display when the user is a moderator, a administrator or a member of a group. --- assets/js/common/functionsSchema.js | 6 +++ assets/js/pages/groups/pages/forbidden.js | 7 +++ assets/js/pages/groups/sections/header.js | 4 ++ .../pages/groups/sections/membershipBlock.js | 47 +++++++++++++++++++ system/config/dev.config.php | 1 + 5 files changed, 65 insertions(+) create mode 100644 assets/js/pages/groups/sections/membershipBlock.js diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 6a33137e..9cb93aaf 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -1247,6 +1247,12 @@ var ComunicWeb = { //TODO : implement }, + /** + * Membership block + */ + membershipBlock: { + //TODO : implement + }, }, }, diff --git a/assets/js/pages/groups/pages/forbidden.js b/assets/js/pages/groups/pages/forbidden.js index 083617ea..72fb7e10 100644 --- a/assets/js/pages/groups/pages/forbidden.js +++ b/assets/js/pages/groups/pages/forbidden.js @@ -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); }, } \ No newline at end of file diff --git a/assets/js/pages/groups/sections/header.js b/assets/js/pages/groups/sections/header.js index 1c2b87ba..cd665c44 100644 --- a/assets/js/pages/groups/sections/header.js +++ b/assets/js/pages/groups/sections/header.js @@ -72,6 +72,10 @@ ComunicWeb.pages.groups.sections.header = { innerHTML: ' '+ 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"){ diff --git a/assets/js/pages/groups/sections/membershipBlock.js b/assets/js/pages/groups/sections/membershipBlock.js new file mode 100644 index 00000000..50f47e74 --- /dev/null +++ b/assets/js/pages/groups/sections/membershipBlock.js @@ -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: " Administrator" + }); + + if(info.membership == "moderator") + return createElem2({ + appendTo: container, + type: "span", + innerHTML: " Moderator" + }); + + if(info.membership == "member") + return createElem2({ + appendTo: container, + type: "span", + innerHTML: " Member" + }); + + } + +}; \ No newline at end of file diff --git a/system/config/dev.config.php b/system/config/dev.config.php index 61d92557..54f97452 100644 --- a/system/config/dev.config.php +++ b/system/config/dev.config.php @@ -432,6 +432,7 @@ class Dev { //Groups sections "js/pages/groups/sections/header.js", + "js/pages/groups/sections/membershipBlock.js", //User settings page