Delay to character deletion has been added.

When user requests character delete, he will have to wait delay from
config. During this time when user logs in on his account, on website,
player will see information that character is awaiting delete. User can
cancel this operation.
This commit is contained in:
Kuzirashi
2014-04-19 01:43:49 +02:00
parent fb86861447
commit a5bf484fdb
4 changed files with 70 additions and 2 deletions

View File

@@ -205,6 +205,15 @@ CREATE TABLE IF NOT EXISTS `znote_forum_posts` (
`updated` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `znote_deleted_characters` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`original_account_id` int(11) NOT NULL,
`character_name` varchar(255) NOT NULL,
`time` datetime NOT NULL,
`done` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
</textarea>
</li>
<li>

View File

@@ -759,6 +759,31 @@ function user_delete_character($char_id) {
mysql_delete("DELETE FROM `znote_players` WHERE `player_id`='$char_id';");
}
// Delete character with supplied id with a delay.
function user_delete_character_soft($char_id) {
$char_id = (int)$char_id;
$char_name = user_character_name($char_id);
$original_acc_id = user_character_account_id($char_name);
if(!user_character_pending_delete($char_name))
mysql_insert('INSERT INTO `znote_deleted_characters`(`original_account_id`, `character_name`, `time`, `done`) VALUES(' . $original_acc_id . ', "' . $char_name . '", (NOW() + INTERVAL ' . Config('delete_character_interval') . '), 0)');
else
return false;
}
// Check if character will be deleted soon.
function user_character_pending_delete($char_name) {
$char_name = sanitize($char_name);
$result = mysql_select_single('SELECT `done` FROM `znote_deleted_characters` WHERE `character_name` = "' . $char_name . '"');
return ($result === false) ? false : !$result['done'];
}
// Get pending character deletes for supplied account id.
function user_pending_deletes($acc_id) {
$acc_id = (int)$acc_id;
return mysql_select_multi('SELECT `id`, `character_name`, `time` FROM `znote_deleted_characters` WHERE `original_account_id` = ' . $acc_id . ' AND `done` = 0');
}
// Parameter: accounts.id returns: An array containing detailed information of every character on the account.
// Array: [0] = name, [1] = level, [2] = vocation, [3] = town_id, [4] = lastlogin, [5] = online
function user_character_list($account_id) {
@@ -1372,6 +1397,14 @@ function user_character_id($charname) {
else return false;
}
// Get character name from character ID
function user_character_name($charID) {
$charID = (int)$charID;
$char = mysql_select_single('SELECT `name` FROM `players` WHERE `id` = ' . $charID);
if ($char !== false) return $char['name'];
else return false;
}
// Hide user character.
function user_character_hide($username) {
$username = sanitize($username);