#314 delete tbc account

This commit is contained in:
Ulf Gebhardt 2017-01-17 07:31:36 +01:00
parent c6d1467cf3
commit aaf902377d
6 changed files with 64 additions and 2 deletions

View File

@ -68,6 +68,27 @@ function init_saimod_mojotrollz_server_tbc_account_show(){
});
});
}
{
$('#btn_del_account').click(function(){
var id = $(this).attr('account');
$.ajax({ type :'GET',
url : './sai.php',
data : { sai_mod: '.SAI.saimod_mojotrollz_server_tbc',
action: 'delete_account',
id: id},
success : function(data) {
if(data.status){
alert('ok');
system.back();
} else {
alert('Fail: '+data.result.message);
}
}
});
});
}
}
function init_saimod_mojotrollz_server_tbc_character(){

View File

@ -69,6 +69,17 @@ class saimod_mojotrollz_server_tbc extends \SYSTEM\SAI\SaiModule {
}
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/tpl/account_show.tpl',$vars);
}
public static function sai_mod__SAI_saimod_mojotrollz_server_tbc_action_delete_account($id){
$account = \SQL\TBC_ACCOUNT_CHARACTERS_COUNT::Q1(array($id));
if(!$account){
throw new \SYSTEM\LOG\ERROR('Account not found.');}
if($account['char_count'] > 0){
throw new \SYSTEM\LOG\ERROR('Account still has Characters.');}
\SQL\TBC_ACCOUNT_DELETE::QI(array($id));
return \SYSTEM\LOG\JsonResult::ok();
}
public static function sai_mod__SAI_saimod_mojotrollz_server_tbc_action_character($search='%',$page=0){
$res = \SQL\TBC_CHARACTERS::QQ(array($search,$search,$search));
$count = \SQL\TBC_CHARACTERS_COUNT::Q1(array($search,$search,$search))['count'];

View File

@ -17,4 +17,5 @@ REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `na
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5670, 42, 2, 5600, 'character_show', 'guid', 'UINT0');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5671, 42, 2, 5600, 'change_account', 'guid', 'UINT0');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5672, 42, 2, 5600, 'change_account', 'accountname', 'STRING');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5672, 42, 2, 5600, 'change_account', 'accountname', 'STRING');
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5673, 42, 2, 5600, 'delete_account', 'id', 'UINT0');

View File

@ -0,0 +1,11 @@
<?php
namespace SQL;
class TBC_ACCOUNT_CHARACTERS_COUNT extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'SELECT accounts.id, COUNT(chars.guid) as char_count'.
' FROM mangos_one_realm.account as accounts'.
' LEFT JOIN mangos_one_chars.characters as chars ON accounts.id = chars.account'.
' WHERE accounts.id = ?;';
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace SQL;
class TBC_ACCOUNT_DELETE extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'DELETE FROM mangos_one_realm.account WHERE id = ?;';
}
}

View File

@ -25,7 +25,17 @@
<tr>
<th>System Account</th>
<td><a href="#!security(user);username.${system_account}">${system_account}</a></td>
</tr>
</tr>
<tr>
<th></th>
<td></td>
</tr>
<tr>
<th>Delete Account</th>
<td>
<button account="${id}" class="btn-sm btn btn-danger" id="btn_del_account" type="submit"><span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span> Delete</button>
</td>
</tr>
</table>
<br/>
<table class="table table-hover table-condensed sai_table tablesorter">