kleine Anpassungen, (User und Char anklickbar)

main
radiskull 13 years ago
parent f0889b8b2e
commit da71cd39b0

@ -11,6 +11,7 @@ include_once(ROOT_PATH.'/include/clan.inc.php');
include_once(ROOT_PATH.'/include/fehlerausgabe.inc.php');
include_once(ROOT_PATH.'/include/parse.inc.php');
include_once(ROOT_PATH.'/include/char.inc.php');
include_once(ROOT_PATH.'/include/user.inc.php');
defineIfNotDefined('DENY_CHALLENGE', 1);
defineIfNotDefined('WITHDRAW_CHALLENGE', 2);
@ -25,6 +26,7 @@ $challangedclan_id = validateUnsignedInteger($_GET['challangedclan_id'], null);
$inquirychallenge_clanid = validateUnsignedInteger($_GET['clanid'], null);
$clan_challange_id = validateUnsignedInteger($_GET['challenge'], null);
$char_id = validateUnsignedInteger($_GET['char'], null);
$type = validateUnsignedInteger($_GET['type'], null);
//unkritisch
if($action == null) {
@ -84,7 +86,7 @@ function displayDenyChallenge($clan_id, $type) {
<?php }?>
</tr>
<tr>
<td align="center"><?php echo '<a href="index.php?as=clan/kampf_info&action=denychallenge&clanid='.$clan_id.'">ja</a>';?>
<td align="center"><?php echo '<a href="index.php?as=clan/kampf_info&action=denychallenge&clanid='.$clan_id.'&type='.$type.'">ja</a>';?>
</td>
<td align="center"><?php echo '<a href="index.php?as=clan/kampf_info">nein</a>';?>
</td>
@ -93,6 +95,21 @@ function displayDenyChallenge($clan_id, $type) {
<?php
}
function denyChallenge($type, $clan_id, $user) {
if($type == DENY_CHALLENGE) {
$success = denyChallengeRequest($clan_id, $user);
} elseif($type == WITHDRAW_CHALLENGE) {
$success = cancelChallengeRequest($clan_id, $user);
}
if($success == null) {
displayClanFightMenu($user_ida);
} else {
displayErrorMessage(NULL, $success, displayHistoryBackLink());
exit;
}
}
function displayShowChallenge($clan_challenge_id, $user) {
$user_clan = getClan($user['clan']);
$open_challenge_ids = getOpenChallengeIDs($user_clan['id']);
@ -117,7 +134,6 @@ function displayShowChallenge($clan_challenge_id, $user) {
$slots = array();
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="as" value=clan/kampf_info> <input
type="hidden" name="action" value="joinchallenge"> <input
@ -148,7 +164,9 @@ function displayShowChallenge($clan_challenge_id, $user) {
echo '<td><b>Slot '.$i.'</b></td>';
if($user_clan_chars[$i] != null) {
$char = getChar($user_clan_chars[$i]);
echo '<td align="center">'.$char['name'].'</td>';
$char_owner = getOwnerOfChar($char['id']);
echo '<td align="center"><a href="index.php?as=info&charm=1&char_id='.$char['id'].'">'.$char['name'].'</a> ';
echo '(<a href="index.php?as=info&user_id='.$char_owner['id'].'">'.$char_owner['nickname'].'</a></td>)';
if(isUserOwnerOf($user['id'], $char['id'])) {
echo '<td align="center"><a href="index.php?as=clan/kampf_info&action=leavechallenge&challenge='.$clan_challenge_id.'&char='.$char['id'].'">abmelden</a></td>';
}
@ -270,7 +288,7 @@ function displayJoinChallenge($user, $clan_challenge_id, $char_id, $slot) {
exit;
} else {
echo 'Der Charakter wurde erfoglreich angemeldet.<br><br>';
echo '<a href="index.php?as=clan/kampf_info">weiter</a>';
echo '<a href="index.php?as=clan/kampf_info&action=showchallenge&challenge='.$clan_challenge_id.'">weiter</a>';
}
}
@ -289,7 +307,43 @@ function displayLeaveChallenge($user, $clan_challenge_id, $char_id) {
exit;
} else {
echo 'Der Charakter wurde erfoglreich abgemeldet.<br><br>';
echo '<a href="index.php?as=clan/kampf_info">weiter</a>';
echo '<a href="index.php?as=clan/kampf_info&action=showchallenge&challenge='.$clan_challenge_id.'">weiter</a>';
}
}
function displayCancelChallenge($user, $clan_challange_id) {
if(!is_numeric($clan_challange_id)) {
displayErrorMessage(NULL, 'Wollte da jemand schummeln? ;)', displayHistoryBackLink());
return;
}
?>
<table>
<tr>
<th colspan="2">Clankampf wirklich abbrechen?</th>
</tr>
<tr>
<td align="center"><?php echo '<a href="index.php?as=clan/kampf_info&action=cancelchallenge&challenge='.$clan_challange_id.'">ja</a>';?>
</td>
<td align="center"><?php echo '<a href="index.php?as=clan/kampf_info">nein</a>';?>
</td>
</tr>
</table>
<?php
}
function cancelThisChallenge($user, $clan_challange_id) {
if(!is_numeric($clan_challange_id)) {
displayErrorMessage(NULL, 'Wollte da jemand schummeln? ;)', displayHistoryBackLink());
return;
}
$success = cancelChallenge($clan_challange_id, $user);
if($success != null) {
displayErrorMessage(NULL, $success, displayHistoryBackLink());
exit;
} else {
displayClanFightMenu($user);
}
}
@ -312,14 +366,16 @@ function displayClanFightMenu($user) {
$clans[] = getClan($clan_tmp_id);
}
}
$active_clan_challange_ids = getActiveChallengeIDs($user_clan['id']);
$open_challenge_requests = getOpenChallengeRequests($user_clan['id']);
$open_challenge_ids = getOpenChallengeIDs($user_clan['id']);
$old_challenge_ids = getHistoricalChallengeIDs($user_clan['id']);
?>
<div align="center">
<table width="100%" border="1">
<tr>
<th height="30" colspan="2" align="center">Herausforderungen</th>
<th height="30" colspan="3" align="center">Herausforderungen</th>
</tr>
<tr>
<th align="Left" height="25">Clan herausfordern</th>
@ -348,7 +404,11 @@ function displayClanFightMenu($user) {
<th align="center" height="25">Anzahl</th>
<th align="center" height="25">Status</th>
</tr>
<tr>
<?php
if(count($open_challenge_requests) == 0) {
echo '<td align ="center" colspan="5" height="20">Keine</td>';
} else {
foreach ($open_challenge_requests as $challenge) {
$requester_clan = getClan($challenge['clan_requester']);
$challenged_clan = getClan($challenge['clan_challenged']);
@ -357,28 +417,27 @@ function displayClanFightMenu($user) {
if($user_clan['id'] == $challenge['clan_requester']) {
echo '<tr><td align ="center">'.$challenged_clan['clanname'].'</td><td align ="center">'.formatTimestamp($challenge['challenged_time']).'</td>';
echo '<td align ="center">'.getFightType($challenge['type']).'</td><td align ="center">'.$challenge['anzahl_chars'].'</td>';
echo '<td align ="center">ausstehend (<a href="index.php?as=clan/kampf_info&action=q_withdrawchallenge&clanid='.$requester_clan['id'].'">zur&uuml;ckziehen</a>)</td></tr>';
echo '<td align ="center">ausstehend (<a href="index.php?as=clan/kampf_info&action=q_withdrawclanchallenge&clanid='.$challenged_clan['id'].'">zur&uuml;ckziehen</a>)</td></tr>';
} else {
echo '<tr><td align ="center">'.$requester_clan['clanname'].'</td><td align ="center">'.formatTimestamp($challenge['challenged_time']).'</td>';
echo '<td align ="center">'.getFightType($challenge['type']).'</td><td align ="center">'.$challenge['anzahl_chars'].'</td>';
echo '<td align ="center"><a href="index.php?as=clan/kampf_info&action=acceptchallenge&clanid='.$requester_clan['id'].'">annehmen</a> |';
echo '<a href="index.php?as=clan/kampf_info&action=q_denychallenge&clanid='.$requester_clan['id'].'">ablehnen</a></td></tr>';
echo '<td align ="center"><a href="index.php?as=clan/kampf_info&action=acceptclanchallenge&clanid='.$requester_clan['id'].'">annehmen</a> |';
echo '<a href="index.php?as=clan/kampf_info&action=q_denyclanchallenge&clanid='.$requester_clan['id'].'">ablehnen</a></td></tr>';
}
}
}
?>
</tr>
</table>
</td>
</tr>
<tr>
<th height="30" colspan="2" align="center">offene Herausforderungen</th>
<th height="30" colspan="3" align="center">offene Herausforderungen</th>
</tr>
<?php
if(count($open_challenge_ids) == 0) {
?>
<tr>
<td height="20" colspan="2" align="center">Keine</td>
</tr>
<?php
if(count($open_challenge_ids) == 0) {
echo '<td height="20" colspan="2" align="center">Keine</td>';
} else {
foreach ($open_challenge_ids as $oci) {
$participating_clan_ids = getParticipatingClanIDs($oci);
@ -388,30 +447,47 @@ function displayClanFightMenu($user) {
echo '<tr>';
echo '<td> '.$challenged_clan['clanname'].'</td>';
echo '<td align="center"><a href="index.php?as=clan/kampf_info&action=showchallenge&challenge='.$oci.'">'.anzeigen.'</a></td>';
echo '<td align="center"><a href="index.php?as=clan/kampf_info&action=q_cancelclanchallenge&challenge='.$oci.'">'.abbrechen.'</a></td>';
echo '</tr>';
}
}
}
?>
<tr>
<th height="30" colspan="2" align="center">Beendete Herausforderungen</th>
</tr>
<tr>
<th height="30" colspan="3" align="center">Laufende Herausforderungen</th>
</tr>
<?php
if(count($old_challenge_ids) == 0) {
if(count($active_clan_challange_ids) == 0) {
echo '<td height="20" colspan="3" align="center">Keine</td>';
} else {
foreach ($active_clan_challange_ids as $acci) {
$participating_clan_ids = getParticipatingClanIDs($acci);
foreach ($participating_clan_ids as $pci)
if($pci != $user_clan['id']) {
$challenged_clan = getClan($pci);
echo '<tr><td align="center"> '.$challenged_clan['clanname'].'</td>';
//TODO: hier muss javascript fenster aufgerufen werden
echo '<td align="center"><a href="index.php?as=clan/kampf_info&action=showoldchallenge&challenge='.$acci.'">'.anzeigen.'</a></td></tr>';
}
}
}
?>
<td height="20" colspan="2" align="center">Keine</td>
<tr>
<th height="30" colspan="3" align="center">Beendete Herausforderungen</th>
</tr>
<tr>
<?php
if(count($old_challenge_ids) == 0) {
echo '<td height="20" colspan="3" align="center">Keine</td>';
} else {
foreach ($old_challenge_ids as $oci) {
$participating_clan_ids = getParticipatingClanIDs($oci);
foreach ($participating_clan_ids as $pci)
if($pci != $user_clan['id']) {
$challenged_clan = getClan($pci);
echo '<tr>';
echo '<td> '.$challenged_clan['clanname'].'</td>';
echo '<td align="center"><a href="index.php?as=clan/kampf_info&action=showoldchallenge&challenge='.$oci.'">'.anzeigen.'</a></td>';
echo '</tr>';
echo '<tr><td> '.$challenged_clan['clanname'].'</td>';
echo '<td align="center"><a href="index.php?as=clan/kampf_info&action=showoldchallenge&challenge='.$oci.'">'.anzeigen.'</a></td></tr>';
}
}
}
@ -426,18 +502,17 @@ switch($action) {
case 'challengeclan':
displayChallengeClan($user_ida, $challangedclan_id);
break;
case 'acceptchallenge':
case 'acceptclanchallenge':
displayChallengeAccepted($user_ida, $inquirychallenge_clanid);
break;
case 'q_denychallenge':
case 'q_denyclanchallenge':
displayDenyChallenge($inquirychallenge_clanid, DENY_CHALLENGE);
break;
case 'q_withdrawchallenge':
case 'q_withdrawclanchallenge':
displayDenyChallenge($inquirychallenge_clanid, WITHDRAW_CHALLENGE);
break;
case 'denychallenge':
denyChallengeRequest($inquirychallenge_clanid, $user_ida);
displayClanFightMenu($user_ida);
denyChallenge($type, $inquirychallenge_clanid, $user_ida);
break;
case 'showchallenge':
displayShowChallenge($clan_challange_id, $user_ida);
@ -451,6 +526,12 @@ switch($action) {
case 'leavechallenge':
displayLeaveChallenge($user_ida, $clan_challange_id, $char_id);
break;
case 'q_cancelclanchallenge':
displayCancelChallenge($user_ida, $clan_challange_id);
break;
case 'cancelchallenge':
cancelThisChallenge($user_ida, $clan_challange_id);
break;
default:
displayClanFightMenu($user_ida);
}

@ -25,6 +25,25 @@ function getUser($userid, $buffer_enabled = true) {
return $GLOBALS['user_buffered_instances'][$userid];
}
/**
*
* Returns the user of the Character. (attributes of the user-table should be added here if needed)
* @param unknown_type $charid
* @param unknown_type $buffer_enabled
*/
function getOwnerOfChar($charid, $buffer_enabled = true) {
// Fehlerkontrolle
if(!is_numeric($charid)){
return null;
}
// Wenn Char nicht im Puffer ist, oder nicht gepuffert werden soll
if ($GLOBALS['user_buffered_instances'][$userid] == null || !$buffer_enabled) {
$user = mysql_fetch_assoc(mysql_query('SELECT u.nickname, u.id FROM user u INNER JOIN chars ch ON ch.besitzer=u.id WHERE ch.id = '.$charid));
$GLOBALS['user_buffered_instances'][$userid] = $user;
}
return $GLOBALS['user_buffered_instances'][$userid];
}
function addMoneyToUser($userid, $amount) {
mysql_query('update user set geld = geld + ' . $amount . ' WHERE id = ' .$userid);
}

Loading…
Cancel
Save