1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-06 06:25:04 +02:00

Merge pull request #2420 from prototech/ticket/9388

[ticket/9388] Only display the settings for the selected method in the auth and search ACP pages.

* prototech/ticket/9388:
  [ticket/9388] Use "togglable" instead of "toggable"
  [ticket/9388] Do not nest the <fieldset> tags in the OAuth settings.
  [ticket/9388] Reopen <fieldset> after auth templates.
  [ticket/9388] Fix unit tests.
  [ticket/9388] Use the new toggle function for the avatar type <select>.
  [ticket/9388] Display only the settings for the selected search backend.
  [ticket/9388] Display only the settings for the auth method that's selected.
  [ticket/9388] Add support for making <select> options able to toggle settings.
This commit is contained in:
Joas Schilling 2014-05-11 10:48:10 +02:00
commit 6cd7abe255
17 changed files with 102 additions and 119 deletions

View File

@ -33,9 +33,12 @@
<!-- END options --> <!-- END options -->
<!-- IF S_AUTH --> <!-- IF S_AUTH -->
</fieldset>
<!-- BEGIN auth_tpl --> <!-- BEGIN auth_tpl -->
<!-- INCLUDE {auth_tpl.TEMPLATE_FILE} --> <!-- INCLUDE {auth_tpl.TEMPLATE_FILE} -->
<!-- END auth_tpl --> <!-- END auth_tpl -->
<fieldset>
<legend>{L_ACP_SUBMIT_CHANGES}</legend>
<!-- ENDIF --> <!-- ENDIF -->
<p class="submit-buttons"> <p class="submit-buttons">

View File

@ -114,10 +114,10 @@
</dl> </dl>
<dl> <dl>
<dt><label>{L_AVATAR_TYPE}{L_COLON}</label></dt> <dt><label>{L_AVATAR_TYPE}{L_COLON}</label></dt>
<dd><select name="avatar_driver" id="avatar_driver"> <dd><select name="avatar_driver" id="avatar_driver" data-togglable-settings="true">
<option value="">{L_NO_AVATAR_CATEGORY}</option> <option value="">{L_NO_AVATAR_CATEGORY}</option>
<!-- BEGIN avatar_drivers --> <!-- BEGIN avatar_drivers -->
<option value="{avatar_drivers.DRIVER}"<!-- IF avatar_drivers.SELECTED --> selected="selected"<!-- ENDIF -->>{avatar_drivers.L_TITLE}</option> <option value="{avatar_drivers.DRIVER}"<!-- IF avatar_drivers.SELECTED --> selected="selected"<!-- ENDIF --> data-toggle-setting="#avatar_option_{avatar_drivers.DRIVER}">{avatar_drivers.L_TITLE}</option>
<!-- END avatar_drivers --> <!-- END avatar_drivers -->
</select></dd> </select></dd>
</dl> </dl>
@ -139,8 +139,6 @@
</fieldset> </fieldset>
</form> </form>
<!-- INCLUDEJS avatars.js -->
<!-- ELSEIF S_LIST --> <!-- ELSEIF S_LIST -->
<a href="{U_BACK}" style="float: {S_CONTENT_FLOW_END};">&laquo; {L_BACK}</a> <a href="{U_BACK}" style="float: {S_CONTENT_FLOW_END};">&laquo; {L_BACK}</a>

View File

@ -46,13 +46,13 @@
<legend>{L_SEARCH_TYPE}</legend> <legend>{L_SEARCH_TYPE}</legend>
<dl> <dl>
<dt><label for="search_type">{L_SEARCH_TYPE}{L_COLON}</label><br /><span>{L_SEARCH_TYPE_EXPLAIN}</span></dt> <dt><label for="search_type">{L_SEARCH_TYPE}{L_COLON}</label><br /><span>{L_SEARCH_TYPE_EXPLAIN}</span></dt>
<dd><select id="search_type" name="config[search_type]">{S_SEARCH_TYPES}</select></dd> <dd><select id="search_type" name="config[search_type]" data-togglable-settings="true">{S_SEARCH_TYPES}</select></dd>
</dl> </dl>
</fieldset> </fieldset>
<!-- BEGIN backend --> <!-- BEGIN backend -->
<fieldset> <fieldset id="search_{backend.IDENTIFIER}_settings">
<legend>{backend.NAME}</legend> <legend>{backend.NAME}</legend>
{backend.SETTINGS} {backend.SETTINGS}
</fieldset> </fieldset>

