1#!/usr/local/bin/perl 2# move.cgi 3# Move a cron job up or down 4 5require './cron-lib.pl'; 6&error_setup($text{'move_err'}); 7&ReadParse(); 8 9@jobs = &list_cron_jobs(); 10$job = $jobs[$in{'idx'}]; 11if ($in{'up'}) { 12 $swap = $jobs[$in{'idx'}-1]; 13 } 14elsif ($in{'down'}) { 15 $swap = $jobs[$in{'idx'}+1]; 16 } 17elsif ($in{'top'}) { 18 for(my $i=$in{'idx'}; 19 $i && $jobs[$i]->{'file'} eq $job->{'file'}; $i--) { 20 $swap = $jobs[$i]; 21 } 22 } 23elsif ($in{'bottom'}) { 24 for(my $i=$in{'idx'}; 25 $i < @jobs && $jobs[$i]->{'file'} eq $job->{'file'}; $i++) { 26 $swap = $jobs[$i]; 27 } 28 } 29else { 30 &error("Unknown mode!"); 31 } 32$swap || &error("No job to swap with found"); 33$access{'move'} && &can_edit_user(\%access, $job->{'user'}) || 34 &error(&text('save_ecannot', $job->{'user'})); 35&can_edit_user(\%access, $swap->{'user'}) || 36 &error(&text('save_ecannot', $swap->{'user'})); 37$job->{'file'} eq $swap->{'file'} && 38 ($job->{'type'} == 0 || $job->{'type'} == 3) && 39 ($swap->{'type'} == 0 || $swap->{'type'} == 3) || &error($text{'move_etype'}); 40&lock_file($job->{'file'}); 41&swap_cron_jobs($job, $swap); 42&unlock_file($job->{'file'}); 43&webmin_log("move", "cron", $job->{'user'}); 44&redirect("index.cgi?search=".&urlize($in{'search'})); 45 46