diff --git a/assets/css/pages/groups/pages/settings.css b/assets/css/pages/groups/pages/settings.css new file mode 100644 index 00000000..b75fca8e --- /dev/null +++ b/assets/css/pages/groups/pages/settings.css @@ -0,0 +1,16 @@ +/** + * Group settings stylesheet + * + * @author Pierre HUBERT + */ + +.group-settings-container { + float: none; + margin: auto; + margin-top: 40px; +} + +.group-settings-container .title { + text-align: center; + margin-bottom: 15px; +} \ No newline at end of file diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index a3594a1b..0c0ddd5f 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -1219,6 +1219,13 @@ var ComunicWeb = { //TODO : implement }, + /** + * Settings page + */ + settings: { + //TODO : implement + }, + }, /** diff --git a/assets/js/components/groups/interface.js b/assets/js/components/groups/interface.js index 272c4e2e..91167776 100644 --- a/assets/js/components/groups/interface.js +++ b/assets/js/components/groups/interface.js @@ -50,6 +50,21 @@ ComunicWeb.components.groups.interface = { id: id }; ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback); + }, + + /** + * Get the settings of a group + * + * @param {Number} id The ID of the target group + * @param {Function} callback + */ + getSettings: function(id, callback){ + //Perform the request over the API + var apiURI = "groups/get_settings"; + var params = { + id: id + }; + ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback); } }; \ No newline at end of file diff --git a/assets/js/pages/groups/main.js b/assets/js/pages/groups/main.js index b76d2633..c4c2bd4d 100644 --- a/assets/js/pages/groups/main.js +++ b/assets/js/pages/groups/main.js @@ -54,9 +54,12 @@ ComunicWeb.pages.groups.main = { } //Check which page to open - if(page == "group"){ + if(page == "group") ComunicWeb.pages.groups.pages.group.open(groupID, target); - } + + else if(page == "settings") + ComunicWeb.pages.groups.pages.settings.open(groupID, target); + //Unrecognized page else diff --git a/assets/js/pages/groups/pages/group.js b/assets/js/pages/groups/pages/group.js index 365eba7c..41119f15 100644 --- a/assets/js/pages/groups/pages/group.js +++ b/assets/js/pages/groups/pages/group.js @@ -21,7 +21,7 @@ ComunicWeb.pages.groups.pages.group = { if(result.error){ //Check the code of the error - if(result.error.code == 404){ + if(result.error.code == 401){ need_auth;//TODO : implement } diff --git a/assets/js/pages/groups/pages/settings.js b/assets/js/pages/groups/pages/settings.js new file mode 100644 index 00000000..c5192df8 --- /dev/null +++ b/assets/js/pages/groups/pages/settings.js @@ -0,0 +1,87 @@ +/** + * Page settings + * + * @author Pierre HUBERT + */ + +ComunicWeb.pages.groups.pages.settings = { + + /** + * Open group settings page + * + * @param {Number} id The ID of the settings page + * @param {HTMLElement} target The target of the page + */ + open: function(id, target){ + + //Create settings container + var settingsContainer = createElem2({ + appendTo: target, + type: "div", + class: "group-settings-container col-md-6" + }); + + //Add title + createElem2({ + appendTo: settingsContainer, + type: "h2", + class: "title", + innerHTML: "Group settings" + }); + + //Display loading message + var loadingMsg = ComunicWeb.common.messages.createCalloutElem( + "Loading", + "Please wait while we retrieve the settings of the page...", + "info"); + settingsContainer.appendChild(loadingMsg); + + //Get the settings of the page + ComunicWeb.components.groups.interface.getSettings(id, function(result){ + + //Remove loading message + loadingMsg.remove(); + + //Check for error + if(result.error){ + + //Check if the user is not authorized to access the page + if(result.error.code == 401){ + //The user is not authorized to see this page + settingsContainer.appendChild(ComunicWeb.common.messages.createCalloutElem( + "Access forbidden", + "You are not authorized to access these information !", + "danger" + )); + } + + //Else the page was not found + else { + settingsContainer.remove(); + ComunicWeb.common.error.pageNotFound({}, target); + } + + } + + else { + //Display settings pages + ComunicWeb.pages.groups.pages.settings.display(id, result, target); + } + + }); + + }, + + /** + * Display page settings + * + * @param {Number} id The ID of the target page + * @param {Object} settings The settings of the page + * @param {HTMLElement} target The target of the page + */ + display: function(id, settings, target){ + + alert(settings); + + }, +} \ 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 255ff358..7593c9fb 100644 --- a/assets/js/pages/groups/sections/header.js +++ b/assets/js/pages/groups/sections/header.js @@ -71,6 +71,20 @@ ComunicWeb.pages.groups.sections.header = { type: "div", innerHTML: ' '+ info.number_members+' members' }); + + //If the user is an admin, add a link to configure the page + if(signed_in() && info.membership == "administrator"){ + + var settingsLink = createElem2({ + appendTo: secondColumn, + type: "div", + class: "a", + innerHTML: " Settings" + }); + settingsLink.addEventListener("click", function(e){ + openPage("groups/" + info.id + "/settings"); + }); + } }, }; \ No newline at end of file diff --git a/system/config/dev.config.php b/system/config/dev.config.php index 5bc960f0..5c59c974 100644 --- a/system/config/dev.config.php +++ b/system/config/dev.config.php @@ -221,6 +221,7 @@ class Dev { "css/pages/groups/pages/main.css", "css/pages/groups/pages/create.css", "css/pages/groups/pages/group.css", + "css/pages/groups/pages/settings.css", //Groups sections "css/pages/groups/sections/header.css", @@ -425,6 +426,7 @@ class Dev { "js/pages/groups/pages/main.js", "js/pages/groups/pages/create.js", "js/pages/groups/pages/group.js", + "js/pages/groups/pages/settings.js", //Groups sections "js/pages/groups/sections/header.js",