diff --git a/assets/js/components/groups/utils.js b/assets/js/components/groups/utils.js index 02fc15c6..6afaafe6 100644 --- a/assets/js/components/groups/utils.js +++ b/assets/js/components/groups/utils.js @@ -23,6 +23,26 @@ ComunicWeb.components.groups.utils = { return IDs; - } + }, + + /** + * 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; + + }, } \ No newline at end of file diff --git a/assets/js/pages/groups/pages/group.js b/assets/js/pages/groups/pages/group.js index 7ac94b5a..0a4d4459 100644 --- a/assets/js/pages/groups/pages/group.js +++ b/assets/js/pages/groups/pages/group.js @@ -65,6 +65,28 @@ ComunicWeb.pages.groups.pages.group = { //Display the header for the group ComunicWeb.pages.groups.sections.header.display(info, headerColumn); + + //Check if the user can create posts or not + if(ComunicWeb.components.groups.utils.canCreatePosts(info)){ + + //Intialize posts creation form + var postFormRow = createElem2({ + appendTo: target, + type: "div", + class: "row group-page" + }); + + //Add column + var postFormCol = createElem2({ + appendTo: postFormRow, + type: "div", + class: "col-md-6" + }); + + //Display form + ComunicWeb.components.posts.form.display("group", id, postFormCol); + } + } } \ No newline at end of file diff --git a/assets/js/pages/groups/pages/settings.js b/assets/js/pages/groups/pages/settings.js index 461edb30..ca6b7ffd 100644 --- a/assets/js/pages/groups/pages/settings.js +++ b/assets/js/pages/groups/pages/settings.js @@ -292,7 +292,7 @@ ComunicWeb.pages.groups.pages.settings = { //Moderators only createFormGroup({ target: postsLevelsForm, - label: "Moderators and moderators only can create groups", + label: "Administrators and moderators only can create groups", name: "group-posts-level", type: "radio", value: "moderators", diff --git a/assets/js/pages/groups/sections/header.js b/assets/js/pages/groups/sections/header.js index de01c4f8..95f1b2dc 100644 --- a/assets/js/pages/groups/sections/header.js +++ b/assets/js/pages/groups/sections/header.js @@ -18,14 +18,14 @@ ComunicWeb.pages.groups.sections.header = { var headerContainer = createElem2({ appendTo: target, type: "div", - class: "group-header" + class: "group-header box box-primary" }); //Create a row var row = createElem2({ appendTo: headerContainer, type: "div", - class: "row" + class: "box-body row" }); //First column