View File

@ -13,10 +13,10 @@
<legend>{L_AVATAR_SELECT}</legend> <legend>{L_AVATAR_SELECT}</legend>
<dl> <dl>
<dt><label>{L_AVATAR_TYPE}</label></dt> <dt><label>{L_AVATAR_TYPE}</label></dt>
<dd><select name="avatar_driver" id="avatar_driver"> <dd><select name="avatar_driver" id="avatar_driver" data-togglable-settings="true">
<option value="">{L_NO_AVATAR_CATEGORY}</option> <option value="">{L_NO_AVATAR_CATEGORY}</option>
<!-- BEGIN avatar_drivers --> <!-- BEGIN avatar_drivers -->
<option value="{avatar_drivers.DRIVER}"<!-- IF avatar_drivers.SELECTED --> selected="selected"<!-- ENDIF -->>{avatar_drivers.L_TITLE}</option> <option value="{avatar_drivers.DRIVER}"<!-- IF avatar_drivers.SELECTED --> selected="selected"<!-- ENDIF --> data-toggle-setting="#avatar_option_{avatar_drivers.DRIVER}">{avatar_drivers.L_TITLE}</option>
<!-- END avatar_drivers --> <!-- END avatar_drivers -->
</select></dd> </select></dd>
</dl> </dl>
@ -35,5 +35,3 @@
{S_FORM_TOKEN} {S_FORM_TOKEN}
</fieldset> </fieldset>
</form> </form>
<!-- INCLUDEJS avatars.js -->

View File

