Skip to content

Commit

Permalink
Intruducing mybb#197
Browse files Browse the repository at this point in the history
Warnings when users try to change settings which often cause problems.
Also a JS password comparison.
  • Loading branch information
Destroy666x committed Jul 19, 2014
1 parent 6b293f0 commit a6e8a04
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
55 changes: 55 additions & 0 deletions install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,41 @@ function configure()
global $output, $mybb, $errors, $lang;

$output->print_header($lang->board_config, 'config');

echo <<<EOF
<script type="text/javascript">
function warnUser(inp, warn)
{
var parenttr = $('#'+inp.id).closest('tr');
if(inp.value != inp.defaultValue)
{
if(!parenttr.next('.setting_peeker').length)
{
var revertlink = ' <a href="javascript:revertSetting(\''+inp.defaultValue+'\', \'#'+inp.id+'\');">{$lang->config_step_revert}</a>';
parenttr.removeClass('last').after('<tr class="setting_peeker"><td colspan="2">'+warn+revertlink+'</td></tr>');
}
} else {
parenttr.next('.setting_peeker').remove();
if(parenttr.is(':last-child'))
{
parenttr.addClass('last');
}
}
}
function revertSetting(defval, inpid)
{
$(inpid).val(defval);
var parenttr = $(inpid).closest('tr');
parenttr.next('.setting_peeker').remove();
if(parenttr.is(':last-child'))
{
parenttr.addClass('last');
}
}
</script>
EOF;

// If board configuration errors
if(is_array($errors))
Expand Down Expand Up @@ -1894,6 +1929,26 @@ function create_admin_user()
}
}
$output->print_header($lang->create_admin, 'admin');

echo <<<EOF
<script type="text/javascript">
function comparePass()
{
var parenttr = $('#adminpass2').closest('tr');
var passval = $('#adminpass2').val();
if(passval && passval != $('#adminpass').val())
{
if(!parenttr.next('.pass_peeker').length)
{
parenttr.removeClass('last').after('<tr class="pass_peeker"><td colspan="2">{$lang->admin_step_nomatch}</td></tr>');
}
} else {
parenttr.addClass('last').next('.pass_peeker').remove();
}
}
</script>
EOF;

if(is_array($errors))
{
Expand Down
12 changes: 7 additions & 5 deletions install/resources/language.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
</tr>
<tr class="alt_row last">
<td class="first"><label for="bburl">Forum URL (No trailing slash):</label></td>
<td class="last alt_col"><input type="text" class="text_input" name="bburl" id="bburl" value="{2}" /></td>
<td class="last alt_col"><input type="text" class="text_input" name="bburl" id="bburl" value="{2}" onkeyup="warnUser(this, \'This option was set automatically. Do not change it if you are not sure about the correct value, otherwise links on your forum may be broken.\')" onchange="warnUser(this, \'This option was set automatically. Do not change it if you are not sure about the correct value, otherwise links on your forum may be broken.\')" /></td>
</tr>
<tr>
<th colspan="2" class="first last">Website Details</th>
Expand All @@ -242,11 +242,11 @@
</tr>
<tr>
<td class="first"><label for="cookiedomain">Cookie Domain:</label></td>
<td class="last alt_col"><input type="text" class="text_input" name="cookiedomain" id="cookiedomain" value="{5}" /></td>
<td class="last alt_col"><input type="text" class="text_input" name="cookiedomain" id="cookiedomain" value="{5}" onkeyup="warnUser(this, \'This option was set automatically. Do not change it if you are not sure about the correct value, otherwise logging in or out on your forum may be broken.\')" onchange="warnUser(this, \'This option was set automatically. Do not change it if you are not sure about the correct value, otherwise logging in or out on your forum may be broken.\')" /></td>
</tr>
<tr class="alt_row last">
<td class="first"><label for="cookiepath">Cookie Path:</label></td>
<td class="last alt_col"><input type="text" class="text_input" name="cookiepath" id="cookiepath" value="{6}" /></td>
<td class="last alt_col"><input type="text" class="text_input" name="cookiepath" id="cookiepath" value="{6}" onkeyup="warnUser(this, \'This option was set automatically. Do not change it if you are not sure about the correct value, otherwise logging in or out on your forum may be broken.\')" onchange="warnUser(this, \'This option was set automatically. Do not change it if you are not sure about the correct value, otherwise logging in or out on your forum may be broken.\')" /></td>
</tr>
<tr>
<th colspan="2" class="first last">Contact Details</th>
Expand All @@ -269,6 +269,7 @@
</div>';
$l['config_step_error_url'] = 'You did not enter the URL to your forums.';
$l['config_step_error_name'] = 'You did not enter a name for your copy of MyBB.';
$l['config_step_revert'] = 'Click to revert this setting to original value.';


$l['admin_step_setupsettings'] = '<p>Setting up basic board settings...</p>';
Expand All @@ -292,11 +293,11 @@
</tr>
<tr class="alt_row">
<td class="first"><label for="adminpass">Password:</label></td>
<td class="alt_col last"><input type="password" class="text_input" name="adminpass" id="adminpass" value="" autocomplete="off" /></td>
<td class="alt_col last"><input type="password" class="text_input" name="adminpass" id="adminpass" value="" autocomplete="off" onchange="comparePass()" /></td>
</tr>
<tr class="last">
<td class="first"><label for="adminpass2">Retype Password:</label></td>
<td class="alt_col last"><input type="password" class="text_input" name="adminpass2" id="adminpass2" value="" autocomplete="off" /></td>
<td class="alt_col last"><input type="password" class="text_input" name="adminpass2" id="adminpass2" value="" autocomplete="off" onchange="comparePass()" /></td>
</tr>
<tr>
<th colspan="2" class="first last">Contact Details</th>
Expand All @@ -320,6 +321,7 @@
$l['admin_step_error_nopassword'] = 'You did not enter a password for your Administrator account.';
$l['admin_step_error_nomatch'] = 'The passwords you entered do not match.';
$l['admin_step_error_noemail'] = 'You did not enter your email address for the Administrator\'s account.';
$l['admin_step_nomatch'] = 'The retyped password does not match the password from the first input. Please correct it before continuing.';

$l['done_step_usergroupsinserted'] = "<p>Importing user groups...";
$l['done_step_admincreated'] = '<p>Creating Administrator account...';
Expand Down

0 comments on commit a6e8a04

Please sign in to comment.