From c69b5d8ed359016be9f7f86ef3bd9c1dc93c5b10 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Fri, 3 Feb 2017 11:12:02 +0100 Subject: [PATCH] Comments --- website/public/groupAdmin.php | 2 ++ website/public/settings.php | 2 ++ website/queries/connect.php | 5 ++++ website/queries/createGroup.php | 4 +++ website/queries/groupAdmin.php | 51 +++++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+) diff --git a/website/public/groupAdmin.php b/website/public/groupAdmin.php index fadaa87..ec6eee8 100644 --- a/website/public/groupAdmin.php +++ b/website/public/groupAdmin.php @@ -21,6 +21,8 @@ require_once "../queries/alerts.php"; include("../views/main.php"); $alertClass; $alertMessage; + +// Select which button has been pressed. if ($_SERVER["REQUEST_METHOD"] == "POST") { try { switch ($_POST["form"]) { diff --git a/website/public/settings.php b/website/public/settings.php index 6996f54..7208141 100644 --- a/website/public/settings.php +++ b/website/public/settings.php @@ -14,6 +14,8 @@ prepare($query); } \ No newline at end of file diff --git a/website/queries/createGroup.php b/website/queries/createGroup.php index 20ee28b..1b093fb 100644 --- a/website/queries/createGroup.php +++ b/website/queries/createGroup.php @@ -2,6 +2,10 @@ require_once "../queries/checkInput.php"; require_once "../queries/picture.php"; require_once "../queries/alerts.php"; + +/** + * Creates a group. + */ function createGroup() { $createGroup = prepareQuery(" diff --git a/website/queries/groupAdmin.php b/website/queries/groupAdmin.php index c9b3af5..8cefb9b 100644 --- a/website/queries/groupAdmin.php +++ b/website/queries/groupAdmin.php @@ -1,4 +1,9 @@ fetch(); } +/** + * Updates the settings for a group. + * @param int $groupID + * @throws AngryAlert + * @throws HappyAlert + */ function updateGroupSettings(int $groupID) { if (!checkGroupAdmin($groupID, $_SESSION["userID"])) { @@ -40,6 +51,12 @@ function updateGroupSettings(int $groupID) } } +/** + * Checks if an user is an admin for a page. + * @param int $groupID + * @param int $userID + * @return bool + */ function checkGroupAdmin(int $groupID, int $userID) : bool { $stmt = prepareQuery(" SELECT @@ -60,18 +77,39 @@ function checkGroupAdmin(int $groupID, int $userID) : bool { return ($role == "admin"); } +/** + * Returns all normal members for a group. + * @param int $groupID + * @return array|bool + */ function getAllGroupUsers(int $groupID) { return getAllGroupMembers($groupID, 'member'); } +/** + * Returns all admin for a group. + * @param int $groupID + * @return array|bool + */ function getAllGroupAdmins(int $groupID) { return getAllGroupMembers($groupID, 'admin'); } +/** + * Returns all Moderators for a group. + * @param int $groupID + * @return array|bool + */ function getAllGroupMods(int $groupID) { return getAllGroupMembers($groupID, 'mod'); } +/** + * Returns all members for a group specified by a string. + * @param int $groupID + * @param string $role + * @return array|bool + */ function getAllGroupMembers(int $groupID, string $role) { $stmt = prepareQuery(" SELECT @@ -97,6 +135,14 @@ function getAllGroupMembers(int $groupID, string $role) { return $stmt->fetchAll(); } +/** + * Upgrades or downgrades a groupmember to a different role. + * @param int $groupID + * @param int $userID + * @param string $role + * @throws AngryAlert + * @throws HappyAlert + */ function upgradeUser(int $groupID, int $userID, string $role) { if (!checkGroupAdmin($groupID, $_SESSION["userID"])) { throw new AngryAlert("Geen toestemming om te wijzigen"); @@ -121,6 +167,11 @@ function upgradeUser(int $groupID, int $userID, string $role) { } } +/** + * Removes a group form the database. + * @throws AngryAlert + * @throws HappyAlert + */ function deleteGroup() { if (!checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) { throw new AngryAlert("Geen toestemming om de groep te verwijderen!");