Added a parameter-level option to make the parameter mandatory.
---- Changes since 1.500 ----
Added a button to clone an existing command when editing.
+The sort order of commands can now be set on the Module Config page, and is respected in the Webmin Users module.
$mode == 0 ? 'checked' : '', $text{'acl_csel'};
printf "<input type=radio name=cmds_def value=2 %s> %s<br>\n",
$mode == 2 ? 'checked' : '', $text{'acl_cexcept'};
-print "<select name=cmds size=5 multiple width=200>\n";
-local @cmds = &list_commands();
+print "<select name=cmds size=10 multiple width=200>\n";
+local @cmds = &sort_commands(&list_commands());
local ($c, %ccan);
map { $ccan{$_}++ } split(/\s+/, $_[0]->{'cmds'});
foreach $c (@cmds) {
height=Height of file editor window,3,Default (20 chars)
wrap=File editor wrap mode,1,-Default (Soft),hard-Hard,off-Off
columns=Columns to display commands in,1,2-2,1-1
-line2=System configuration,11
+sort=Sort commands by,1,desc-Command name,html-Description,-Command ordering
return @rv;
}
+# sort_commands(&command, ...)
+# Sorts a list of custom commands by the user-defined order
+sub sort_commands
+{
+local @cust = @_;
+if ($config{'sort'}) {
+ @cust = sort { lc($a->{$config{'sort'}}) cmp
+ lc($b->{$config{'sort'}}) } @cust;
+ }
+else {
+ @cust = sort { local $o = $b->{'order'} <=> $a->{'order'};
+ $o ? $o : $a->{'id'} <=> $b->{'id'} } @cust;
+ }
+return @cust;
+}
+
# get_command(id)
# Returns the command with some ID
sub get_command
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1);
@cust = grep { &can_run_command($_) } &list_commands();
-@cust = sort { local $o = $b->{'order'} <=> $a->{'order'};
- $o ? $o : $a->{'id'} <=> $b->{'id'} } @cust;
+@cust = &sort_commands(@cust);
# Build links
@links = ( );