Permalink
Browse files

1.02.

  • Loading branch information...
1 parent 30bf063 commit d10701554efcbf547ed5cf72817708ab8f6244ae Chia-liang Kao committed Feb 24, 2009
Showing with 158 additions and 4 deletions.
  1. +5 −0 Changes
  2. +2 −0 MANIFEST
  3. +2 −0 Makefile.PL
  4. +51 −0 README
  5. +87 −3 bin/rt-workflow
  6. +11 −1 lib/RTx/WorkflowBuilder.pm
View
@@ -0,0 +1,5 @@
+Revision history for RTx-WorkflowBuilder
+
+1.02 Tue Feb 24 16:06:37 CST 2009
+ Initial CPAN release.
+
View
@@ -9,7 +9,9 @@ inc/Module/Install/RTx.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
lib/RTx/WorkflowBuilder.pm
+Changes
Makefile.PL
MANIFEST This list of files
META.yml
+README
t/basic.t
View
@@ -8,4 +8,6 @@ author ('Chia-liang Kao <clkao@bestpractical.com>');
version_from ('lib/RTx//WorkflowBuilder.pm');
license ('GPL version 2');
+requires ('Class::Accessor::Fast');
+
&WriteAll;
View
51 README
@@ -0,0 +1,51 @@
+RTx::WorkflowBuilder is a tool for configuring approval workflow in RT.
+
+Best Practical sells support and customization for RT. Feel free to
+contact us at sales@bestpractical.com if you have any questions about
+our service offerings.
+
+
+Installation instructions:
+--------------------------
+
+1) Install RT 3.8.2 or newer.
+
+2) Once RT appears to be happily installed, cd into the directory
+ where you unpacked RTx::WorkflowBuilder.
+
+3) perl Makefile.PL
+
+4) make install
+
+Further reading:
+-----------------------------------------------------
+
+perldoc bin/rt-workflow - quick overview and configuration
+
+Development
+------------------------------------------------------
+
+If you would like to run RTx::WorkflowBuilder's tests, you need to
+set a few environment variables
+RT_DBA_USER - a user who can create a database on your
+ RDBMS (such as root on mysql)
+RT_DBA_PASSWORD - the password for RT_DBA_USER
+PERL5LIB - the path to your RT libraries (/opt/rt3/lib)
+
+RT_DBA_USER=user RT_DBA_PASSWORD=password PERL5LIB=/opt/rt3/lib make test
+
+These are intended to be run before installing RTx::WorkflowBuilder.
+Like RT, RTx::WorkflowBuilder expects to be able to create a new
+database called rt3test on your system.
+
+Bug reporting and discussion lists:
+-----------------------------------------------------
+
+You probably want to discuss RTx::WorkflowBuilder on
+rt-users@lists.bestpractical.com. (Send mail to
+rt-users-request@lists.fsck.com to subscribe)
+
+Bug reports can be sent to bugs-rtx-workflowbuilder@bestpractical.com.
+You can look at open bug reports at
+https://rt.cpan.org/Public/Dist/Display.html?Name=RTx-WorkflowBuilder.
+Log in as guest/guest to see the content of bug reports.
View
@@ -1,13 +1,97 @@
-#!/usr/bin/perl -w
+#!perl -w
use strict;
use warnings;
use Getopt::Long;
use RTx::WorkflowBuilder;
-my ($queue, $wf_name) = @ARGV;
+=head1 NAME
+
+rt-workflow - helper for configuring approval workflow in RT
+
+=head1 SYNOPSIS
+
+In your RT_SiteConfig.pm:
+
+ Set( $WorkflowBuilderStages,
+ { 'Manager approval' =>
+ { content => '.....',
+ subject => 'Manager Approval for PO: {$Approving->Id} - {$Approving->Subject}',
+
+ owner => q!{{
+ Fire => "moss",
+ IT => "roy",
+ Marketing => "jen"}->{ $Approving->FirstCustomFieldValue('Department') }}! },
+ 'Finance approval' =>
+ { content => '... ',
+ owner => 'CFO',
+ },
+ 'CEO approval' =>
+ { content => '..........',
+ owner => 'CEO',
+ }});
+
+ Set( $WorkflowBuilderRules,
+ { 'PO-Approval' => [ 'Manager approval' => 'Finance approval' => 'CEO approval'],
+ 'Vacation-Approval' => [ 'Manager approval' => 'CEO approval']
+ }
+);
+
+# to enable the workflow rules described in "PO-Approval" for the PO queue:
+% bin/rt-workflow PO PO-Approval --create
+
+# to update the workflow associated with the PO queue once you changed
+# the configuration
+% bin/rt-workflow PO PO-Approval
+
+=head1 DESCRIPTION
+
+This module allows you to define approval stages and approval rules in
+your F<RT_SiteConfig.pm> and builds the appropriate scrips for you.
+
+=over
+
+=item $WorkflowBuilderStages
+
+The config value should be a hashref, with keys being the name of the
+approval stage, and values being a hashref of the approval
+specification, which can include the usual fields for ticket such as
+owner, subject. note that the values can be interpolated just like
+normal RT Template (escaped with C<{}>), and you can access the ticket to
+be approved with the variable C<$Approving>.
+
+=item $WorkflowBuilderRules
+
+The config value should be a hashref, with keys being the name of the
+approval rule, and the values being arrayref denoting the stages of
+the approval in the suitable order.
+
+A stage with parallel approvals where any of them can move the
+approval workflow to next stage, can be represented as another
+arrayref in the approval chain. For example:
+
+ ['Manager approval' => 'Financial approval' => 'CEO approval']
+
+implies a monotonous approval chain that goes from manager to
+financial, and finally to CEO.
+
+ ['Manager approval' => ['HR', 'VP'] => 'CEO approval']
+
+implies after manager approval, either one of HR or VP approval will
+make it go to CEO approval.
+
+=back
+
+=cut
my %opts;
-GetOptions( \%opts, "create" );
+GetOptions( \%opts, "create", "help" );
+
+if ($opts{help}) {
+ system("perldoc", $0);
+ exit;
+}
+
+my ($queue, $wf_name) = @ARGV or die "Usage: $0 queue workflowname\n";
use RT::Interface::CLI qw(CleanEnv
GetCurrentUser GetMessageContent);
View
@@ -4,7 +4,17 @@ use strict;
use warnings;
__PACKAGE__->mk_accessors(qw(stages rule));
-our $VERSION = '1.01';
+our $VERSION = '1.02';
+
+=head1 NAME
+
+RTx::WorkflowBuilder - helper for configuring approval workflow in RT
+
+=head1 SYNOPSIS
+
+# see rt-workflow
+
+=cut
sub get_stage_object {
my ($self, $stage, $previous, $approving) = @_;

0 comments on commit d107015

Please sign in to comment.