Skip to content

Commit

Permalink
Allow reset of highscore via ACP
Browse files Browse the repository at this point in the history
  • Loading branch information
rmcgirr83 committed Mar 6, 2021
1 parent 51f0222 commit c5f03d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
17 changes: 15 additions & 2 deletions acp/settings_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class settings_module

public function main()
{
global $config, $phpbb_container, $request, $template, $phpbb_root_path;
global $config, $db, $phpbb_container, $phpbb_log, $request, $template, $user, $phpbb_root_path, $table_prefix;

$language = $phpbb_container->get('language');
$this->tpl_name = 'acp_hangman_settings';
Expand All @@ -40,13 +40,26 @@ public function main()
trigger_error($language->lang('ACP_HANGMAN_SETTING_SAVED') . adm_back_link($this->u_action));
}

if ($request->is_set_post('reset_highscore'))
{
define ('HANGMAN_SCORE_TABLE', $table_prefix . 'hangman_score');

$db->sql_query('TRUNCATE TABLE ' . HANGMAN_SCORE_TABLE);

$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_HANGMAN_HIGHSCORE_TABLE_CLEARED');

if ($request->is_ajax())
{
trigger_error('HIGHSCORE_TABLE_CLEARED');
}
}
$template->assign_vars(array(
'ACP_HANGMAN_LIVES' => $config['mot_hangman_lives'],
'ACP_HANGMAN_POINTS_LETTER' => $config['mot_hangman_points_letter'],
'ACP_HANGMAN_POINTS_LOOSE' => $config['mot_hangman_points_loose'],
'ACP_HANGMAN_POINTS_WIN' => $config['mot_hangman_points_win'],
'ACP_HANGMAN_POINTS_WORD' => $config['mot_hangman_points_word'],
'U_ACTION' => $this->u_action . '&action=submit',
'U_ACTION' => $this->u_action,
'HANGMAN_VERSION' => $config['mot_hangman_version'],
'HANGMAN_YEAR' => date('Y'),
'ICON_PAYPAL' => '<img src="' . $phpbb_root_path . 'ext/mot/hangman/adm/images/Paypal.svg" />',
Expand Down
9 changes: 9 additions & 0 deletions adm/style/acp_hangman_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ <h1>{{ lang('ACP_HANGMAN_SETTINGS') }}</h1>

</form>

<fieldset>
<form id="reset_highscore_action" method="post" action="{U_ACTION}" data-ajax="true">
<dl>
<dt><label for="reset_highscore">{{ lang('RESET_HIGHSCORE') }}</label><br /><span>&nbsp;</span></dt>
<dd><input type="hidden" name="reset_highscore" value="online" /><input class="button2" type="submit" id="reset_highscore" name="reset_highscore" value="{L_RUN}" /></dd>
</dl>
</form>
</fieldset>

<p class="centered_text">
Hangman ver {{ HANGMAN_VERSION }} &copy; 2021 - {{ HANGMAN_YEAR }} by Mike-on-Tour
</p>
Expand Down
3 changes: 3 additions & 0 deletions language/en/info_acp_hangman.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@
(integer greater than or equal to zero)',
'ACP_HANGMAN_SETTING_SAVED' => 'Settings for the Hangman Game successfully saved.',
'SUPPORT_HANGMAN' => 'If you want to support Hangman´s development please use this link to donate:<br>',
'RESET_HIGHSCORE' => 'Reset Highscore',
'LOG_HANGMAN_HIGHSCORE_TABLE_CLEARED' => 'Hangman Highscore table cleared',
'HIGHSCORE_TABLE_CLEARED' => 'Highscore table cleared',
));

0 comments on commit c5f03d5

Please sign in to comment.