href="javascript:if(confirm('Wirklich auflösen? der Clan kann ggf. durch jemand übernommen werden!')==true) window.location.href='index.php?as=clan/clan_info&action=kill'">Clan
auflösen (Achtung! Clans ggf. nur geleert!)</a></td>
</tr>
<tr>
<td> </td>
@ -408,8 +408,9 @@ function displayClanProfileEditable($clan, $userid){
<?php
}
function displayClanProfile($clanid, $user){
function displayClanProfile($clanid, $userid){
$clan = getClan($clanid, FALSE);
$user = getUser($userid, false);
if(!$clan) {
echo displayErrorMessage(NULL, 'Es gibt den Clan mit der ID ' .$clanid.' nicht oder nicht mehr!', displayHistoryBackLink());
return;
@ -422,28 +423,6 @@ function displayClanProfile($clanid, $user){
}
}
function setMeAsLeader($user){
mysql_query('UPDATE clan set leader = '.$user['id'].' WHERE id = '.$user['clan'].' and leader is null and co_leader is null');
}
function sendClanNewsletter($user, $text){
$qry = mysql_query('SELECT * FROM clan WHERE id = ' . $user['clan']);
$clan = mysql_fetch_assoc($qry);
$errors = FALSE;
$sql = 'SELECT id FROM user WHERE clan='.$user['clan'];
function setProfile($what, $value1, $value2, $clanid, $rootlvl){
if($rootlvl <1){
return 'Du hast keine Rechte um diese Aktion auszuführen!';
@ -568,21 +547,6 @@ function displayEdit($what, $clanid, $rootlvl){
<?php
}
function deleteClan($user){
$row = mysql_fetch_assoc(mysql_query('SELECT leader, co_leader from clan where id = '.$user['clan']));
if($user['id'] == $row['leader']){
$qry = mysql_query('SELECT id FROM user WHERE clan = '.$user['clan']);
while($member = mysql_fetch_assoc($qry)) {
sendMessage($user['nickname'], $member['id'], 'Clan wurde gelöscht!', 'Dein Clan wurde von '.$user['nickname'].' gelöscht. Du wirst dir wohl einen neuen suchen müssen!');
}
mysql_query('DELETE FROM clan where id = '.$user['clan']);
} else{
echo displayErrorMessage(NULL, 'Du kannst den Clan nicht auflösen!', displayHistoryBackLink());
}
}
if($action !== NULL) { // this is done to not require to reprogramm the whole stuff!
@ -601,6 +565,7 @@ if($action !== NULL) { // this is done to not require to reprogramm the whole st
$row = mysql_fetch_assoc(mysql_query('SELECT leader, co_leader from clan where id = '.$user_ida['clan']));
$sql = 'Update user set clan = NULL where id = '.$member.' AND clan = '.$user['clan'];
// echo $sql.'<br>';
mysql_query($sql);
@ -174,11 +174,12 @@ function fireMember($user, $member){
mysql_query($sql);
if($user['id'] != $member) {
sendMessage($user['nickname'], $member, 'Clan rauswurf!', 'Du wurdest von '.$user['nickname'].' aus deinem Clan geworfen. Du wirst dir wohl einen neuen suchen müssen!');
mysql_query('DELETE FROM clan WHERE id =' .$user['clan']);
}
// delete the participation in open clan fights! Thats tricky because the user itself is not stored in the database!!
mysql_query('DELETE FROM clan_challenge_whitelist WHERE clan_id = ' .$clan['id'] . ' AND user_id = ' .$user['id']);
mysql_query('DELETE FROM clan_challenge_participants WHERE clan_challenge_id in (SELECT clan_challenge_id FROM clan_challenge where calculated = FALSE) and char_id IN (Select id FROM chars where besitzer = '.$user['id'].')');
}
} else{
@ -199,17 +200,17 @@ function getAllClans() {
return $clans;
}
function joinClan($user, $clanid){
function joinClan($user, $clanid, $check_invitation = true){
// last chance to lock the clan if in the old situation it was having to few members ;)
isClanLocked($clanid); // we only require the calculation not the result!
$sql = 'SELECT * FROM user_clan_invitations WHERE userid = '.$user['id'].' and clanid = '.$clanid.' and valid > now();';
displayErrorMessage(NULL,'Konnte die Einladung des Clans nicht annehmen (Clan voll)!',displayHistoryBackLink());
@ -220,10 +221,13 @@ function joinClan($user, $clanid){
mysql_query($sql);
// unset the leader if the user is moving from one clan to another
mysql_query('UPDATE clan SET leader = NULL WHERE leader = ' .$user['id']);
mysql_query('UPDATE clan SET co_leader = NULL WHERE co_leader = ' .$user['id']);
mysql_query('UPDATE clan SET leader = NULL WHERE leader = ' .$user['id'] . ' and id != ' .$clanid);
mysql_query('UPDATE clan SET co_leader = NULL WHERE co_leader = ' .$user['id'] . ' and id != ' .$clanid);
mysql_query('DELETE FROM clan_challenge_whitelist WHERE clan_id = ' .$clanid . ' AND user_id = ' .$user['id']);
displayErrorMessage('Aufgenommen','Du wurdest erfolgreich in den Clan aufgenommen!','<ahref="index.php?as=clan/clan_info">weiter</a>');
if($check_invitation) {
displayErrorMessage('Aufgenommen','Du wurdest erfolgreich in den Clan aufgenommen!','<ahref="index.php?as=clan/clan_info">weiter</a>');
}
}
} else{
displayErrorMessage(NULL,'Konnte die Einladung des Clans nicht annehmen!',displayHistoryBackLink());
@ -241,6 +245,86 @@ function denyClan($user, $clanid){
}
}
function deleteClan($userid) {
$user = getUser($userid);
$clanid = $user['clan'];
$clan = getClan($clanid);
if($userid != $clan['leader']) {
return 'Du kannst den Clan nicht auflösen!';
}
// Okay notify the members :)
$qry = mysql_query('SELECT id FROM user WHERE clan = '.$user['clan']);
while($member = mysql_fetch_assoc($qry)) {
sendMessage($user['nickname'], $member['id'], 'Clan wurde gelöscht!', 'Dein Clan wurde von '.$user['nickname'].' gelöscht. Du wirst dir wohl einen neuen suchen müssen!');
}
// Check if this clan is level 0 and has 0 exp ...
if($clan['exp'] == 0 && $clan['level'] == 1) {
// really do delete the clan !!
mysql_query('DELETE FROM clan where id = '.$user['clan']);
} else {
// cleanup the clan!
$sql1 = 'UPDATE user SET clan = NULL WHERE clan = ' . $clanid;
$sql2 = 'UPDATE clan SET leader = NULL, co_leader = NULL WHERE id = ' .$clanid;
$sql3 = 'DELETE FROM clan_challenge_whitelist WHERE clan_id = ' .$clanid; // cleanup the whitelist
// echo $sql1 . '<br>';
// echo $sql2 . '<br>';
mysql_query($sql1);
mysql_query($sql2);
}
return NULL;
}
function conquerClan($clanid, $userid) {
// It is possible to enter a clan that is empty :)
$user = getUser($userid);
$result = mysql_fetch_row(mysql_query('SELECT count(*) FROM user WHERE clan = ' . $clanid));
if($result[0] != 0) {
return 'Der Clan ('.$clanid.') ist nicht leer!';
}
$sql = 'UPDATE clan SET leader = ' . $userid . ' WHERE leader is NULL AND id = '. $clanid;
mysql_query($sql);
$done = mysql_affected_rows() > 0;
if(!$done) {
return 'Der Clan ist schon übernommen worden!';
}
// Cool we got em !! Now move to the new clan :)
joinClan($user, $clanid, false);
return NULL;
}
function setMeAsLeader($user){
mysql_query('UPDATE clan set leader = '.$user['id'].' WHERE id = '.$user['clan'].' and leader IS null AND co_leader IS null');
return mysql_affected_rows() > 0;
}
function sendClanNewsletter($user, $text){
$qry = mysql_query('SELECT * FROM clan WHERE id = ' . $user['clan']);
$clan = mysql_fetch_assoc($qry);
$errors = FALSE;
$sql = 'SELECT id FROM user WHERE clan='.$user['clan'];