- fix: deleting workflows did not delete related instances and crons

- Added a "run" link to the scheduler and the running workflows listings to
   aid in debugging workflow errors.
 - fix: profile fields not validated by WebGUI::User
This commit is contained in:
JT Smith 2006-09-15 06:08:30 +00:00
parent 7852441151
commit 90cb569bb5
9 changed files with 102 additions and 8 deletions

View file

@ -3,6 +3,11 @@
Approval for Version Tag workflow activity.
- Updated the hoverhelp to denote that you can use ranges in the WebGUI
scheduler.
- fix: deleting workflows did not delete related instances and crons
- Added a "run" link to the scheduler and the running workflows listings to
aid in debugging workflow errors.
- fix: profile fields not validated by WebGUI::User
7.0.7
- rfe: Image Management (funded by Formation Design Systems)

View file

@ -52,6 +52,7 @@ The unique id of an ad space to attach this ad to.
=head3 properties
The properties used to create this object. See the set() method for details.
A hash must be passed into create and a "type" key of either "text", "rich" or "image" is mandatory.
=cut
@ -209,7 +210,7 @@ The hex color to be used to display the border on a text based ad.
=head4 textColor
THe hex color to be used to display the text on a test based ad.
The hex color to be used to display the text on a test based ad.
=head4 backgroundColor

View file

