From 6db4d35cd0a49c894b9d8e78fc271b28dcbc9a52 Mon Sep 17 00:00:00 2001 From: hecht Date: Tue, 29 Nov 2011 22:03:55 +0000 Subject: [PATCH] added cancelChallange method (locally tested) --- ag/include/clan_fights.inc.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/ag/include/clan_fights.inc.php b/ag/include/clan_fights.inc.php index 2b619d0..f578ed5 100644 --- a/ag/include/clan_fights.inc.php +++ b/ag/include/clan_fights.inc.php @@ -609,7 +609,7 @@ function leaveChallenge($clan_challenge_id, array $user, $charid) { } if($char['besitzer'] != $user['id']) { - if(!isAuthorizedClanfightCoordinator($clan_id, $user['id'], $clan_challenge_id)) { + if(!isAuthorizedClanfightCoordinator($clan['id'], $user['id'], $clan_challenge_id)) { // authorized coordinators may remove a char!! But this one is not authorized return 'Du kannst den Char nicht vom Kampf zurückziehen, da er dir nicht gehört!'; } @@ -627,6 +627,31 @@ function leaveChallenge($clan_challenge_id, array $user, $charid) { return NULL; } +function cancelChallenge($clan_challenge_id, array $user) { + $clan = getClan($user['clan']); + if(!$clan) { + return 'Du bist in keinem Clan!!'; + } + + $clans = getParticipatingClanIDs($clan_challenge_id); + if(!in_array($clan['id'], $clans)) { + return 'Dein Clan nimmt überhaupt nicht an diesem Clan-Fight teil!'; + } + + if(!isAuthorizedClanfightCoordinator($clan['id'], $user['id'], $clan_challenge_id)) { + return 'Du hast nicht die Rechte diesen Clan-Fight zurück zu ziehen!'; + } + + // kay, finish him !!! + $sql = 'DELETE FROM clan_challenges WHERE clan_challenge_id = ' .$clan_challenge_id . ' AND calculated = FALSE'; +// echo $sql . '
'; + $res = mysql_query($sql); + if(!$res) + return 'Beim zurückziehen des Clan-Fights ist ein technischer Fehler aufgetreten!'; + return NULL; +} + + /** * This function does the calculation of the clan fight. * @param int $clan_challenge_id the id of the challenge