mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Add buttons to move cron jobs to the top and bottom
This commit is contained in:
@@ -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.
|
||||
|
||||
BIN
cron/images/bottom.gif
Normal file
BIN
cron/images/bottom.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 82 B |
BIN
cron/images/top.gif
Normal file
BIN
cron/images/top.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 84 B |
@@ -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)] ],
|
||||
|
||||
@@ -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'}));
|
||||
|
||||
|
||||
16
ui-lib.pl
16
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 .= "<a class='ui_up_down_arrows_down' href=\"$downlink\">".
|
||||
"<img class='ui_up_down_arrows_down' src=$imgdir/movedown.gif border=0></a>";
|
||||
$mover .= "<a class='ui_up_down_arrows_down' href='$downlink'>".
|
||||
"<img class='ui_up_down_arrows_down' src='$downicon' border=0></a>";
|
||||
}
|
||||
else {
|
||||
$mover .= "<img class='ui_up_down_arrows_gap' src='$imgdir/movegap.gif'>";
|
||||
}
|
||||
if ($upshow) {
|
||||
$mover .= "<a class='ui_up_down_arrows_up' href=\"$uplink\">".
|
||||
"<img class='ui_up_down_arrows_up' src='$imgdir/moveup.gif' border=0></a>";
|
||||
$mover .= "<a class='ui_up_down_arrows_up' href='$uplink'>".
|
||||
"<img class='ui_up_down_arrows_up' src='$upicon' border=0></a>";
|
||||
}
|
||||
else {
|
||||
$mover .= "<img class='ui_up_down_arrows_gap' src='$imgdir/movegap.gif'>";
|
||||
|
||||
Reference in New Issue
Block a user