@ -1,32 +1,35 @@
<dl> <fieldset id="auth_ldap_settings">
<dt><label for="ldap_server">{L_LDAP_SERVER}{L_COLON}</label><br /><span>{L_LDAP_SERVER_EXPLAIN}</span></dt> <legend>{L_LDAP}</legend>
<dd><input type="text" id="ldap_server" size="40" name="config[ldap_server]" value="{AUTH_LDAP_SERVER}" /></dd> <dl>
</dl> <dt><label for="ldap_server">{L_LDAP_SERVER}{L_COLON}</label><br /><span>{L_LDAP_SERVER_EXPLAIN}</span></dt>
<dl> <dd><input type="text" id="ldap_server" size="40" name="config[ldap_server]" value="{AUTH_LDAP_SERVER}" /></dd>
<dt><label for="ldap_port">{L_LDAP_PORT}{L_COLON}</label><br /><span>{L_LDAP_PORT_EXPLAIN}</span></dt> </dl>
<dd><input type="text" id="ldap_port" size="40" name="config[ldap_port]" value="{AUTH_LDAP_PORT}" /></dd> <dl>
</dl> <dt><label for="ldap_port">{L_LDAP_PORT}{L_COLON}</label><br /><span>{L_LDAP_PORT_EXPLAIN}</span></dt>
<dl> <dd><input type="text" id="ldap_port" size="40" name="config[ldap_port]" value="{AUTH_LDAP_PORT}" /></dd>
<dt><label for="ldap_dn">{L_LDAP_DN}{L_COLON}</label><br /><span>{L_LDAP_DN_EXPLAIN}</span></dt> </dl>
<dd><input type="text" id="ldap_dn" size="40" name="config[ldap_base_dn]" value="{AUTH_LDAP_BASE_DN}" /></dd> <dl>
</dl> <dt><label for="ldap_dn">{L_LDAP_DN}{L_COLON}</label><br /><span>{L_LDAP_DN_EXPLAIN}</span></dt>
<dl> <dd><input type="text" id="ldap_dn" size="40" name="config[ldap_base_dn]" value="{AUTH_LDAP_BASE_DN}" /></dd>
<dt><label for="ldap_uid">{L_LDAP_UID}{L_COLON}</label><br /><span>{L_LDAP_UID_EXPLAIN}</span></dt> </dl>
<dd><input type="text" id="ldap_uid" size="40" name="config[ldap_uid]" value="{AUTH_LDAP_UID}" /></dd> <dl>
</dl> <dt><label for="ldap_uid">{L_LDAP_UID}{L_COLON}</label><br /><span>{L_LDAP_UID_EXPLAIN}</span></dt>
<dl> <dd><input type="text" id="ldap_uid" size="40" name="config[ldap_uid]" value="{AUTH_LDAP_UID}" /></dd>
<dt><label for="ldap_user_filter">{L_LDAP_USER_FILTER}{L_COLON}</label><br /><span>{L_LDAP_USER_FILTER_EXPLAIN}</span></dt> </dl>
<dd><input type="text" id="ldap_user_filter" size="40" name="config[ldap_user_filter]" value="{AUTH_LDAP_USER_FILTER}" /></dd> <dl>
</dl> <dt><label for="ldap_user_filter">{L_LDAP_USER_FILTER}{L_COLON}</label><br /><span>{L_LDAP_USER_FILTER_EXPLAIN}</span></dt>
<dl> <dd><input type="text" id="ldap_user_filter" size="40" name="config[ldap_user_filter]" value="{AUTH_LDAP_USER_FILTER}" /></dd>
<dt><label for="ldap_email">{L_LDAP_EMAIL}{L_COLON}</label><br /><span>{L_LDAP_EMAIL_EXPLAIN}</span></dt> </dl>
<dd><input type="email" id="ldap_email" size="40" name="config[ldap_email]" value="{AUTH_LDAP_EMAIL}" /></dd> <dl>
</dl> <dt><label for="ldap_email">{L_LDAP_EMAIL}{L_COLON}</label><br /><span>{L_LDAP_EMAIL_EXPLAIN}</span></dt>
<dl> <dd><input type="email" id="ldap_email" size="40" name="config[ldap_email]" value="{AUTH_LDAP_EMAIL}" /></dd>
<dt><label for="ldap_user">{L_LDAP_USER}{L_COLON}</label><br /><span>{L_LDAP_USER_EXPLAIN}</span></dt> </dl>
<dd><input type="text" id="ldap_user" size="40" name="config[ldap_user]" value="{AUTH_LDAP_USER}" /></dd> <dl>
</dl> <dt><label for="ldap_user">{L_LDAP_USER}{L_COLON}</label><br /><span>{L_LDAP_USER_EXPLAIN}</span></dt>
<dl> <dd><input type="text" id="ldap_user" size="40" name="config[ldap_user]" value="{AUTH_LDAP_USER}" /></dd>
<dt><label for="ldap_password">{L_LDAP_PASSWORD}{L_COLON}</label><br /><span>{L_LDAP_PASSWORD_EXPLAIN}</span></dt> </dl>
<dd><input type="password" id="ldap_password" size="40" name="config[ldap_password]" value="{AUTH_LDAP_PASSWORD}" autocomplete="off" /></dd> <dl>
</dl> <dt><label for="ldap_password">{L_LDAP_PASSWORD}{L_COLON}</label><br /><span>{L_LDAP_PASSWORD_EXPLAIN}</span></dt>
<dd><input type="password" id="ldap_password" size="40" name="config[ldap_password]" value="{AUTH_LDAP_PASSWORD}" autocomplete="off" /></dd>
</dl>
</fieldset>

View File

