mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +00:00
Display posts creation form on groups pages.
This commit is contained in:
parent
07af7c961d
commit
5c0cdced85
@ -23,6 +23,26 @@ ComunicWeb.components.groups.utils = {
|
|||||||
|
|
||||||
return IDs;
|
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;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
@ -65,6 +65,28 @@ ComunicWeb.pages.groups.pages.group = {
|
|||||||
//Display the header for the group
|
//Display the header for the group
|
||||||
ComunicWeb.pages.groups.sections.header.display(info, headerColumn);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -292,7 +292,7 @@ ComunicWeb.pages.groups.pages.settings = {
|
|||||||
//Moderators only
|
//Moderators only
|
||||||
createFormGroup({
|
createFormGroup({
|
||||||
target: postsLevelsForm,
|
target: postsLevelsForm,
|
||||||
label: "Moderators and moderators only can create groups",
|
label: "Administrators and moderators only can create groups",
|
||||||
name: "group-posts-level",
|
name: "group-posts-level",
|
||||||
type: "radio",
|
type: "radio",
|
||||||
value: "moderators",
|
value: "moderators",
|
||||||
|
@ -18,14 +18,14 @@ ComunicWeb.pages.groups.sections.header = {
|
|||||||
var headerContainer = createElem2({
|
var headerContainer = createElem2({
|
||||||
appendTo: target,
|
appendTo: target,
|
||||||
type: "div",
|
type: "div",
|
||||||
class: "group-header"
|
class: "group-header box box-primary"
|
||||||
});
|
});
|
||||||
|
|
||||||
//Create a row
|
//Create a row
|
||||||
var row = createElem2({
|
var row = createElem2({
|
||||||
appendTo: headerContainer,
|
appendTo: headerContainer,
|
||||||
type: "div",
|
type: "div",
|
||||||
class: "row"
|
class: "box-body row"
|
||||||
});
|
});
|
||||||
|
|
||||||
//First column
|
//First column
|
||||||
|
Loading…
Reference in New Issue
Block a user