Fixed guilds "Add new rank function"

Exception thrown in OTS_GuildRank::__toString() method

https://otland.net/threads/myaac-bug-guild-new-rank.263953/
This commit is contained in:
slawkens 2019-04-09 00:49:30 +02:00
parent 2dd51d0202
commit 4d566500e9

View File

@ -11,13 +11,13 @@
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$guild_name = isset($_REQUEST['guild']) ? urldecode($_REQUEST['guild']) : null; $guild_name = isset($_REQUEST['guild']) ? urldecode($_REQUEST['guild']) : null;
$new_rank = isset($_REQUEST['rank_name']) ? $_REQUEST['rank_name'] : null; $rank_name = isset($_REQUEST['rank_name']) ? $_REQUEST['rank_name'] : null;
if(!Validator::guildName($guild_name)) { if(!Validator::guildName($guild_name)) {
$errors[] = Validator::getLastError(); $errors[] = Validator::getLastError();
} }
if(empty($errors)) { if(empty($errors)) {
if(!Validator::rankName($new_rank)) { if(!Validator::rankName($rank_name)) {
$errors[] = 'Invalid rank name format.'; $errors[] = 'Invalid rank name format.';
} }
if(!$logged) { if(!$logged) {
@ -45,7 +45,7 @@ if(empty($errors)) {
$new_rank = new OTS_GuildRank(); $new_rank = new OTS_GuildRank();
$new_rank->setGuild($guild); $new_rank->setGuild($guild);
$new_rank->setLevel(1); $new_rank->setLevel(1);
$new_rank->setName($new_rank); $new_rank->setName($rank_name);
$new_rank->save(); $new_rank->save();
header("Location: ?subtopic=guilds&guild=".$guild->getName()."&action=manager"); header("Location: ?subtopic=guilds&guild=".$guild->getName()."&action=manager");
echo 'New rank added. Redirecting...'; echo 'New rank added. Redirecting...';