From 9f4ae9708ea334078104172bb015f621d5d1cb18 Mon Sep 17 00:00:00 2001 From: hecht Date: Sun, 11 Sep 2011 15:21:35 +0000 Subject: [PATCH] Tippfehler im Profil beseitigt. Die Memberberechnung stimmt nun, der co_leader kann nicht gefeuert werden wenn die maximale anzahl der member drinne ist --- ag/clan/clan_info.php | 35 ++++++++++++++++++++++++----------- ag/include/clan.inc.php | 20 +++++++++----------- ag/profil.php | 4 ++-- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/ag/clan/clan_info.php b/ag/clan/clan_info.php index efd7dcd..ba11509 100644 --- a/ag/clan/clan_info.php +++ b/ag/clan/clan_info.php @@ -41,7 +41,7 @@ if($clan_id == NULL){ } -if(isset($_GET['value1'])) { +if(isset($_GET['value1']) || isset($_GET['value2'])) { switch($what) { case 'Banner': case 'Homepage': @@ -373,6 +373,7 @@ function sendClanNewsletter($user, $text){ } function setProfile($what, $value1, $value2, $clanid, $rootlvl){ + echo 'setProfile
'; if($rootlvl < 1) { return 'Du hast keine Rechte um diese Aktion auszuführen!'; } @@ -390,7 +391,11 @@ function setProfile($what, $value1, $value2, $clanid, $rootlvl){ mysql_query('UPDATE clan SET Info = \''.$value1.'\' where id = '.$clanid); return NULL; case 'Leadership': - if($value1 == 0){$value1 = 'null';} + echo 'setLeadership!
'; + $clan = getClan($clanid); + + if($value1 == 0 && $rootlvl == 2){$value1 = 'null';} + else if($rootlvl == 1) { $value1 = $clan['leader']; } if($value2 == 0){$value2 = 'null';} // okay, are we allowed to change?? If we have max members, it is not allowed to remove the co_leader @@ -398,14 +403,15 @@ function setProfile($what, $value1, $value2, $clanid, $rootlvl){ $members = getClanMembersCount($clanid); $members_max = getMaximumMembers($clan['id']); - if($members_max == $members && $clan['leader'] != $clan['co_leader'] && $value1 == $value2) { + if($members_max == $members && $clan['leader'] != $clan['co_leader'] && $value1 == $value2 || $value2 == 'null') { // Okay, actually there are the max amount of users in the clan // it is now not possible to change to a leader only clan!! - return 'Es ist nicht m&oouml;glich den co_leader zu feuern, da der clan die maximale Anzahl Member besitzt!'; + return 'Es ist nicht möglich den Co-Leader zu ändern, da der clan die maximale Anzahl Member besitzt!'; } if($rootlvl == 1){ // the co leader may only set the co leader XD $sql = 'UPDATE clan SET co_leader = '.$value2.' where id = '.$clanid; + echo $sql.'
'; mysql_query($sql); } else if($rootlvl == 2) { // the leader may set the leader and the co leader $sql = 'UPDATE clan SET leader = '.$value1.', co_leader = '.$value2.' where id = '.$clanid; @@ -454,7 +460,7 @@ function displayEdit($what, $clanid, $rootlvl){ } } - if($root){ + if($rootlvl == 2){ $content = 'Leader:'; } $content .= 'Co-Leader:'; @@ -526,25 +532,32 @@ function deleteClan($user){ if($action !== NULL) { // this is done to not require to reprogramm the whole stuff! $rootlvl = 0; + $clan = getClan($user_ida['clan']); - - if($row['leader'] == $user_ida['id'] || ($row['leader'] === null && ($row['co_leader'] === null || $row['co_leader'] = $user_ida['id']))) { + if($clan['leader'] == $user_ida['id'] || ($clan['leader'] === null && ($clan['co_leader'] === null || $clan['co_leader'] = $user_ida['id']))) { $rootlvl = 2; // leader or putsch!! - } else if($row['co_leader'] = $user_ida['id']) { + } else if($clan['co_leader'] = $user_ida['id']) { $rootlvl = 1; // co_leader } + echo 'Rootlvl = ' . $rootlvl . '
';; switch ($action) { case 'edit': + $errorMsg = NULL; $row = mysql_fetch_assoc(mysql_query('SELECT leader, co_leader from clan where id = '.$user_ida['clan'])); if($row['leader'] != $user_ida['id'] && $row['co_leader'] != $user_ida['id']){ displayErrorMessage(NULL, 'Du bist weder Leader noch Co-Leader des Clans!', displayHistoryBackLink()); - } else if(isset($value1)){ - setProfile($what, $value1, $value2, $user_ida['clan'], $rootlvl); + } else if(isset($value1) || isset($value2)){ + $errorMsg = setProfile($what, $value1, $value2, $user_ida['clan'], $rootlvl); } else{ - displayEdit($what, $user_ida['clan'], $rootlvl); + $errorMsg = displayEdit($what, $user_ida['clan'], $rootlvl); $displayMore = false; } + if($errorMsg !== NULL) { + echo displayErrorMessage(NULL, $errorMsg, displayHistoryBackLink()); + $displayMore = false; + } + break; case 'fire': fireMember($user_ida, $member); diff --git a/ag/include/clan.inc.php b/ag/include/clan.inc.php index d307ea6..5f8de7a 100644 --- a/ag/include/clan.inc.php +++ b/ag/include/clan.inc.php @@ -43,29 +43,27 @@ function getClanMemberBonusByLevel($level) { return 0; case 4: case 5: - return 1; case 6: + return 1; case 7: - return 2; case 8: + return 2; case 9: - return 3; case 10: + return 3; case 11: - return 4; case 12: + return 4; case 13: - return 5; case 14: - return 6; + return 5; case 15: - return 7; case 16: - return 8; + return 6; case 17: - return 9; + return 7; default: - return 10; + return 8; } } @@ -76,7 +74,7 @@ function getMaximumMembers($clanid) { $clan = getClan($clanid); if($clan === NULL){ return 0; } - $base = 10; + $base = 12; $members_by_level = getClanMemberBonusByLevel($clan['level']); $malus = 0; if($clan['co_leader'] == NULL || $clan['co_leader'] == $clan['leader']) { diff --git a/ag/profil.php b/ag/profil.php index 79f072d..bc7c86c 100644 --- a/ag/profil.php +++ b/ag/profil.php @@ -183,7 +183,7 @@ function display($user, $usergroups){ Werbegrad: \ No newline at end of file +?>