@ -1,17 +1,18 @@
<h2>{L_AUTH_PROVIDER_OAUTH_TITLE}</h2>
<p>{L_AUTH_PROVIDER_OAUTH_EXPLAIN}</p> <div id="auth_oauth_settings">
<p>{L_AUTH_PROVIDER_OAUTH_EXPLAIN}</p>
<!-- BEGIN oauth_services --> <!-- BEGIN oauth_services -->
<fieldset> <fieldset>
<legend>{oauth_services.ACTUAL_NAME}</legend> <legend>{oauth_services.ACTUAL_NAME}</legend>
<dl> <dl>
<dt><label for="oauth_service_{oauth_services.NAME}_key">{L_AUTH_PROVIDER_OAUTH_KEY}{L_COLON}</label></dt> <dt><label for="oauth_service_{oauth_services.NAME}_key">{L_AUTH_PROVIDER_OAUTH_KEY}{L_COLON}</label></dt>
<dd><input type="text" id="oauth_service_{oauth_services.NAME}_key" size="40" name="config[auth_oauth_{oauth_services.NAME}_key]" value="{oauth_services.KEY}" /></dd> <dd><input type="text" id="oauth_service_{oauth_services.NAME}_key" size="40" name="config[auth_oauth_{oauth_services.NAME}_key]" value="{oauth_services.KEY}" /></dd>
</dl> </dl>
<dl> <dl>
<dt><label for="oauth_service_{oauth_services.NAME}_secret">{L_AUTH_PROVIDER_OAUTH_SECRET}{L_COLON}</label></dt> <dt><label for="oauth_service_{oauth_services.NAME}_secret">{L_AUTH_PROVIDER_OAUTH_SECRET}{L_COLON}</label></dt>
<dd><input type="text" id="oauth_service_{oauth_services.NAME}_secret" size="40" name="config[auth_oauth_{oauth_services.NAME}_secret]" value="{oauth_services.SECRET}" /></dd> <dd><input type="text" id="oauth_service_{oauth_services.NAME}_secret" size="40" name="config[auth_oauth_{oauth_services.NAME}_secret]" value="{oauth_services.SECRET}" /></dd>
</dl> </dl>
</fieldset> </fieldset>
<!-- END oauth_services --> <!-- END oauth_services -->
</div>

View File

@ -1,15 +0,0 @@
(function($) { // Avoid conflicts with other libraries
"use strict";
function avatarHide() {
$('#avatar_options > div').hide();
var selected = $('#avatar_driver').val();
$('#avatar_option_' + selected).show();
}
avatarHide();
$('#avatar_driver').bind('change', avatarHide);
})(jQuery); // Avoid conflicts with other libraries

View File

