58 lines
1.9 KiB
PHP
58 lines
1.9 KiB
PHP
<?php
|
|
|
|
include_once './includes/tournaments/Tournament.inc.php';
|
|
include_once './includes/tournaments/Category.inc.php';
|
|
|
|
include_once './includes/users/Member.inc.php';
|
|
|
|
include_once './includes/database/MySQLDatabase.inc.php';
|
|
|
|
include_once './includes/utils/MapperUtils.inc.php';
|
|
|
|
/**
|
|
* This class allows for easy listing of tournaments entries.
|
|
*
|
|
* @author Thomas Schwery <thomas.schwery@epfl.ch>
|
|
*/
|
|
class TournamentEntryLister {
|
|
|
|
public static function GetAllEntries(Tournament $tournament) {
|
|
$tournamentId = $tournament->getIdentifier();
|
|
|
|
return TournamentEntryLister::GetEntries("WHERE tournamentId = $tournamentId");
|
|
}
|
|
|
|
public static function GetAllEntriesFromCategory(Tournament $tournament, Category $category) {
|
|
$tournamentId = $tournament->getIdentifier();
|
|
$categoryId = $category->getIdentifier();
|
|
|
|
return TournamentEntryLister::GetEntries("WHERE tournamentId = $tournamentId AND categoryId = $categoryId");
|
|
}
|
|
|
|
public static function GetAllEntriesFromMember(Member $member) {
|
|
$userId = $member->getIdentifier();
|
|
return TournamentEntryLister::GetEntries("WHERE userId = $userId");
|
|
}
|
|
|
|
public static function GetAllEntriesFromMemberAndCategory(Member $member, Category $category) {
|
|
$userId = $member->getIdentifier();
|
|
$categoryId = $category->getIdentifier();
|
|
|
|
$limitation = "WHERE categoryId = $categoryId AND userId = $userId";
|
|
|
|
return TournamentEntryLister::GetEntries($limitation);
|
|
}
|
|
|
|
private static function GetEntries($condition) {
|
|
$sql = "SELECT entryId FROM tournamentsEntries $condition";
|
|
$result = MySQLDatabase::getInstance()->runRequest($sql);
|
|
|
|
if ($result) {
|
|
$result1 = array_map("mapIdentifierToTournamentEntry", $result);
|
|
return $result1;
|
|
} else {
|
|
return array();
|
|
}
|
|
}
|
|
}
|
|
?>
|