diff --git a/cron/CHANGELOG b/cron/CHANGELOG
index 74ead3162..840b1c70a 100644
--- a/cron/CHANGELOG
+++ b/cron/CHANGELOG
@@ -39,3 +39,5 @@ Converted commands in the module's API file to POD format, and added more detail
Added a Module Config option to add new cron jobs to a specific file, like /etc/cron.d/webmin, instead of users' personal crontab files.
---- Changes since 1.670 ----
Fixed a security hole what could be exploited by passing in an invalid username.
+---- Changes since 1.690 ----
+Added buttons to move cron jobs to the top and bottom of the list.
diff --git a/cron/images/bottom.gif b/cron/images/bottom.gif
new file mode 100644
index 000000000..f4c0eb151
Binary files /dev/null and b/cron/images/bottom.gif differ
diff --git a/cron/images/top.gif b/cron/images/top.gif
new file mode 100644
index 000000000..5c1010e84
Binary files /dev/null and b/cron/images/top.gif differ
diff --git a/cron/index.cgi b/cron/index.cgi
index fe5c5e4b4..d4feeb6e5 100755
--- a/cron/index.cgi
+++ b/cron/index.cgi
@@ -180,13 +180,25 @@ foreach $u (@ulist) {
local $prv = $i > 0 ? $plist[$i-1]->[0] : undef;
local $nxt = $i != $#plist ? $plist[$i+1]->[0] : undef;
if ($access{'move'}) {
+ local $canup = $prv &&
+ $prv->{'file'} eq $job->{'file'} &&
+ ($job->{'type'} == 0 || $job->{'type'} == 3);
+ local $candown = $nxt &&
+ $nxt->{'file'} eq $job->{'file'} &&
+ ($job->{'type'} == 0 || $job->{'type'} == 3);
+ local $mover = "move.cgi?search=".
+ &urlize($in{'search'})."&idx=$idx";
push(@cols, &ui_up_down_arrows(
- "move.cgi?idx=$idx&up=1",
- "move.cgi?idx=$idx&down=1",
- $prv && $prv->{'file'} eq $job->{'file'} &&
- ($job->{'type'} == 0 || $job->{'type'} == 3),
- $nxt && $nxt->{'file'} eq $job->{'file'} &&
- ($job->{'type'} == 0 || $job->{'type'} == 3)
+ "$mover&up=1",
+ "$mover&down=1",
+ $canup, $candown,
+ ));
+ push(@cols, &ui_up_down_arrows(
+ "$mover&top=1",
+ "$mover&bottom=1",
+ $canup, $candown,
+ "images/top.gif",
+ "images/bottom.gif",
));
}
@@ -235,7 +247,7 @@ elsif (@rows) {
$config{'show_comment'} || $userconfig{'show_comment'} ?
( $text{'index_comment'} ) : ( ),
$config{'show_run'} ? ( $text{'index_run'} ) : ( ),
- $access{'move'} ? ( $text{'index_move'} ) : ( ),
+ $access{'move'} ? ( $text{'index_move'}, "" ) : ( ),
], 100, 0, \@tds);
foreach my $r (@rows) {
print &ui_checked_columns_row([ @$r[1..(@$r-2)] ],
diff --git a/cron/move.cgi b/cron/move.cgi
index 2f8ce652d..a4305dc76 100755
--- a/cron/move.cgi
+++ b/cron/move.cgi
@@ -11,9 +11,25 @@ $job = $jobs[$in{'idx'}];
if ($in{'up'}) {
$swap = $jobs[$in{'idx'}-1];
}
-else {
+elsif ($in{'down'}) {
$swap = $jobs[$in{'idx'}+1];
}
+elsif ($in{'top'}) {
+ for(my $i=$in{'idx'};
+ $i && $jobs[$i]->{'file'} eq $job->{'file'}; $i--) {
+ $swap = $jobs[$i];
+ }
+ }
+elsif ($in{'bottom'}) {
+ for(my $i=$in{'idx'};
+ $i < @jobs && $jobs[$i]->{'file'} eq $job->{'file'}; $i++) {
+ $swap = $jobs[$i];
+ }
+ }
+else {
+ &error("Unknown mode!");
+ }
+$swap || &error("No job to swap with found");
$access{'move'} && &can_edit_user(\%access, $job->{'user'}) ||
&error(&text('save_ecannot', $job->{'user'}));
&can_edit_user(\%access, $swap->{'user'}) ||
@@ -25,5 +41,5 @@ $job->{'file'} eq $swap->{'file'} &&
&swap_cron_jobs($job, $swap);
&unlock_file($job->{'file'});
&webmin_log("move", "cron", $job->{'user'});
-&redirect("");
+&redirect("index.cgi?search=".&urlize($in{'search'}));
diff --git a/ui-lib.pl b/ui-lib.pl
index 94bc6b7b4..46ae21a3a 100755
--- a/ui-lib.pl
+++ b/ui-lib.pl
@@ -2224,23 +2224,29 @@ Returns HTML for moving some objects in a table up or down. The parameters are :
=item down-show - Set to 1 if the down-arrow should be shown, 0 if not.
+=item up-icon - Optional path to icon for up link
+
+=item down-icon - Optional path to icon for down link
+
=cut
sub ui_up_down_arrows
{
return &theme_ui_up_down_arrows(@_) if (defined(&theme_ui_up_down_arrows));
-my ($uplink, $downlink, $upshow, $downshow) = @_;
+my ($uplink, $downlink, $upshow, $downshow, $upicon, $downicon) = @_;
my $mover;
my $imgdir = "$gconfig{'webprefix'}/images";
+$upicon ||= "$imgdir/moveup.gif";
+$downicon ||= "$imgdir/movedown.gif";
if ($downshow) {
- $mover .= "".
- "
";
+ $mover .= "".
+ "
";
}
else {
$mover .= "
";
}
if ($upshow) {
- $mover .= "".
- "
";
+ $mover .= "".
+ "
";
}
else {
$mover .= "
";