diff --git a/docs/upgrades/upgrade_6.8.5-6.9.0.pl b/docs/upgrades/upgrade_6.8.5-6.9.0.pl index ea68f897f..f6a51f144 100644 --- a/docs/upgrades/upgrade_6.8.5-6.9.0.pl +++ b/docs/upgrades/upgrade_6.8.5-6.9.0.pl @@ -42,6 +42,7 @@ sub addWorkflow { $session->config->set("spectreCryptoKey","123qwe"); $session->db->write("create table WorkflowSchedule ( taskId varchar(22) binary not null primary key, + title varchar(255) not null default 'Untitled', enabled int not null default 0, runOnce int not null default 0, minuteOfHour varchar(25) not null default '0', @@ -98,6 +99,7 @@ sub addWorkflow { $activity->set("title","Delete files older than 24 hours"); $activity->set("storageTimeout",60*60*24); my $cron = WebGUI::Workflow::Cron->create($session, { + title=>'Delete temp files', enabled=>1, runOnce=>0, minuteOfHour=>"30", diff --git a/lib/WebGUI/AdminConsole.pm b/lib/WebGUI/AdminConsole.pm index 36c675002..018531b5d 100644 --- a/lib/WebGUI/AdminConsole.pm +++ b/lib/WebGUI/AdminConsole.pm @@ -161,6 +161,15 @@ sub getAdminFunction { func=>"manageVersions", group=>"3" }, + "cron"=>{ + title=>{ + id=>"topicName", + namespace=>"Workflow_Cron" + }, + icon=>"cron.gif", + op=>"manageCron", + group=>"3" + }, "users"=>{ title=>{ id=>"149", diff --git a/lib/WebGUI/Form/Captcha.pm b/lib/WebGUI/Form/Captcha.pm index 9e8292523..a6b8444a6 100644 --- a/lib/WebGUI/Form/Captcha.pm +++ b/lib/WebGUI/Form/Captcha.pm @@ -60,7 +60,7 @@ sub definition { my $i18n = WebGUI::International->new($session,"Form_Captcha"); push(@{$definition}, { formName=>{ - defaultValue=>$i18n->get("formName") + defaultValue=>$i18n->get("topicName") }, profileEnabled=>{ defaultValue=>1 diff --git a/lib/WebGUI/Operation.pm b/lib/WebGUI/Operation.pm index 074255061..4a01450e6 100644 --- a/lib/WebGUI/Operation.pm +++ b/lib/WebGUI/Operation.pm @@ -77,6 +77,10 @@ Returns a hash reference containing operation and package names. sub getOperations { return { + 'manageCron' => 'WebGUI::Operation::Cron', + 'editCronJob' => 'WebGUI::Operation::Cron', + 'editCronJobSave' => 'WebGUI::Operation::Cron', + 'deleteCronJob' => 'WebGUI::Operation::Cron', 'spectre' => 'WebGUI::Operation::Spectre', 'adminConsole' => 'WebGUI::Operation::Admin', 'switchOffAdmin' => 'WebGUI::Operation::Admin', diff --git a/lib/WebGUI/Operation/Cron.pm b/lib/WebGUI/Operation/Cron.pm new file mode 100644 index 000000000..11d3a6d5e --- /dev/null +++ b/lib/WebGUI/Operation/Cron.pm @@ -0,0 +1,188 @@ +package WebGUI::Operation::Cron; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2006 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use Tie::IxHash; +use WebGUI::AdminConsole; +use WebGUI::HTMLForm; +use WebGUI::International; +use WebGUI::Workflow::Cron; + +=head1 NAME + +Package WebGUI::Operations::Cron + +=head1 DESCRIPTION + +Operation handler for managing scheduler activities. + +=cut + +#------------------------------------------------------------------- + +=head2 www_deleteCronJob ( ) + +Deletes a cron job. + +=cut + +sub www_deleteCronJob { + my $session = shift; + return $session->privilege->adminOnly() unless ($session->user->isInGroup(3)); + my $cron = WebGUI::Workflow::Cron->new($session, $session->form->get("id")); + $cron->delete if defined $cron; + return www_manageCron($session); +} + +#------------------------------------------------------------------- + +=head2 www_editCronJob ( ) + +Displays an edit form for a cron job. + +=cut + +sub www_editCronJob { + my $session = shift; + return $session->privilege->adminOnly() unless ($session->user->isInGroup(3)); + my $i18n = WebGUI::International->new($session, "Workflow_Cron"); + my $cron = WebGUI::Workflow::Cron->new($session, $session->form->get("id")); + my $f = WebGUI::HTMLForm->new($session); + $f->hidden( + name=>"op", + value=>"editCronJobSave" + ); + $f->hidden( + name=>"id", + value=>$session->form->get("id"), + defaultValue=>"new", + ); + $f->readOnly( + label=>$i18n->get("id"), + value=>$session->form->get("id"), + defaultValue=>"new" + ); + my $value = $cron->get("title") if defined $cron; + $f->text( + name=>"title", + value=>$value, + label=>$i18n->get("title"), + hoverHelp=>$i18n->get("title help") + ); + my $value = $cron->get("enabled") if defined $cron; + $f->yesNo( + name=>"enabled", + value=>$value, + defaultValue=>0, + label=>$i18n->get("enabled"), + hoverHelp=>$i18n->get("enabled help") + ); + my $value = $cron->get("runOnce") if defined $cron; + $f->yesNo( + name=>"runOnce", + value=>$value, + defaultValue=>0, + label=>$i18n->get("run once"), + hoverHelp=>$i18n->get("ron once help") + ); + my $value = $cron->get("workflowId") if defined $cron; + $f->workflow( + name=>"workflowId", + value=>$value, + label=>$i18n->get("workflow"), + hoverHelp=>$i18n->get("workflow help") + ); + my %priorities = (); + tie %priorities, 'Tie::IxHash'; + %priorities = (1=>$i18n->get("high"), 2=>$i18n->get("medium"), 3=>$i18n->get("low")); + my $value = $cron->get("priority") if defined $cron; + $f->radioList( + name=>"priority", + vertical=>1, + value=>$value, + defaultValue=>2, + options=>\%priorities, + label=>$i18n->get("priority"), + hoverHelp=>$i18n->get("priority help") + ); + my $value = $cron->get("minuteOfHour") if defined $cron; + $f->text( + name=>"minuteOfHour", + value=>$value, + defaultValue=>0, + label=>$i18n->get("minute of hour"), + hoverHelp=>$i18n->get("minute of hour help") + ); + my $value = $cron->get("hourOfDay") if defined $cron; + $f->text( + name=>"hourOfDay", + value=>$value, + defaultValue=>"*", + label=>$i18n->get("hour of day"), + hoverHelp=>$i18n->get("hour of day help") + ); + my $value = $cron->get("dayOfMonth") if defined $cron; + $f->text( + name=>"dayOfMonth", + value=>$value, + defaultValue=>"*", + label=>$i18n->get("day of month"), + hoverHelp=>$i18n->get("day of month help") + ); + my $value = $cron->get("monthOfYear") if defined $cron; + $f->text( + name=>"monthOfYear", + value=>$value, + defaultValue=>"*", + label=>$i18n->get("month of year"), + hoverHelp=>$i18n->get("month of year help") + ); + my $value = $cron->get("dayOfWeek") if defined $cron; + $f->text( + name=>"dayOfWeek", + value=>$value, + defaultValue=>"*", + label=>$i18n->get("day of week"), + hoverHelp=>$i18n->get("day of week help") + ); + $f->submit; + return WebGUI::AdminConsole->new($session,"cron")->render($f->print); +} + + +#------------------------------------------------------------------- + +=head2 www_manageCron ( ) + +Display a list of the scheduler activities. + +=cut + +sub www_manageCron { + my $session = shift; + return $session->privilege->adminOnly() unless ($session->user->isInGroup(3)); + my $i18n = WebGUI::International->new($session, "Workflow_Cron"); + my $output = '
| ' + .$session->icon->delete("op=deleteCronJob;id=".$id, undef, $i18n->get("are you sure you want to delete this scheduled task")) + .$session->icon->edit("op=editCronJob;id=".$id) + .' | '.$title.' | '.$schedule.' | ' + .($enabled ? "X" : "") + ." |