From bf07be52493e8d2d4dff7a7bb9a2020f03620b9a Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Mon, 27 Nov 2017 08:47:15 -0800 Subject: [PATCH] Use new UI library for acl editing --- custom/acl_security.pl | 55 ++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/custom/acl_security.pl b/custom/acl_security.pl index 9678bd518..93164d9dd 100755 --- a/custom/acl_security.pl +++ b/custom/acl_security.pl @@ -5,47 +5,38 @@ require 'custom-lib.pl'; # Output HTML for editing security options for the custom module sub acl_security_form { -local $mode = $_[0]->{'cmds'} eq '*' ? 1 : - $_[0]->{'cmds'} =~ /^\!/ ? 2 : 0; -print " $text{'acl_cmds'} \n"; -printf " %s\n", - $mode == 1 ? 'checked' : '', $text{'acl_call'}; -printf " %s\n", - $mode == 0 ? 'checked' : '', $text{'acl_csel'}; -printf " %s
\n", - $mode == 2 ? 'checked' : '', $text{'acl_cexcept'}; -print " \n"; +my ($o) = @_; +my $mode = $o->{'cmds'} eq '*' ? 1 : + $o->{'cmds'} =~ /^\!/ ? 2 : 0; +my @cmds = &sort_commands(&list_commands()); +print &ui_table_row($text{'acl_cmds'}, + &ui_radio("cmds_def", $mode, + [ [ 1, $text{'acl_call'} ], + [ 0, $text{'acl_csel'} ], + [ 2, $text{'acl_cexcept'} ] ])."
\n". + &ui_select("cmds", + [ split(/\s+/, $o->{'cmds'}) ], + [ map { [ $_->{'id'}, $_->{'desc'} ] } @cmds ], + 10, 1), 3); -print " $text{'acl_edit'} \n"; -printf " $text{'yes'}\n", - $_[0]->{'edit'} ? "checked" : ""; -printf " $text{'no'} \n", - $_[0]->{'edit'} ? "" : "checked"; +print &ui_table_row($text{'acl_edit'}, + &ui_yesno_radio("edit", $_[0]->{'edit'})); } -# acl_security_save(&options) +# acl_security_save(&options, &in) # Parse the form for security options for the custom module sub acl_security_save { -if ($in{'cmds_def'} == 1) { - $_[0]->{'cmds'} = "*"; +my ($o, $in) = @_; +if ($in->{'cmds_def'} == 1) { + $o->{'cmds'} = "*"; } -elsif ($in{'cmds_def'} == 0) { - $_[0]->{'cmds'} = join(" ", split(/\0/, $in{'cmds'})); +elsif ($in->{'cmds_def'} == 0) { + $o->{'cmds'} = join(" ", split(/\0/, $in->{'cmds'})); } else { - $_[0]->{'cmds'} = join(" ", "!", split(/\0/, $in{'cmds'})); + $o->{'cmds'} = join(" ", "!", split(/\0/, $in->{'cmds'})); } -$_[0]->{'edit'} = $in{'edit'}; +$o->{'edit'} = $in->{'edit'}; }