myaac/system/pages/guilds/delete_by_admin.php
slawkens1 05f8756a12 * fixed viewing pages with capital letters (like serverInfo) on case sensitive systems
* fixed changing comment of characters with space and other special
characters in name (#29)
* fixed viewing guilds with space and other special characters in name
(#29)
* (kathrine template) fixed displaying menu when no URI is set (URI =
'/')
* added some additional checks for Validator guildName and rankName if
name is empty
* (internal) new twig filter: urlencode, which is using urlencode php
function
2017-11-14 19:58:44 +01:00

68 lines
1.8 KiB
PHP

<?php
/**
* Delete by admin
*
* @package MyAAC
* @author Gesior <jerzyskalski@wp.pl>
* @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC
* @link http://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$guild_name = urldecode($_REQUEST['guild']);
if(!Validator::guildName($guild_name)) {
$errors[] = Validator::getLastError();
}
if(empty($errors)) {
$guild = new OTS_Guild();
$guild->find($guild_name);
if(!$guild->isLoaded()) {
$errors[] = 'Guild with name <b>' . $guild_name . '</b> doesn\'t exist.';
}
}
if(empty($errors)) {
if($logged) {
if(admin()) {
$saved = false;
if(isset($_POST['todo']) && $_POST['todo'] == 'save') {
delete_guild($guild->getId());
$saved = true;
}
if($saved) {
echo $twig->render('success.html.twig', array(
'title' => 'Guild Deleted',
'description' => 'Guild with name <b>' . $guild_name . '</b> has been deleted.',
'custom_buttons' => $twig->render('guilds.back_button.html.twig')
));
}
else {
echo $twig->render('success.html.twig', array(
'title' => 'Delete Guild',
'description' => 'Are you sure you want delete guild <b>' . $guild_name . '</b>?<br/>
<form action="?subtopic=guilds&guild=' . $guild->getName() . '&action=delete_by_admin" METHOD="post"><input type="hidden" name="todo" value="save"><input type="submit" value="Yes, delete"></form>',
'custom_buttons' => $twig->render('guilds.back_button.html.twig')
));
}
}
else {
$errors[] = 'You are not an admin!';
}
}
else {
$errors[] = "You are not logged. You can't delete guild.";
}
}
if(!empty($errors)) {
echo $twig->render('error_box.html.twig', array('errors' => $errors));
echo $twig->render('guilds.back_button.html.twig', array(
'new_line' => true,
'action' => '?subtopic=guilds'
));
}
?>