Delete groups

This commit is contained in:
Marijn Jansen
2017-02-03 10:44:50 +01:00
parent 74e91ed7cb
commit 28e9269b52
5 changed files with 45 additions and 10 deletions

View File

@@ -60,7 +60,7 @@ function checkGroupAdmin(int $groupID, int $userID) : bool {
return ($role == "admin");
}
function getAllGroupMembers(int $groupID) {
function getAllGroupUsers(int $groupID) {
$stmt = prepareQuery("
SELECT
`username`,
@@ -106,4 +106,23 @@ function upgradeUser(int $groupID, int $userID, string $role) {
} else {
throw new AngryAlert("Er is iets mis gegaan");
}
}
function deleteGroup() {
if (!checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) {
throw new AngryAlert("Geen toestemming om de groep te verwijderen!");
}
$stmt = prepareQuery("
DELETE FROM
`group_page`
WHERE
`groupID` = :groupID
");
$stmt->bindValue(":groupID", $_POST["groupID"]);
$stmt->execute();
if ($stmt->rowCount()) {
throw new HappyAlert("Group verwijderd!");
} else {
throw new AngryAlert("Er is iets mis gegaan");
}
}

View File

@@ -16,7 +16,10 @@ function getSettings() {
`location`,
`birthdate`,
`bio`,
`profilepicture`,
IFNULL(
`profilepicture`,
'../img/avatar-standard.png'
) AS profilepicture,
`showBday`,
`showEmail`,
`showProfile`