@ -1475,6 +1475,21 @@ phpbb.toggleDisplay = function(id, action, type) {
$('#' + id).css('display', ((action === 1) ? type : 'none')); $('#' + id).css('display', ((action === 1) ? type : 'none'));
} }
/**
* Toggle additional settings based on the selected
* option of select element.
*
* @param jQuery el jQuery select element object.
* @return undefined
*/
phpbb.toggleSelectSettings = function(el) {
el.children().each(function() {
var option = $(this),
setting = $(option.data('toggle-setting'));
setting.toggle(option.is(':selected'));
});
};
/** /**
* Get function from name. * Get function from name.
* Based on http://stackoverflow.com/a/359910 * Based on http://stackoverflow.com/a/359910
@ -1516,6 +1531,16 @@ $(document).ready(function() {
// Update browser history URL to point to specific post in viewtopic.php // Update browser history URL to point to specific post in viewtopic.php
// when using view=unread#unread link. // when using view=unread#unread link.
phpbb.history.replaceUrl($('#unread[data-url]').data('url')); phpbb.history.replaceUrl($('#unread[data-url]').data('url'));
// Hide settings that are not selected via select element.
$('select[data-togglable-settings]').each(function() {
var select = $(this);
select.change(function() {
phpbb.toggleSelectSettings(select);
});
phpbb.toggleSelectSettings(select);
});
}); });
})(jQuery); // Avoid conflicts with other libraries })(jQuery); // Avoid conflicts with other libraries

View File

@ -363,7 +363,7 @@ class acp_board
'title' => 'ACP_AUTH_SETTINGS', 'title' => 'ACP_AUTH_SETTINGS',
'vars' => array( 'vars' => array(
'legend1' => 'ACP_AUTH_SETTINGS', 'legend1' => 'ACP_AUTH_SETTINGS',
'auth_method' => array('lang' => 'AUTH_METHOD', 'validate' => 'string', 'type' => 'select', 'method' => 'select_auth_method', 'explain' => false), 'auth_method' => array('lang' => 'AUTH_METHOD', 'validate' => 'string', 'type' => 'select:1:toggable', 'method' => 'select_auth_method', 'explain' => false),
) )
); );
break; break;
@ -715,7 +715,7 @@ class acp_board
foreach ($auth_plugins as $method) foreach ($auth_plugins as $method)
{ {
$selected = ($selected_method == $method) ? ' selected="selected"' : ''; $selected = ($selected_method == $method) ? ' selected="selected"' : '';
$auth_select .= '<option value="' . $method . '"' . $selected . '>' . ucfirst($method) . '</option>'; $auth_select .= "<option value=\"$method\"$selected data-toggle-setting=\"#auth_{$method}_settings\">" . ucfirst($method) . '</option>';
} }
return $auth_select; return $auth_select;

View File

@ -79,7 +79,8 @@ class acp_search
$name = $search->get_name(); $name = $search->get_name();
$selected = ($config['search_type'] == $type) ? ' selected="selected"' : ''; $selected = ($config['search_type'] == $type) ? ' selected="selected"' : '';
$search_options .= '<option value="' . $type . '"' . $selected . '>' . $name . '</option>'; $identifier = substr($type, strrpos($type, '\\') + 1);
$search_options .= "<option value=\"$type\"$selected data-toggle-setting=\"#search_{$identifier}_settings\">$name</option>";
if (method_exists($search, 'acp')) if (method_exists($search, 'acp'))
{ {
@ -88,9 +89,10 @@ class acp_search
if (!$submit) if (!$submit)
{ {
$template->assign_block_vars('backend', array( $template->assign_block_vars('backend', array(
'NAME' => $name, 'NAME' => $name,
'SETTINGS' => $vars['tpl']) 'SETTINGS' => $vars['tpl'],
); 'IDENTIFIER' => $identifier,
));
} }
else if (is_array($vars['config'])) else if (is_array($vars['config']))
{ {

View File

@ -364,8 +364,9 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
if ($tpl_type[0] == 'select') if ($tpl_type[0] == 'select')
{ {
$size = (isset($tpl_type[1])) ? (int) $tpl_type[1] : 1; $size = (isset($tpl_type[1])) ? (int) $tpl_type[1] : 1;
$data_toggle = (!empty($tpl_type[2])) ? ' data-togglable-settings="true"' : '';
$tpl = '<select id="' . $key . '" name="' . $name . '"' . (($size > 1) ? ' size="' . $size . '"' : '') . '>' . $return . '</select>'; $tpl = '<select id="' . $key . '" name="' . $name . '"' . (($size > 1) ? ' size="' . $size . '"' : '') . $data_toggle . '>' . $return . '</select>';
} }
else else
{ {

View File

@ -406,6 +406,7 @@ $lang = array_merge($lang, array(
'APACHE_SETUP_BEFORE_USE' => 'You have to setup apache authentication before you switch phpBB to this authentication method. Keep in mind that the username you use for apache authentication has to be the same as your phpBB username. Apache authentication can only be used with mod_php (not with a CGI version) and safe_mode disabled.', 'APACHE_SETUP_BEFORE_USE' => 'You have to setup apache authentication before you switch phpBB to this authentication method. Keep in mind that the username you use for apache authentication has to be the same as your phpBB username. Apache authentication can only be used with mod_php (not with a CGI version) and safe_mode disabled.',
'LDAP' => 'LDAP',
'LDAP_DN' => 'LDAP base <var>dn</var>', 'LDAP_DN' => 'LDAP base <var>dn</var>',
'LDAP_DN_EXPLAIN' => 'This is the Distinguished Name, locating the user information, e.g. <samp>o=My Company,c=US</samp>.', 'LDAP_DN_EXPLAIN' => 'This is the Distinguished Name, locating the user information, e.g. <samp>o=My Company,c=US</samp>.',
'LDAP_EMAIL' => 'LDAP email attribute', 'LDAP_EMAIL' => 'LDAP email attribute',

View File

@ -1,15 +0,0 @@
(function($) { // Avoid conflicts with other libraries
"use strict";
function avatarHide() {
$('#avatar_options > div').hide();
var selected = $('#avatar_driver').val();
$('#avatar_option_' + selected).show();
}
avatarHide();
$('#avatar_driver').bind('change', avatarHide);
})(jQuery); // Avoid conflicts with other libraries

View File

@ -16,10 +16,10 @@
<fieldset> <fieldset>
<dl> <dl>
<dt><label>{L_AVATAR_TYPE}{L_COLON}</label></dt> <dt><label>{L_AVATAR_TYPE}{L_COLON}</label></dt>
<dd><select name="avatar_driver" id="avatar_driver"> <dd><select name="avatar_driver" id="avatar_driver" data-togglable-settings="true">
<option value="">{L_NO_AVATAR_CATEGORY}</option> <option value="">{L_NO_AVATAR_CATEGORY}</option>
<!-- BEGIN avatar_drivers --> <!-- BEGIN avatar_drivers -->
<option value="{avatar_drivers.DRIVER}"<!-- IF avatar_drivers.SELECTED --> selected="selected"<!-- ENDIF -->>{avatar_drivers.L_TITLE}</option> <option value="{avatar_drivers.DRIVER}"<!-- IF avatar_drivers.SELECTED --> selected="selected"<!-- ENDIF --> data-toggle-setting="#avatar_option_{avatar_drivers.DRIVER}">{avatar_drivers.L_TITLE}</option>
<!-- END avatar_drivers --> <!-- END avatar_drivers -->
</select></dd> </select></dd>
</dl> </dl>
@ -46,5 +46,3 @@
<!-- ENDIF --> <!-- ENDIF -->
</div> </div>
</div> </div>
<!-- INCLUDEJS avatars.js -->

View File

@ -1,15 +0,0 @@
(function($) { // Avoid conflicts with other libraries
"use strict";
function avatarHide() {
$('.[class^="avatar_option_"]').hide();
var selected = $('#avatar_driver').val();
$('.avatar_option_' + selected).show();
}
avatarHide();
$('#avatar_driver').bind('change', avatarHide);
})(jQuery); // Avoid conflicts with other libraries

View File

@ -27,10 +27,10 @@
<tr> <tr>
<td class="row1" width="35%"><b class="genmed">{L_AVATAR_TYPE}{L_COLON}</b></td> <td class="row1" width="35%"><b class="genmed">{L_AVATAR_TYPE}{L_COLON}</b></td>
<td class="row2"> <td class="row2">
<select name="avatar_driver" id="avatar_driver"> <select name="avatar_driver" id="avatar_driver" data-togglable-settings="true">
<option value="">{L_NO_AVATAR_CATEGORY}</option> <option value="">{L_NO_AVATAR_CATEGORY}</option>
<!-- BEGIN avatar_drivers --> <!-- BEGIN avatar_drivers -->
<option value="{avatar_drivers.DRIVER}"<!-- IF avatar_drivers.SELECTED --> selected="selected"<!-- ENDIF -->>{avatar_drivers.L_TITLE}</option> <option value="{avatar_drivers.DRIVER}"<!-- IF avatar_drivers.SELECTED --> selected="selected"<!-- ENDIF --> data-toggle-setting=".avatar_option_{avatar_drivers.DRIVER}">{avatar_drivers.L_TITLE}</option>
<!-- END avatar_drivers --> <!-- END avatar_drivers -->
</select></td> </select></td>
</tr> </tr>
@ -48,6 +48,4 @@
</tr> </tr>
</table> </table>
<!-- INCLUDEJS avatars.js -->
<!-- INCLUDE ucp_footer.html --> <!-- INCLUDE ucp_footer.html -->

View File

@ -18,8 +18,8 @@ class phpbb_acp_board_select_auth_method_test extends phpbb_test_case
public static function select_auth_method_data() public static function select_auth_method_data()
{ {
return array( return array(
array('acp_board_valid', '<option value="acp_board_valid" selected="selected">Acp_board_valid</option>'), array('acp_board_valid', '<option value="acp_board_valid" selected="selected" data-toggle-setting="#auth_acp_board_valid_settings">Acp_board_valid</option>'),
array('acp_board_invalid', '<option value="acp_board_valid">Acp_board_valid</option>'), array('acp_board_invalid', '<option value="acp_board_valid" data-toggle-setting="#auth_acp_board_valid_settings">Acp_board_valid</option>'),
); );
} }