mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 04:09:20 +00:00
Send group membreship requests to the server.
This commit is contained in:
parent
f90dc5d9ae
commit
d32c1428cf
@ -143,6 +143,21 @@ ComunicWeb.components.groups.interface = {
|
||||
id: id
|
||||
};
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Send a request to join a group
|
||||
*
|
||||
* @param {Number} id The ID of the target group
|
||||
* @param {Function} callback
|
||||
*/
|
||||
sendRequest: function(id, callback){
|
||||
//Perform the request over the API
|
||||
var apiURI = "groups/send_request";
|
||||
var params = {
|
||||
id: id
|
||||
};
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
},
|
||||
|
||||
};
|
@ -163,6 +163,39 @@ ComunicWeb.pages.groups.sections.membershipBlock = {
|
||||
})
|
||||
}
|
||||
|
||||
//Check if the user is only a simple visitor
|
||||
if(info.membership == "visitor"){
|
||||
|
||||
//Check if the registration is closed
|
||||
if(info.registration_level == "closed"){
|
||||
add_p(container, "Only a moderator can invite you to join this group.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Offer the user to join the group
|
||||
var joinGroup = createElem2({
|
||||
appendTo: container,
|
||||
type: "span",
|
||||
class: "a",
|
||||
innerHTML: "Join this group"
|
||||
});
|
||||
|
||||
joinGroup.addEventListener("click", function(e){
|
||||
|
||||
ComunicWeb.components.groups.interface.sendRequest(info.id, function(result){
|
||||
|
||||
//Check for errors
|
||||
if(result.error)
|
||||
notify("An error occurred while trying to send a membership request to the server!", "danger");
|
||||
|
||||
//Refresh current page
|
||||
ComunicWeb.common.page.refresh_current_page();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
Loading…
Reference in New Issue
Block a user