Merge branch 'marijn-groups' into hendrik-testing

This commit is contained in:
Hendrik
2017-02-03 12:08:42 +01:00
5 changed files with 61 additions and 5 deletions

View File

@@ -41,7 +41,11 @@ function checkInputChoice($variable, $option){
} }
} }
/* Checks for only letters and spaces. */ /**
* Checks for only letters and spaces.
* @param $variable
* @throws lettersAndSpacesException
*/
function checkName($variable){ function checkName($variable){
if (empty($variable)) { if (empty($variable)) {
throw new lettersAndSpacesException("Verplicht!"); throw new lettersAndSpacesException("Verplicht!");
@@ -52,7 +56,11 @@ function checkName($variable){
} }
} }
/* Checks for bday */ /**
* Checks for bday
* @param $variable
* @throws bdayException
*/
function validateBday($variable){ function validateBday($variable){
if (empty($variable)) { if (empty($variable)) {
throw new bdayException("Verplicht!"); throw new bdayException("Verplicht!");
@@ -220,6 +228,9 @@ function test_input($data) {
return $data; return $data;
} }
/**
* Class lettersAndSpacesException
*/
class lettersAndSpacesException extends Exception class lettersAndSpacesException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -228,7 +239,9 @@ class lettersAndSpacesException extends Exception
} }
} }
/**
* Class bdayException
*/
class bdayException extends Exception class bdayException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -237,6 +250,9 @@ class bdayException extends Exception
} }
} }
/**
* Class usernameException
*/
class usernameException extends Exception class usernameException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -245,6 +261,9 @@ class usernameException extends Exception
} }
} }
/**
* Class passwordException
*/
class passwordException extends Exception class passwordException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -253,6 +272,9 @@ class passwordException extends Exception
} }
} }
/**
* Class confirmPasswordException
*/
class confirmPasswordException extends Exception class confirmPasswordException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -261,6 +283,9 @@ class confirmPasswordException extends Exception
} }
} }
/**
* Class fbConfirmPasswordException
*/
class fbConfirmPasswordException extends Exception class fbConfirmPasswordException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -269,6 +294,9 @@ class fbConfirmPasswordException extends Exception
} }
} }
/**
* Class emailException
*/
class emailException extends Exception class emailException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -277,6 +305,9 @@ class emailException extends Exception
} }
} }
/**
* Class confirmEmailException
*/
class confirmEmailException extends Exception class confirmEmailException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -285,6 +316,9 @@ class confirmEmailException extends Exception
} }
} }
/**
* Class captchaException
*/
class captchaException extends Exception class captchaException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)
@@ -293,6 +327,9 @@ class captchaException extends Exception
} }
} }
/**
* Class registerException
*/
class registerException extends Exception class registerException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)

View File

@@ -8,6 +8,7 @@ require_once "../queries/alerts.php";
*/ */
function createGroup() function createGroup()
{ {
// Creates the group.
$createGroup = prepareQuery(" $createGroup = prepareQuery("
INSERT INTO INSERT INTO
`group_page` (`name`, `description`) `group_page` (`name`, `description`)
@@ -17,6 +18,7 @@ function createGroup()
$createGroup->bindValue(':description', test_input($_POST["bio"])); $createGroup->bindValue(':description', test_input($_POST["bio"]));
$createGroup->execute(); $createGroup->execute();
// Gets the groupID just created.
$getGroupID = prepareQuery(" $getGroupID = prepareQuery("
SELECT SELECT
`groupID` `groupID`
@@ -28,6 +30,7 @@ function createGroup()
$getGroupID->execute(); $getGroupID->execute();
$groupID = $getGroupID->fetch()["groupID"]; $groupID = $getGroupID->fetch()["groupID"];
// Adds the user as an admin.
$makeUserAdmin = prepareQuery(" $makeUserAdmin = prepareQuery("
INSERT INTO INSERT INTO
`group_member` (userID, groupID, role) `group_member` (userID, groupID, role)

View File

@@ -1,5 +1,8 @@
<?php <?php
/**
* Sends a confirm email if you know the username.
* @param string $username
*/
function sendConfirmEmailUsername(string $username) { function sendConfirmEmailUsername(string $username) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT
@@ -15,6 +18,10 @@ function sendConfirmEmailUsername(string $username) {
sendConfirmEmail($userID); sendConfirmEmail($userID);
} }
/**
* Sends a confirm email if you know the userID.
* @param int $userID
*/
function sendConfirmEmail(int $userID) { function sendConfirmEmail(int $userID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT

View File

@@ -1,6 +1,9 @@
<?php <?php
//Find matching password with the inputted username/emailadress. /**
* Find matching password with the inputted username/emailadress.
* @return mixed
*/
function getUser() { function getUser() {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT

View File

@@ -281,6 +281,12 @@ function checkPermissionOnPost(int $postID, int $userID) : bool {
} }
} }
/**
* Returns role of an user.
* @param int $userID
* @param int $groupID
* @return mixed role of an user.
*/
function getRoleInGroup(int $userID, int $groupID) { function getRoleInGroup(int $userID, int $groupID) {
$stmt = prepareQuery(" $stmt = prepareQuery("
SELECT SELECT