* @author Slawkens * @copyright 2017 MyAAC * @version 0.6.1 * @link http://my-aac.org */ defined('MYAAC') or die('Direct access not allowed!'); //set rights in guild $guild_name = isset($_REQUEST['guild']) ? $_REQUEST['guild'] : NULL; $name = isset($_REQUEST['name']) ? stripslashes($_REQUEST['name']) : NULL; if(!$logged) { $errors[] = 'You are not logged in. You can\'t accept invitations.'; } if(!Validator::guildName($guild_name)) { $errors[] = Validator::getLastError(); } if(empty($errors)) { $guild = $ots->createObject('Guild'); $guild->find($guild_name); if(!$guild->isLoaded()) { $errors[] = 'Guild with name '.$guild_name.' doesn\'t exist.'; } } if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') { if(!Validator::characterName($name)) { $errors[] = 'Invalid name format.'; } if(empty($errors)) { $player = new OTS_Player(); $player->find($name); if(!$player->isLoaded()) { $errors[] = 'Player with name '.$name.' doesn\'t exist.'; } else { $rank_of_player = $player->getRank(); if($rank_of_player->isLoaded()) { $errors[] = 'Character with name '.$name.' is already in guild. You must leave guild before you join other guild.'; } } } } if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') { if(empty($errors)) { $is_invited = false; include(SYSTEM . 'libs/pot/InvitesDriver.php'); new InvitesDriver($guild); $invited_list = $guild->listInvites(); if(count($invited_list) > 0) { foreach($invited_list as $invited) { if($invited->getName() == $player->getName()) { $is_invited = true; } } } if(!$is_invited) { $errors[] = 'Character '.$player->getName.' isn\'t invited to guild '.$guild->getName().'.'; } } } else { if(empty($errors)) { $acc_invited = false; $account_players = $account_logged->getPlayers(); include(SYSTEM . 'libs/pot/InvitesDriver.php'); new InvitesDriver($guild); $invited_list = $guild->listInvites(); if(count($invited_list) > 0) { foreach($invited_list as $invited) { foreach($account_players as $player_from_acc) { if($invited->getName() == $player_from_acc->getName()) { $acc_invited = true; $list_of_invited_players[] = $player_from_acc->getName(); } } } } } if(!$acc_invited) { $errors[] = 'Any character from your account isn\'t invited to '.$guild->getName().'.'; } } if(!empty($errors)) { echo $twig->render('error_box.html.twig', array('errors' => $errors)); echo '
'; } else { if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') { $guild->acceptInvite($player); echo '
Accept invitation
Player with name '.$player->getName().' has been added to guild '.$guild->getName().'.

'; } else { echo ''; echo ''; echo '
Accept invitation
Select character to join guild:
'; sort($list_of_invited_players); $i = 0; foreach($list_of_invited_players as $invited_player_from_list) { echo '
'; } echo '

'; } } ?>