mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
[ticket/14315] Correctly set default values and reset values
The permissions tooltip javascript failed at correctly passing the default values to the page. The same applied to the display_mask() method in includes/acp/auth.php. PHPBB3-14315
This commit is contained in:
parent
4973632288
commit
eab1b1ad11
3 changed files with 20 additions and 22 deletions
|
@ -52,7 +52,7 @@
|
|||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<input type="hidden" name="role[{p_mask.f_mask.UG_ID}][{p_mask.f_mask.FORUM_ID}]"{% if S_ROLE_ID %}value="{{ S_ROLE_ID }}"{% endif %} />
|
||||
<input type="hidden" name="role[{p_mask.f_mask.UG_ID}][{p_mask.f_mask.FORUM_ID}]"{% if p_mask.f_mask.S_ROLE_ID %}value="{{ p_mask.f_mask.S_ROLE_ID }}"{% endif %} />
|
||||
</div>
|
||||
</dd>
|
||||
{% else %}
|
||||
|
|
|
@ -141,20 +141,32 @@ phpbb.positionTooltip = function ($element) {
|
|||
*/
|
||||
phpbb.prepareRolesDropdown = function () {
|
||||
var $options = $('.roles-options li');
|
||||
var $rolesOptions = $options.closest('.roles-options');
|
||||
var $span = $rolesOptions.children('span');
|
||||
|
||||
// Prepare highlighting of select options and settings update
|
||||
$options.each(function () {
|
||||
var $this = $(this);
|
||||
var $rolesOptions = $this.closest('.roles-options');
|
||||
var $span = $rolesOptions.children('span');
|
||||
|
||||
// Correctly show selected option
|
||||
if (typeof $this.attr('data-selected') !== 'undefined') {
|
||||
$rolesOptions.closest('.roles-options')
|
||||
$rolesOptions
|
||||
.children('span')
|
||||
.text($this.text())
|
||||
.attr('data-default', $this.text())
|
||||
.attr('data-default-val', $this.attr('data-id'));
|
||||
|
||||
// Save default text of drop down if there is no default set yet
|
||||
if (typeof $span.attr('data-default') === 'undefined') {
|
||||
$span.attr('data-default', $span.text());
|
||||
}
|
||||
|
||||
// Prepare resetting drop down on form reset
|
||||
$this.closest('form').on('reset', function () {
|
||||
$span.text($span.attr('data-default'));
|
||||
$rolesOptions.children('input[type=hidden]')
|
||||
.val($span.attr('data-default-val'));
|
||||
});
|
||||
}
|
||||
|
||||
$this.on('mouseover', function () {
|
||||
|
@ -163,6 +175,7 @@ phpbb.prepareRolesDropdown = function () {
|
|||
$this.addClass('roles-highlight');
|
||||
}).on('click', function () {
|
||||
var $this = $(this);
|
||||
var $rolesOptions = $this.closest('.roles-options');
|
||||
|
||||
// Update settings
|
||||
set_role_settings($this.attr('data-id'), $this.attr('data-target-id'));
|
||||
|
@ -178,19 +191,6 @@ phpbb.prepareRolesDropdown = function () {
|
|||
$('body').trigger('click');
|
||||
});
|
||||
});
|
||||
|
||||
// Save default text of drop down if there is no default set yet
|
||||
if (typeof $span.attr('data-default') === 'undefined') {
|
||||
$span.attr('data-default', $span.text());
|
||||
}
|
||||
|
||||
// Prepare resetting drop down on form reset
|
||||
$options.closest('form').on('reset', function () {
|
||||
$span.text($span.attr('data-default'));
|
||||
$rolesOptions.children('input[type=hidden]')
|
||||
.val($span.attr('data-id'));
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Run onload functions for RolesDropdown and tooltips
|
||||
|
|
|
@ -466,9 +466,6 @@ class auth_admin extends \phpbb\auth\auth
|
|||
// Build role dropdown options
|
||||
$current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0;
|
||||
|
||||
// Output current role id to template
|
||||
$template->assign_var('S_ROLE_ID', $current_role_id);
|
||||
|
||||
@reset($roles);
|
||||
while (list($role_id, $role_row) = each($roles))
|
||||
{
|
||||
|
@ -506,8 +503,9 @@ class auth_admin extends \phpbb\auth\auth
|
|||
'NAME' => $ug_names_ary[$ug_id],
|
||||
'UG_ID' => $ug_id,
|
||||
'S_CUSTOM' => $s_custom_permissions,
|
||||
'FORUM_ID' => $forum_id)
|
||||
);
|
||||
'FORUM_ID' => $forum_id,
|
||||
'S_ROLE_ID' => $current_role_id,
|
||||
));
|
||||
|
||||
$this->assign_cat_array($ug_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, ($mode == 'view'), $show_trace);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue