Guilds - suggestions
Rank levels should be the inverse, 1 for higher rank/leader, to make it easier to add more ranks (which could be added too). Add option to add/change player guild nick (and remove it if guild disband/character is kicked). And maybe join date, but don't know if it worth the effort, since at default databases there isn't a field to track it, and would need to be implemented through znote tables.
A vice-leader can change others vice-leaders ranks. It's supposed to be like that?
https://github.com/Znote/ZnoteAAC/blob/master/guilds.php#L630
foreach ($players as $player) {
$pl_data = get_player_guild_data(user_character_id($player['name']));
if ($pl_data['rank_level'] != 3) {
if ($pl_data['rank_level'] != 2) {
echo '<option value="'. $player['name'] .'">'. $player['name'] .'</option>';
} else {
if ($highest_access == 3) {
echo '<option value="'. $player['name'] .'">'. $player['name'] .'</option>';
}
}
}
}
Concerning changing guild nick, I think I covered it all.
https://github.com/Znote/ZnoteAAC/blob/master/engine/function/users.php#L505
function get_guild_players($gid) {
$gid = (int)$gid; // Sanitizing the parameter id
if (config('TFSVersion') !== 'TFS_10') return mysql_select_multi("SELECT p.rank_id, p.name, p.level, p.guildnick, p.vocation, p.online, gr.name AS `rank_name` FROM players AS p LEFT JOIN guild_ranks AS gr ON gr.id = p.rank_id WHERE gr.guild_id ='$gid' ORDER BY gr.id, p.name;");
else return mysql_select_multi("SELECT p.id, p.name, p.level, p.vocation, gm.rank_id, gm.nick AS `guildnick`, gr.name AS `rank_name` FROM players AS p LEFT JOIN guild_membership AS gm ON gm.player_id = p.id LEFT JOIN guild_ranks AS gr ON gr.id = gm.rank_id WHERE gm.guild_id = '$gid' ORDER BY gm.rank_id, p.name");
}
https://github.com/Znote/ZnoteAAC/blob/master/engine/function/users.php#L330
function guild_player_leave($cid) {
$cid = (int)$cid;
mysql_update("UPDATE `players` SET `rank_id`='0' WHERE `id`=$cid LIMIT 1;");
mysql_update("UPDATE `players` SET `guildnick`= NULL WHERE `id`=$cid");
}
https://github.com/Znote/ZnoteAAC/blob/master/engine/function/users.php#L242
function guild_remove_member($cid) {
$cid = (int)$cid;
mysql_update("UPDATE `players` SET `rank_id`='0' WHERE `id`=$cid");
mysql_update("UPDATE `players` SET `guildnick`= NULL WHERE `id`=$cid");
}
this one I added above line https://github.com/Znote/ZnoteAAC/blob/master/engine/function/users.php#L411
// Update player's guild nick
function update_player_guildnick($cid, $nick) {
$cid = (int)$cid;
$nick = sanitize($nick);
if (!empty($nick)) {
mysql_update("UPDATE `players` SET `guildnick`='$nick' WHERE `id`=$cid");
} else {
mysql_update("UPDATE `players` SET `guildnick`= NULL WHERE `id`=$cid");
}
}
function update_player_guildnick_10($cid, $nick) {
$cid = (int)$cid;
$nick = sanitize($nick);
if (!empty($nick)) {
mysql_update("UPDATE `guild_membership` SET `nick`='$nick' WHERE `player_id`=$cid");
} else {
mysql_update("UPDATE `guild_membership` SET `nick`= NULL WHERE `player_id`=$cid");
}
}
now in guilds.php I added this above line https://github.com/Znote/ZnoteAAC/blob/master/guilds.php#L344
// Change Guild Nick
if (!empty($_POST['player_guildnick'])) {
$p_cid = user_character_id($_POST['player_guildnick']);
$p_guild = get_player_guild_data($p_cid);
if (preg_match("/^[a-zA-Z_ ]+$/", $_POST['guildnick']) || empty($_POST['guildnick'])) {
// Only allow normal symbols as guild nick
$p_nick = sanitize($_POST['guildnick']);
if ($p_guild['guild_id'] == $gid) {
if ($config['TFSVersion'] !== 'TFS_10') $chardata = user_character_data($p_cid, 'online');
else $chardata['online'] = (user_is_online_10($p_cid)) ? 1 : 0;
if ($chardata['online'] == 0) {
if ($config['TFSVersion'] !== 'TFS_10') update_player_guildnick($p_cid, $p_nick);
else update_player_guildnick_10($p_cid, $p_nick);
header('Location: guilds.php?name='. $_GET['name']);
exit();
} else echo '<font color="red" size="4">Character not offline.</font>';
}
} else echo '<font color="red" size="4">Character guild nick may only contain a-z, A-Z and spaces.</font>';
}
and above line https://github.com/Znote/ZnoteAAC/blob/master/guilds.php#L620
<!-- FORMS TO CHANGE GUILD NICK -->
<form action="" method="post">
<ul>
<li>
Change Guild Nick:<br>
<select name="player_guildnick">
<?php
//$gid = get_guild_id($_GET['name']);
//$players = get_guild_players($gid);
foreach ($players as $player) {
$pl_data = get_player_guild_data(user_character_id($player['name']));
if ($pl_data['rank_level'] != 3) {
echo '<option value="'. $player['name'] .'">'. $player['name'] .'</option>';
} else {
if ($highest_access == 3) {
echo '<option value="'. $player['name'] .'">'. $player['name'] .'</option>';
}
}
}
?>
</select>
<input type="text" name="guildnick" maxlength="15" placeholder="leave blank to erase">
<input type="submit" value="Change Nick">
</li>
</ul>
</form>
<!-- END FORMS TO CHANGE GUILD NICK -->
https://github.com/Znote/ZnoteAAC/blob/master/guilds.php#L215
echo '<td><a href="characterprofile.php?name='. $player['name'] .'">'. $player['name'] .'</a>';
if (!empty($player['guildnick'])) {
echo ' ('. $player['guildnick'] .')';
}
echo '</td>';
Also, why there are 2 functions for the same thing, both with TFS_10 counterparts, guild_player_leave($cid) and guild_remove_member($cid)?
Well the function list is messy indeed. :p I must have written two different functions that works the same way. Perhaps I wrote for the guild master and for the player. But in the end the function is the same. :+1:
I'll look deeply into this later, just briefly read through it to keep myself up to date on the issue tracker. Still very busy. :P