commentses

This commit is contained in:
Hendrik
2017-02-03 12:21:37 +01:00
parent b07d0712aa
commit f3aebddfea
5 changed files with 192 additions and 3 deletions

View File

@@ -1,9 +1,20 @@
<?php
/**
* Returns all groups a user is member of.
* @param $userID
* @return string
*/
function selectAllGroupsFromUser($userID) {
return selectLimitedGroupsFromUser($userID, 9999);
}
/**
* Selects number of groups that a user is member of.
* @param $userID
* @param $limit
* @return string
*/
function selectLimitedGroupsFromUser($userID, $limit) {
$stmt = prepareQuery("
SELECT
@@ -27,6 +38,13 @@ function selectLimitedGroupsFromUser($userID, $limit) {
return json_encode($stmt->fetchAll());
}
/**
* Returns m groups offset by n filtered by search that the current user is part of.
* @param $n
* @param $m
* @param $search
* @return string
*/
function searchSomeOwnGroups($n, $m, $search) {
$stmt = prepareQuery("
SELECT
@@ -55,6 +73,11 @@ function searchSomeOwnGroups($n, $m, $search) {
return json_encode($stmt->fetchAll());
}
/**
* Counts all groups filtered by search that the current user is member of.
* @param $search
* @return string
*/
function countSomeOwnGroups($search) {
$stmt = prepareQuery("
SELECT
@@ -78,6 +101,13 @@ function countSomeOwnGroups($search) {
return $stmt->fetchColumn();
}
/**
* Adds a user by userID to a group by groupID with a specified role.
* @param $groupID
* @param $userID
* @param $role
* @return bool
*/
function addMember($groupID, $userID, $role) {
$stmt = prepareQuery("
INSERT INTO
@@ -92,6 +122,13 @@ function addMember($groupID, $userID, $role) {
return $stmt->execute();
}
/**
* Changes te role of a user within a group to the specified one.
* @param $groupID
* @param $userID
* @param $role
* @return bool
*/
function changeMember($groupID, $userID, $role) {
$stmt = prepareQuery("
UPDATE
@@ -109,6 +146,12 @@ function changeMember($groupID, $userID, $role) {
return $stmt->execute();
}
/**
* Removes a user from a group.
* @param $groupID
* @param $userID
* @return bool
*/
function deleteMember($groupID, $userID) {
$stmt = prepareQuery("
DELETE FROM