@ -233,7 +233,9 @@ sub www_manageCron {
.$session->icon->edit("op=editCronJob;id=".$id)
.'</td><td>'.$title.'</td><td>'.$schedule.'</td><td>'
.($enabled ? $i18n->get("enabled") : $i18n->get("disabled"))
."</td></tr>\n";
."</td>";
$output .= '<td><a href="'.$session->url->page("op=runCronJob;taskId=".$id).'">'.$i18n->get("run","Workflow").'</a></td>';
$output .= "</tr>\n";
}
$output .= '</table>';
my $ac = WebGUI::AdminConsole->new($session,"cron");
@ -254,7 +256,7 @@ sub www_runCronJob {
my $session = shift;
$session->http->setMimeType("text/plain");
$session->http->setCacheControl("none");
unless (isInSubnet($session->env->get("REMOTE_ADDR"), $session->config->get("spectreSubnets"))) {
unless (isInSubnet($session->env->get("REMOTE_ADDR"), $session->config->get("spectreSubnets")) || $session->user->isInGroup("3")) {
$session->errorHandler->security("make a Spectre cron job runner request, but we're only allowed to accept requests from ".join(",",@{$session->config->get("spectreSubnets")}).".");
return "error";
}

View file

@ -370,7 +370,7 @@ sub www_runWorkflow {
my $session = shift;
$session->http->setMimeType("text/plain");
$session->http->setCacheControl("none");
unless (isInSubnet($session->env->get("REMOTE_ADDR"), $session->config->get("spectreSubnets"))) {
unless (isInSubnet($session->env->get("REMOTE_ADDR"), $session->config->get("spectreSubnets")) || $session->user->isInGroup("3")) {
$session->errorHandler->security("make a Spectre workflow runner request, but we're only allowed to accept requests from ".join(",",@{$session->config->get("spectreSubnets")}).".");
return "error";
}
@ -407,9 +407,10 @@ sub www_showRunningWorkflows {
.disabled { color: #808000; }
.done { color: #008000; }
.undefined { color: #800000; }
</style><table width="100%">';
my $rs = $session->db->read("select Workflow.title, WorkflowInstance.lastStatus, WorkflowInstance.runningSince, WorkflowInstance.lastUpdate from WorkflowInstance left join Workflow on WorkflowInstance.workflowId=Workflow.workflowId order by WorkflowInstance.runningSince desc");
while (my ($title, $status, $runningSince, $lastUpdate) = $rs->array) {
</style><table style="width: 100%;">';
my $isAdmin = $session->user->isInGroup("3");
my $rs = $session->db->read("select Workflow.title, WorkflowInstance.lastStatus, WorkflowInstance.runningSince, WorkflowInstance.lastUpdate, WorkflowInstance.instanceId from WorkflowInstance left join Workflow on WorkflowInstance.workflowId=Workflow.workflowId order by WorkflowInstance.runningSince desc");
while (my ($title, $status, $runningSince, $lastUpdate, $id) = $rs->array) {
my $class = $status || "complete";
$output .= '<tr class="'.$class.'">'
.'<td>'.$title.'</td>'
@ -419,6 +420,7 @@ sub www_showRunningWorkflows {
.$status.' / '.$session->datetime->epochToHuman($lastUpdate)
.'</td>';
}
$output .= '<td><a href="'.$session->url->page("op=runWorkflow;instanceId=".$id).'">'.$i18n->get("run").'</a></td>' if ($isAdmin);
$output .= "</tr>\n";
}
$output .= '</table>';

View file

@ -44,7 +44,7 @@ This package provides URL writing functionality. It is important that all WebGUI
$string = $url->getSiteURL;
$string = $url->makeCompliant($string);
$string = $url->makeAbsolute($string);
$string = $url->page($string, $pairs);
$string = $url->page($pairs);
$string = $url->unescape($string);
$string = $url->urlize($string);

View file

@ -439,6 +439,7 @@ sub profileField {
$self = shift;
$fieldName = shift;
$value = shift;
die "No such profile field: $fieldName" unless $self->session->db->quickArray("SELECT COUNT(*) FROM userProfileField WHERE fieldName = ?", [$fieldName]);
if (defined $value) {
$self->uncache;
$self->{_profile}{$fieldName} = $value;

View file

@ -228,6 +228,37 @@ sub getActivities {
return \@activities;
}
=head2 getInstances ( )
Returns an array reference of the instance objects currently existing for this workflow.
=cut
sub getInstances {
my $self = shift;
my @instances = ();
my $rs = $self->session->db->read("SELECT instanceId FROM WorkflowInstance WHERE workflowId = ?", [$self->getId]);
while (my ($instanceId) = $rs->array) {
push(@instances, WebGUI::Workflow::Instance->new($self->session, $instanceId));
}
return \@instances;
}
=head2 getCrons ( )
Returns an array reference of the cron objects that trigger this workflow.
=cut
sub getCrons {
my $self = shift;
my @crons = ();
my $rs = $self->session->db->read("SELECT taskId FROM WorkflowSchedule WHERE workflowId = ?", [$self->getId]);
while (my ($taskId) = $rs->array) {
push(@crons, WebGUI::Workflow::Cron->new($self->session, $taskId));
}
return \@crons;
}
#-------------------------------------------------------------------

View file

@ -1,6 +1,12 @@
package WebGUI::i18n::English::Workflow;
our $I18N = {
'run' => {
message => q|Run|,
context => q|Execute a workflow.|,
lastUpdated => 0,
},
'show running workflows' => {
message => q|Show running workflows.|,
context => q|A label used to get to a display of running workflows.|,

46
t/AdSpace/Ad.t Normal file
View file

@ -0,0 +1,46 @@
#-------------------------------------------------------------------
# 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 FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::AdSpace;
#use Test::More tests => 3;
use Test::More;
my $numTests = 1; # increment this value for each test you create
++$numTests; ##For conditional testing on module load
plan tests => $numTests;
my $loaded = use_ok('WebGUI::AdSpace::Ad');
my $session = WebGUI::Test->session;
my $ad;
my $adSpace;
SKIP: {
skip "Unable to load WebGUI::AdSpace::Ad", $numTests-1 unless $loaded;
$adSpace = WebGUI::AdSpace->create($session, {name=>"Alfred"});
$ad=WebGUI::AdSpace::Ad->create($session, $adSpace->getId, {"type", "text"});
isa_ok($ad,"WebGUI::AdSpace::Ad","testing create with no properties");
}
END {
if (defined $ad and ref $ad eq 'WebGUI::AdSpace::Ad') {
$ad->delete;
}
if (defined $adSpace and ref $adSpace eq 'WebGUI::AdSpace') {
$adSpace->delete;
}
}