[Rt-commit] r5660 - in RT-Extension-QueueWizard: . html/Callbacks html/Callbacks/QueueWizard html/Callbacks/QueueWizard/Admin html/Callbacks/QueueWizard/Admin/Elements html/Callbacks/QueueWizard/Admin/Elements/QueueTabs html/QueueWizard html/QueueWizard/Admin html/QueueWizard/Admin/Elements inc inc/Module inc/Module/Install inc/Module/Install/RTx lib lib/RT lib/RT/Extension

kevinr at bestpractical.com kevinr at bestpractical.com
Thu Jul 27 01:37:05 EDT 2006


Author: kevinr
Date: Thu Jul 27 01:37:02 2006
New Revision: 5660

Added:
   RT-Extension-QueueWizard/MANIFEST
   RT-Extension-QueueWizard/META.yml
   RT-Extension-QueueWizard/Makefile.PL
   RT-Extension-QueueWizard/README
   RT-Extension-QueueWizard/html/
   RT-Extension-QueueWizard/html/Callbacks/
   RT-Extension-QueueWizard/html/Callbacks/QueueWizard/
   RT-Extension-QueueWizard/html/Callbacks/QueueWizard/Admin/
   RT-Extension-QueueWizard/html/Callbacks/QueueWizard/Admin/Elements/
   RT-Extension-QueueWizard/html/Callbacks/QueueWizard/Admin/Elements/QueueTabs/
   RT-Extension-QueueWizard/html/Callbacks/QueueWizard/Admin/Elements/QueueTabs/Default
   RT-Extension-QueueWizard/html/QueueWizard/
   RT-Extension-QueueWizard/html/QueueWizard/Admin/
   RT-Extension-QueueWizard/html/QueueWizard/Admin/Elements/
   RT-Extension-QueueWizard/html/QueueWizard/Admin/Elements/ProcmailRule
   RT-Extension-QueueWizard/html/QueueWizard/Admin/index.html
   RT-Extension-QueueWizard/inc/
   RT-Extension-QueueWizard/inc/Module/
   RT-Extension-QueueWizard/inc/Module/Install/
   RT-Extension-QueueWizard/inc/Module/Install.pm
   RT-Extension-QueueWizard/inc/Module/Install/Base.pm
   RT-Extension-QueueWizard/inc/Module/Install/Can.pm
   RT-Extension-QueueWizard/inc/Module/Install/Fetch.pm
   RT-Extension-QueueWizard/inc/Module/Install/Makefile.pm
   RT-Extension-QueueWizard/inc/Module/Install/Metadata.pm
   RT-Extension-QueueWizard/inc/Module/Install/RTx/
   RT-Extension-QueueWizard/inc/Module/Install/RTx.pm
   RT-Extension-QueueWizard/inc/Module/Install/RTx/Factory.pm
   RT-Extension-QueueWizard/inc/Module/Install/Win32.pm
   RT-Extension-QueueWizard/inc/Module/Install/WriteAll.pm
   RT-Extension-QueueWizard/includeall.rc
   RT-Extension-QueueWizard/lib/
   RT-Extension-QueueWizard/lib/RT/
   RT-Extension-QueueWizard/lib/RT/Extension/
   RT-Extension-QueueWizard/lib/RT/Extension/QueueWizard.pm
Modified:
   RT-Extension-QueueWizard/   (props changed)

Log:
 r15473 at SAD-GIRL-IN-SNOW:  kevinr | 2006-07-27 00:51:05 -0400
 


Added: RT-Extension-QueueWizard/MANIFEST
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/MANIFEST	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,19 @@
+html/Callbacks/QueueWizard/Admin/Elements/QueueTabs/Default
+html/QueueWizard/Admin/Elements/ProcmailRule
+html/QueueWizard/Admin/index.html
+inc/Module/Install.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/RTx.pm
+inc/Module/Install/RTx/Factory.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+includeall.rc
+lib/RT/Extension/QueueWizard.pm
+Makefile.PL
+MANIFEST			This list of files
+META.yml
+README

Added: RT-Extension-QueueWizard/META.yml
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/META.yml	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,12 @@
+name: RT-Extension-QueueWizard
+version: 0.1
+abstract: RT Extension-QueueWizard Extension
+author: Jesse Vincent <jesse at bestpractical.com>
+license: perl
+distribution_type: module
+no_index:
+  directory:
+    - etc
+    - html
+    - inc
+generated_by: Module::Install version 0.36

Added: RT-Extension-QueueWizard/Makefile.PL
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/Makefile.PL	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,6 @@
+use inc::Module::Install;
+
+RTx('RT-Extension-QueueWizard');
+license('perl');
+author('Jesse Vincent <jesse at bestpractical.com>');
+&WriteAll;

Added: RT-Extension-QueueWizard/README
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/README	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,32 @@
+QueueWizard allows for fast creation of queues by cloning a
+pre-existing queue, and all group rights associated with it, to a new
+queue.  Additionally, it automatically creates a new procmail file in
+$RT::ProcmailDir/auto with the rules needed to automatically start
+filtering into that queue.
+
+Queues use the value of the Organization configuration variable as
+the domain of their default comment and correspond e-mail addresses.
+The queue name is used as the user of the correspond address, and,
+with '.comment' appended, as the user of the comment address.
+
+The html/QueueWizard/Admin/Elements/ProcmailRule file controls the
+format of the procmail file generated by the QueueWizard.
+
+Individual procmail rules are written to the $RT::ProcmailDir/auto
+directory; they are included in one of two ways:
+
+1. If the $RT::ProcmailControlFile variable is set, it will have a
+   line appended to it for every procmail file written to the 'auto'
+   directory.
+
+2. If $RT::ProcmailControlFile is not set, it assumes you are using
+   the included includeall.rc file, which automatically includes all
+   procmail files in the 'auto' directory underneath it.  This option
+   requires procmail version 3.14 or higher.
+
+     The includeall.rc files does its magic by creating a LIST
+   variable that contains the output of 'ls' on the 'auto/' directory.
+   Then, it matches the fist line of the LIST varaible, includes that
+   file, and then re-runs includeall.rc using SWITCHRC -- which starts
+   on the second line of the output of ls.  In this way, each procmail
+   file in the 'auto/' directory is included.

Added: RT-Extension-QueueWizard/html/Callbacks/QueueWizard/Admin/Elements/QueueTabs/Default
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/html/Callbacks/QueueWizard/Admin/Elements/QueueTabs/Default	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,9 @@
+<%args>
+$tabs => undef
+</%args>
+<%init>
+
+$tabs->{'AA_QueueWizard'}  = { title => loc('New queue (quick)'),
+                            path => 'QueueWizard/Admin/index.html' };
+return;
+</%init>

Added: RT-Extension-QueueWizard/html/QueueWizard/Admin/Elements/ProcmailRule
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/html/QueueWizard/Admin/Elements/ProcmailRule	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,13 @@
+## Rules for '<% $name %>' queue
+:0
+* ^(From|To|Cc).*(<% join("|", $name, @aliases) %>)@
+| <% $RT::BinPath %>/rt-mailgate --queue <% $name %> --action correspond --url <% $RT::WebURL %>
+
+:0
+* ^(From|To|Cc).*(<% join("|", $name, @aliases) %>).comment@
+| <% $RT::BinPath %>/rt-mailgate --queue <% $name %> --action comment    --url <% $RT::WebURL %>
+
+<%args>
+$name
+ at aliases => ()
+</%args>
\ No newline at end of file

Added: RT-Extension-QueueWizard/html/QueueWizard/Admin/index.html
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/html/QueueWizard/Admin/index.html	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,285 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%# 
+%# COPYRIGHT:
+%#  
+%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC 
+%#                                          <jesse at bestpractical.com>
+%# 
+%# (Except where explicitly superseded by other copyright notices)
+%# 
+%# 
+%# LICENSE:
+%# 
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%# 
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%# 
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%# 
+%# 
+%# CONTRIBUTION SUBMISSION POLICY:
+%# 
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%# 
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%# 
+%# END BPS TAGGED BLOCK }}}
+<& /Admin/Elements/Header, Title => $title &>
+<& /Admin/Elements/QueueTabs, 
+    current_tab => $current_tab, 
+    Title => $title &>
+
+<& /Elements/ListActions, actions => \@errors &>
+
+% if ($queue->id) {
+
+Your new queue <%$queue->Name%> has been created.  To manage your new
+queue <a
+href="<%$RT::WebPath%>/Admin/Queues/Modify.html?id=<%$queue->id%>">click
+here.</a>
+
+% } else {
+<form ACTION="<%$RT::WebPath%>/QueueWizard/Admin/index.html" METHOD="post">
+
+This webform automatically sets up queue watchers and default scrips
+based on settings from another queue. All you need to do is enter the
+name for the new queue and email addresses for queue administrators
+and staff, and the que to pull default scrips and permissions from.
+All users need to have accounts in RT already.
+
+<br />
+<hr />
+<label name="Name"><&|/l&>Queue name</&></label><br/>
+<input type="text" name="Name" size="20" value="<%$ARGS{'Name'}%>" />
+<br />
+<br />
+<label name="Name"><&|/l&>Comma-separated list of aliases</&></label><br/>
+<input type="text" name="Aliases" size="20" value="<%$ARGS{'Aliases'}%>" />
+<br />
+<br />
+<label name="Clone"><&|/l&>Clone from</&></label><br />
+<& /Elements/SelectQueue, Name => "Clone", ShowNullOption => 0 &>
+<br />
+<br />
+<label name="Admin"><&|/l&>Queue Administrators</&></label><br />
+<i>(<&|/l&>Enter user email addresses, one per line</&>)</i><br />
+<textarea name="Admin" rows=10><%$ARGS{'Admin'}%></textarea>
+
+<br />
+<label name="Staff"><&|/l&>Queue Staff</&></label><br />
+<i>(<&|/l&>Enter user email addresses, one per line</&>)</i><br />
+<textarea name="Staff" rows=10><%$ARGS{'Staff'}%></textarea>
+
+
+<& /Elements/Submit &>
+
+% }
+</form>
+<%INIT>
+my @errors;
+
+my $current_tab = 'QueueWizard/Admin/index.html';
+my $title       = loc("Create a queue");
+
+my $queue = RT::Queue->new( $session{'CurrentUser'} );
+
+my %valid;
+
+
+# If we're asked to create a queue.
+if ($ARGS{'Name'} ) {
+
+# Validate all the staff and admin users for the queue
+foreach my $type qw(Staff Admin) {
+    @{ $valid{$type} } = ();
+    my @list = split( /[\n\r]+/, $ARGS{$type} );
+
+    foreach my $user (@list) {
+        next unless $user;
+        my $u = RT::User->new( $session{'CurrentUser'} );
+        $u->LoadByCols(EmailAddress => $user);
+        if ( !$u->id ) {
+            $u->Load($user);
+        }
+        if ( !$u->id ) {
+            push @errors, loc( "[_1] user '[_2]' not found.", $type, $user );
+        }
+        else {
+            push @{ $valid{$type} }, $u;
+        }
+    }
+
+}
+
+# Make sure we have a valid queue
+my $clone_queue = RT::Queue->new( $session{'CurrentUser'} );
+$clone_queue->Load($ARGS{Clone});
+if ( !$clone_queue->id ) {
+    push @errors, loc("Queue [_1] not found", $ARGS{Clone});
+}
+
+# Make sure there's a staff group to go for that queue
+my $clone_staff = RT::Group->new( $session{'CurrentUser'} );
+$clone_staff->LoadUserDefinedGroup($clone_queue->Name . "_support");
+if ( !$clone_staff->id ) {
+    push @errors, loc("Staff group [_1] for queue [_2] not found", $clone_queue->Name . "_support", $clone_queue->Name);
+}
+
+# Ditto for the admin group
+my $clone_admin = RT::Group->new( $session{'CurrentUser'} );
+$clone_admin->LoadUserDefinedGroup($clone_queue->Name . "_owners");
+if ( !$clone_admin->id ) {
+    push @errors, loc("Owner group [_1] for queue [_2] not found", $clone_queue->Name . "_owners", $clone_queue->Name);
+}
+
+if ( !@errors ) {
+
+    my %queue_defaults;
+    # Find properties of queue to clone from
+    for ($clone_queue->WritableAttributes) {
+        $queue_defaults{$_} = $clone_queue->$_();
+    }
+
+    my $staff_group = RT::Group->new( $session{'CurrentUser'} );
+    my $admin_group = RT::Group->new( $session{'CurrentUser'} );
+
+    # Find rights from clone queue's groups
+    my @Rights;
+    my %seen;
+    # Clone rights that involve the staff and admin groups, or the queue.
+    for my $obj ($clone_staff, $clone_admin, $clone_queue) {
+        # We care about both rights *on* that object, and *by* it (if possible).
+        for my $side (qw/on by/ ) {
+            my $acl = RT::ACL->new( $session{'CurrentUser'} );
+            if ($side eq "by") {
+                $acl->LimitToObject( $obj );
+            } elsif (UNIVERSAL::can($obj, "PrincipalObj")) {
+                $acl->LimitToPrincipal( Id => $obj->PrincipalObj->Id );
+            } else {
+                next;
+            }
+            while (my $ace = $acl->Next) {
+                my $by = $ace->PrincipalObj->Object;
+                my $on = $ace->Object;
+
+                # Skip user rights
+                next if $by->Type eq "UserEquiv" or UNIVERSAL::isa($on, "RT::User");
+                
+                # Do translation of clones values to new values
+                $by = $queue       if UNIVERSAL::isa($by, ref $clone_queue) and $by->Id == $clone_queue->Id;
+                $by = $staff_group if UNIVERSAL::isa($by, ref $clone_staff) and $by->Id == $clone_staff->Id;
+                $by = $admin_group if UNIVERSAL::isa($by, ref $clone_admin) and $by->Id == $clone_admin->Id;
+                
+                $on = $queue       if UNIVERSAL::isa($on, ref $clone_queue) and $on->Id == $clone_queue->Id;
+                $on = $staff_group if UNIVERSAL::isa($on, ref $clone_staff) and $on->Id == $clone_staff->Id;
+                $on = $admin_group if UNIVERSAL::isa($on, ref $clone_admin) and $on->Id == $clone_admin->Id;
+
+                # Watch out for duplicate values; hence the %seen
+                push @Rights, {
+                               By            => $by,
+                               RightName     => $ace->RightName,
+                               Object        => $on,
+                              }
+                  unless $seen{"$by-".$ace->RightName."-$on"};
+                $seen{"$by-".$ace->RightName."-$on"}++;
+            }
+        }
+    }
+    
+    # Create the queue
+    my ($id,$msg) = $queue->Create(
+        %queue_defaults,
+        Name              => $ARGS{'Name'},
+        Description       => $ARGS{'Name'},
+        CorrespondAddress => $ARGS{'Name'} . '@' . $RT::Organization,
+        CommentAddress => $ARGS{'Name'} . '.comment@' . $RT::Organization,
+    );
+
+    if (!$id) {
+        push @errors, $msg;
+    } else {
+        # Create the queue groups
+        $staff_group->CreateUserDefinedGroup( Name => $ARGS{'Name'} . "_support" );
+        foreach my $user ( @{ $valid{'Staff'} } ) {
+            $staff_group->AddMember( $user->id );
+        }
+        $queue->AddWatcher(
+                           Type        => 'AdminCc',
+                           PrincipalId => $staff_group->id
+                          );
+
+        $admin_group->CreateUserDefinedGroup( Name => $ARGS{'Name'} . "_owners" );
+        foreach my $user ( @{ $valid{'Admin'} } ) {
+            $admin_group->AddMember( $user->id );
+        }
+
+        # Set up rights for the groups, discovered above
+        foreach my $args (@Rights) {
+            my $right = RT::ACE->new( $session{'CurrentUser'} );
+            my %args = %{$args};
+            $args{PrincipalId}   = $args{By}->PrincipalObj->Id;
+            $args{PrincipalType} = $args{By}->PrincipalObj->PrincipalType;
+            ($id, $msg) = $right->Create(%args);
+            push @errors, $msg unless $id;
+        }
+
+        # Clone scrips
+        my $clone_scrips = RT::Scrips->new( $session{'CurrentUser'} );
+        $clone_scrips->LimitToQueue($clone_queue->Id);
+        while (my $clone_scrip = $clone_scrips->Next) {
+            my %scrip_defaults;
+            for ($clone_scrip->WritableAttributes) {
+                $scrip_defaults{$_} = $clone_scrip->$_();
+            }
+            my $scrip = RT::Scrip->new($session{'CurrentUser'});
+            $scrip_defaults{'Queue'} = $queue->id;
+            ($id, $msg) = $scrip->Create(%scrip_defaults);
+            push @errors, $msg unless $id;
+        }
+
+        # Add procmail aliases
+        my $file = "$RT::ProcmailDir/auto/rt-queue-".$queue->Id;
+        unless (open(FILTERS, ">$file")) {
+            push @errors, loc("Can't add alias to procmail file [_1]: [_2]", $file, $!);
+        } else {
+            my $name = $queue->Name;
+            print FILTERS $m->scomp("Elements/ProcmailRule",
+                                    name => $queue->Name,
+                                    aliases => [split /\s*,\s*/, $ARGS{'Aliases'}],
+                                   );
+            close FILTERS;
+
+            if (defined $RT::ProcmailControlFile) {
+              unless (open(LISTING, ">>$RT::ProcmailControlFile")) {
+                push @errors, loc("Can't add alias to procmail control file [_1]: [_2]",
+                                  $RT::ProcmailControlFile, $!);
+              } else {
+                print LISTING "INCLUDERC = $file\n";
+                close LISTING;
+              }
+            }
+        }
+    }
+
+}
+}
+</%INIT>

Added: RT-Extension-QueueWizard/inc/Module/Install.pm
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/inc/Module/Install.pm	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,169 @@
+#line 1 "inc/Module/Install.pm - /usr/local/share/perl/5.8.4/Module/Install.pm"
+package Module::Install;
+$VERSION = '0.36';
+
+die << "." unless $INC{join('/', inc => split(/::/, __PACKAGE__)).'.pm'};
+Please invoke ${\__PACKAGE__} with:
+
+    use inc::${\__PACKAGE__};
+
+not:
+
+    use ${\__PACKAGE__};
+
+.
+
+use strict 'vars';
+use Cwd ();
+use File::Find ();
+use File::Path ();
+
+ at inc::Module::Install::ISA = 'Module::Install';
+*inc::Module::Install::VERSION = *VERSION;
+
+#line 129
+
+sub import {
+    my $class = shift;
+    my $self = $class->new(@_);
+
+    if (not -f $self->{file}) {
+        require "$self->{path}/$self->{dispatch}.pm";
+        File::Path::mkpath("$self->{prefix}/$self->{author}");
+        $self->{admin} = 
+          "$self->{name}::$self->{dispatch}"->new(_top => $self);
+        $self->{admin}->init;
+        @_ = ($class, _self => $self);
+        goto &{"$self->{name}::import"};
+    }
+
+    *{caller(0) . "::AUTOLOAD"} = $self->autoload;
+
+    # Unregister loader and worker packages so subdirs can use them again
+    delete $INC{"$self->{file}"};
+    delete $INC{"$self->{path}.pm"};
+}
+
+#line 156
+
+sub autoload {
+    my $self = shift;
+    my $caller = caller;
+
+    my $cwd = Cwd::cwd();
+    my $sym = "$caller\::AUTOLOAD";
+
+    $sym->{$cwd} = sub {
+        my $pwd = Cwd::cwd();
+        if (my $code = $sym->{$pwd}) {
+            goto &$code unless $cwd eq $pwd; # delegate back to parent dirs
+        }
+        $$sym =~ /([^:]+)$/ or die "Cannot autoload $caller";
+        unshift @_, ($self, $1);
+        goto &{$self->can('call')} unless uc($1) eq $1;
+    };
+}
+
+#line 181
+
+sub new {
+    my ($class, %args) = @_;
+
+    return $args{_self} if $args{_self};
+
+    $args{dispatch} ||= 'Admin';
+    $args{prefix}   ||= 'inc';
+    $args{author}   ||= '.author';
+    $args{bundle}   ||= 'inc/BUNDLES';
+
+    $class =~ s/^\Q$args{prefix}\E:://;
+    $args{name}     ||= $class;
+    $args{version}  ||= $class->VERSION;
+
+    unless ($args{path}) {
+        $args{path}  = $args{name};
+        $args{path}  =~ s!::!/!g;
+    }
+    $args{file}     ||= "$args{prefix}/$args{path}.pm";
+
+    bless(\%args, $class);
+}
+
+#line 210
+
+sub call {
+    my $self   = shift;
+    my $method = shift;
+    my $obj = $self->load($method) or return;
+
+    unshift @_, $obj;
+    goto &{$obj->can($method)};
+}
+
+#line 225
+
+sub load {
+    my ($self, $method) = @_;
+
+    $self->load_extensions(
+        "$self->{prefix}/$self->{path}", $self
+    ) unless $self->{extensions};
+
+    foreach my $obj (@{$self->{extensions}}) {
+        return $obj if $obj->can($method);
+    }
+
+    my $admin = $self->{admin} or die << "END";
+The '$method' method does not exist in the '$self->{prefix}' path!
+Please remove the '$self->{prefix}' directory and run $0 again to load it.
+END
+
+    my $obj = $admin->load($method, 1);
+    push @{$self->{extensions}}, $obj;
+
+    $obj;
+}
+
+#line 255
+
+sub load_extensions {
+    my ($self, $path, $top_obj) = @_;
+
+    unshift @INC, $self->{prefix}
+        unless grep { $_ eq $self->{prefix} } @INC;
+
+    local @INC = ($path, @INC);
+    foreach my $rv ($self->find_extensions($path)) {
+        my ($file, $pkg) = @{$rv};
+        next if $self->{pathnames}{$pkg};
+
+        eval { require $file; 1 } or (warn($@), next);
+        $self->{pathnames}{$pkg} = delete $INC{$file};
+        push @{$self->{extensions}}, $pkg->new( _top => $top_obj );
+    }
+}
+
+#line 279
+
+sub find_extensions {
+    my ($self, $path) = @_;
+    my @found;
+
+    File::Find::find(sub {
+        my $file = $File::Find::name;
+        return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
+        return if $1 eq $self->{dispatch};
+
+        $file = "$self->{path}/$1.pm";
+        my $pkg = "$self->{name}::$1"; $pkg =~ s!/!::!g;
+        push @found, [$file, $pkg];
+    }, $path) if -d $path;
+
+    @found;
+}
+
+1;
+
+__END__
+
+#line 617

Added: RT-Extension-QueueWizard/inc/Module/Install/Base.pm
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/inc/Module/Install/Base.pm	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,54 @@
+#line 1 "inc/Module/Install/Base.pm - /usr/local/share/perl/5.8.4/Module/Install/Base.pm"
+package Module::Install::Base;
+
+#line 28
+
+sub new {
+    my ($class, %args) = @_;
+
+    foreach my $method (qw(call load)) {
+        *{"$class\::$method"} = sub {
+            +shift->_top->$method(@_);
+        } unless defined &{"$class\::$method"};
+    }
+
+    bless(\%args, $class);
+}
+
+#line 46
+
+sub AUTOLOAD {
+    my $self = shift;
+    goto &{$self->_top->autoload};
+}
+
+#line 57
+
+sub _top { $_[0]->{_top} }
+
+#line 68
+
+sub admin {
+    my $self = shift;
+    $self->_top->{admin} or Module::Install::Base::FakeAdmin->new;
+}
+
+sub is_admin {
+    my $self = shift;
+    $self->admin->VERSION;
+}
+
+sub DESTROY {}
+
+package Module::Install::Base::FakeAdmin;
+
+my $Fake;
+sub new { $Fake ||= bless(\@_, $_[0]) }
+sub AUTOLOAD {}
+sub DESTROY {}
+
+1;
+
+__END__
+
+#line 112

Added: RT-Extension-QueueWizard/inc/Module/Install/Can.pm
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/inc/Module/Install/Can.pm	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,38 @@
+#line 1 "inc/Module/Install/Can.pm - /usr/local/share/perl/5.8.4/Module/Install/Can.pm"
+package Module::Install::Can;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+$VERSION = '0.01';
+
+use strict;
+use Config ();
+use File::Spec ();
+use ExtUtils::MakeMaker ();
+
+# check if we can run some command
+sub can_run {
+    my ($self, $cmd) = @_;
+
+    my $_cmd = $cmd;
+    return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
+
+    for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
+        my $abs = File::Spec->catfile($dir, $_[1]);
+        return $abs if (-x $abs or $abs = MM->maybe_command($abs));
+    }
+
+    return;
+}
+
+sub can_cc {
+    my $self = shift;
+    my @chunks = split(/ /, $Config::Config{cc}) or return;
+
+    # $Config{cc} may contain args; try to find out the program part
+    while (@chunks) {
+        return $self->can_run("@chunks") || (pop(@chunks), next);
+    }
+
+    return;
+}
+
+1;

Added: RT-Extension-QueueWizard/inc/Module/Install/Fetch.pm
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/inc/Module/Install/Fetch.pm	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,86 @@
+#line 1 "inc/Module/Install/Fetch.pm - /usr/local/share/perl/5.8.4/Module/Install/Fetch.pm"
+package Module::Install::Fetch;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.01';
+
+sub get_file {
+    my ($self, %args) = @_;
+    my ($scheme, $host, $path, $file) = 
+        $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
+
+    if ($scheme eq 'http' and !eval { require LWP::Simple; 1 }) {
+        $args{url} = $args{ftp_url}
+            or (warn("LWP support unavailable!\n"), return);
+        ($scheme, $host, $path, $file) = 
+            $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
+    }
+
+    $|++;
+    print "Fetching '$file' from $host... ";
+
+    unless (eval { require Socket; Socket::inet_aton($host) }) {
+        warn "'$host' resolve failed!\n";
+        return;
+    }
+
+    return unless $scheme eq 'ftp' or $scheme eq 'http';
+
+    require Cwd;
+    my $dir = Cwd::getcwd();
+    chdir $args{local_dir} or return if exists $args{local_dir};
+
+    if (eval { require LWP::Simple; 1 }) {
+        LWP::Simple::mirror($args{url}, $file);
+    }
+    elsif (eval { require Net::FTP; 1 }) { eval {
+        # use Net::FTP to get past firewall
+        my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600);
+        $ftp->login("anonymous", 'anonymous at example.com');
+        $ftp->cwd($path);
+        $ftp->binary;
+        $ftp->get($file) or (warn("$!\n"), return);
+        $ftp->quit;
+    } }
+    elsif (my $ftp = $self->can_run('ftp')) { eval {
+        # no Net::FTP, fallback to ftp.exe
+        require FileHandle;
+        my $fh = FileHandle->new;
+
+        local $SIG{CHLD} = 'IGNORE';
+        unless ($fh->open("|$ftp -n")) {
+            warn "Couldn't open ftp: $!\n";
+            chdir $dir; return;
+        }
+
+        my @dialog = split(/\n/, << ".");
+open $host
+user anonymous anonymous\@example.com
+cd $path
+binary
+get $file $file
+quit
+.
+        foreach (@dialog) { $fh->print("$_\n") }
+        $fh->close;
+    } }
+    else {
+        warn "No working 'ftp' program available!\n";
+        chdir $dir; return;
+    }
+
+    unless (-f $file) {
+        warn "Fetching failed: $@\n";
+        chdir $dir; return;
+    }
+
+    return if exists $args{size} and -s $file != $args{size};
+    system($args{run}) if exists $args{run};
+    unlink($file) if $args{remove};
+
+    print(((!exists $args{check_for} or -e $args{check_for})
+        ? "done!" : "failed! ($!)"), "\n");
+    chdir $dir; return !$?;
+}
+
+1;

Added: RT-Extension-QueueWizard/inc/Module/Install/Makefile.pm
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/inc/Module/Install/Makefile.pm	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,143 @@
+#line 1 "inc/Module/Install/Makefile.pm - /usr/local/share/perl/5.8.4/Module/Install/Makefile.pm"
+package Module::Install::Makefile;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.01';
+
+use strict 'vars';
+use vars '$VERSION';
+
+use ExtUtils::MakeMaker ();
+
+sub Makefile { $_[0] }
+
+sub prompt { 
+    shift;
+    goto &ExtUtils::MakeMaker::prompt;
+}
+
+sub makemaker_args {
+    my $self = shift;
+    my $args = ($self->{makemaker_args} ||= {});
+    %$args = ( %$args, @_ ) if @_;
+    $args;
+}
+
+sub clean_files {
+    my $self = shift;
+    my $clean = $self->makemaker_args->{clean} ||= {};
+    %$clean = (
+        %$clean, 
+        FILES => join(" ", grep length, $clean->{FILES}, @_),
+    );
+}
+
+sub libs {
+    my $self = shift;
+    my $libs = ref $_[0] ? shift : [shift];
+    $self->makemaker_args( LIBS => $libs );
+}
+
+sub inc {
+    my $self = shift;
+    $self->makemaker_args( INC => shift );
+}
+
+sub write {
+    my $self = shift;
+    die "&Makefile->write() takes no arguments\n" if @_;
+
+    my $args = $self->makemaker_args;
+
+    $args->{DISTNAME} = $self->name;
+    $args->{NAME} = $self->module_name || $self->name || $self->determine_NAME($args);
+    $args->{VERSION} = $self->version || $self->determine_VERSION($args);
+    $args->{NAME} =~ s/-/::/g;
+
+    if ($] >= 5.005) {
+	$args->{ABSTRACT} = $self->abstract;
+	$args->{AUTHOR} = $self->author;
+    }
+    if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) {
+        $args->{NO_META} = 1;
+    }
+    if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 ) {
+	$args->{SIGN} = 1 if $self->sign;
+    }
+    delete $args->{SIGN} unless $self->is_admin;
+
+    # merge both kinds of requires into prereq_pm
+    my $prereq = ($args->{PREREQ_PM} ||= {});
+    %$prereq = ( %$prereq, map { @$_ } map { @$_ } grep $_,
+                 ($self->build_requires, $self->requires) );
+
+    # merge both kinds of requires into prereq_pm
+    my $dir = ($args->{DIR} ||= []);
+    if ($self->bundles) {
+        push @$dir, map "$_->[1]", @{$self->bundles};
+        delete $prereq->{$_->[0]} for @{$self->bundles};
+    }
+
+    if (my $perl_version = $self->perl_version) {
+        eval "use $perl_version; 1"
+            or die "ERROR: perl: Version $] is installed, ".
+                   "but we need version >= $perl_version";
+    }
+
+    my %args = map {($_ => $args->{$_})} grep {defined($args->{$_})} keys %$args;
+
+    if ($self->admin->preop) {
+        $args{dist} = $self->admin->preop;
+    }
+
+    ExtUtils::MakeMaker::WriteMakefile(%args);
+
+    $self->fix_up_makefile();
+}
+
+sub fix_up_makefile {
+    my $self = shift;
+    my $top_class = ref($self->_top) || '';
+    my $top_version = $self->_top->VERSION || '';
+
+    my $preamble = $self->preamble 
+       ? "# Preamble by $top_class $top_version\n" . $self->preamble
+       : '';
+    my $postamble = "# Postamble by $top_class $top_version\n" . 
+                    ($self->postamble || '');
+
+    open MAKEFILE, '< Makefile' or die $!;
+    my $makefile = do { local $/; <MAKEFILE> };
+    close MAKEFILE;
+
+    $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
+    $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
+    $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g;
+
+    $makefile =~ s/^(FULLPERL = .*)/$1 -Iinc/m;
+    $makefile =~ s/^(PERL = .*)/$1 -Iinc/m;
+
+    open MAKEFILE, '> Makefile' or die $!;
+    print MAKEFILE "$preamble$makefile$postamble";
+    close MAKEFILE;
+}
+
+sub preamble {
+    my ($self, $text) = @_;
+    $self->{preamble} = $text . $self->{preamble} if defined $text;
+    $self->{preamble};
+}
+
+sub postamble {
+    my ($self, $text) = @_;
+
+    $self->{postamble} ||= $self->admin->postamble;
+    $self->{postamble} .= $text if defined $text;
+    $self->{postamble}
+}
+
+1;
+
+__END__
+
+#line 273

Added: RT-Extension-QueueWizard/inc/Module/Install/Metadata.pm
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/inc/Module/Install/Metadata.pm	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,187 @@
+#line 1 "inc/Module/Install/Metadata.pm - /usr/local/share/perl/5.8.4/Module/Install/Metadata.pm"
+package Module::Install::Metadata;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.04';
+
+use strict 'vars';
+use vars qw($VERSION);
+
+sub Meta { shift }
+
+my @scalar_keys = qw(
+    name module_name version abstract author license
+    distribution_type sign perl_version
+);
+my @tuple_keys  = qw(build_requires requires recommends bundles);
+
+foreach my $key (@scalar_keys) {
+    *$key = sub {
+        my $self = shift;
+        return $self->{'values'}{$key} unless @_;
+        $self->{'values'}{$key} = shift;
+        return $self;
+    };
+}
+
+foreach my $key (@tuple_keys) {
+    *$key = sub {
+        my $self = shift;
+        return $self->{'values'}{$key} unless @_;
+        my @rv;
+        while (@_) {
+            my $module  = shift or last;
+            my $version = shift || 0;
+            if ($module eq 'perl') {
+                $version =~ s{^(\d+)\.(\d+)\.(\d+)}
+                             {$1 + $2/1_000 + $3/1_000_000}e;
+                $self->perl_version($version);
+                next;
+            }
+            my $rv = [$module, $version];
+            push @{$self->{'values'}{$key}}, $rv;
+            push @rv, $rv;
+        }
+        return @rv;
+    };
+}
+
+sub features {
+    my $self = shift;
+    while (my ($name, $mods) = splice(@_, 0, 2)) {
+        my $count = 0;
+        push @{$self->{'values'}{'features'}}, ($name => [
+            map { (++$count % 2 and ref($_) and ($count += $#$_)) ? @$_ : $_ } @$mods
+        ] );
+    }
+    return @{$self->{'values'}{'features'}};
+}
+
+sub no_index {
+    my $self = shift;
+    my $type = shift;
+    push @{$self->{'values'}{'no_index'}{$type}}, @_ if $type;
+    return $self->{'values'}{'no_index'};
+}
+
+sub _dump {
+    my $self = shift;
+    my $package = ref($self->_top);
+    my $version = $self->_top->VERSION;
+    my %values = %{$self->{'values'}};
+
+    delete $values{sign};
+    if (my $perl_version = delete $values{perl_version}) {
+        # Always canonical to three-dot version 
+        $perl_version =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2), int($3))}e
+            if $perl_version >= 5.006;
+        $values{requires} = [
+            [perl => $perl_version],
+            @{$values{requires}||[]},
+        ];
+    }
+
+    warn "No license specified, setting license = 'unknown'\n"
+        unless $values{license};
+
+    $values{license} ||= 'unknown';
+    $values{distribution_type} ||= 'module';
+    $values{name} ||= do {
+        my $name = $values{module_name};
+        $name =~ s/::/-/g;
+        $name;
+    } if $values{module_name};
+
+    if ($values{name} =~ /::/) {
+        my $name = $values{name};
+        $name =~ s/::/-/g;
+        die "Error in name(): '$values{name}' should be '$name'!\n";
+    }
+
+    my $dump = '';
+    foreach my $key (@scalar_keys) {
+        $dump .= "$key: $values{$key}\n" if exists $values{$key};
+    }
+    foreach my $key (@tuple_keys) {
+        next unless exists $values{$key};
+        $dump .= "$key:\n";
+        foreach (@{$values{$key}}) {
+            $dump .= "  $_->[0]: $_->[1]\n";
+        }
+    }
+
+    if (my $no_index = $values{no_index}) {
+        push @{$no_index->{'directory'}}, 'inc';
+        require YAML;
+        local $YAML::UseHeader = 0;
+        $dump .= YAML::Dump({ no_index => $no_index});
+    }
+    else {
+        $dump .= << "META";
+no_index:
+  directory:
+    - inc
+META
+    }
+    
+    $dump .= "generated_by: $package version $version\n";
+    return $dump;
+}
+
+sub read {
+    my $self = shift;
+    $self->include_deps( 'YAML', 0 );
+    require YAML;
+    my $data = YAML::LoadFile( 'META.yml' );
+    # Call methods explicitly in case user has already set some values.
+    while ( my ($key, $value) = each %$data ) {
+        next unless $self->can( $key );
+        if (ref $value eq 'HASH') {
+            while (my ($module, $version) = each %$value) {
+                $self->$key( $module => $version );
+            }
+        }
+        else {
+            $self->$key( $value );
+        }
+    }
+    return $self;
+}
+
+sub write {
+    my $self = shift;
+    return $self unless $self->is_admin;
+
+    META_NOT_OURS: {
+        local *FH;
+        if (open FH, "META.yml") {
+            while (<FH>) {
+                last META_NOT_OURS if /^generated_by: Module::Install\b/;
+            }
+            return $self if -s FH;
+        }
+    }
+
+    warn "Writing META.yml\n";
+    open META, "> META.yml" or warn "Cannot write to META.yml: $!";
+    print META $self->_dump;
+    close META;
+    return $self;
+}
+
+sub version_from {
+    my ($self, $version_from) = @_;
+    require ExtUtils::MM_Unix;
+    $self->version(ExtUtils::MM_Unix->parse_version($version_from));
+}
+
+sub abstract_from {
+    my ($self, $abstract_from) = @_;
+    require ExtUtils::MM_Unix;
+    $self->abstract(
+        bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix')
+            ->parse_abstract($abstract_from)
+    );
+}
+
+1;

Added: RT-Extension-QueueWizard/inc/Module/Install/RTx.pm
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/inc/Module/Install/RTx.pm	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,158 @@
+#line 1 "inc/Module/Install/RTx.pm - /usr/local/share/perl/5.8.4/Module/Install/RTx.pm"
+package Module::Install::RTx;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$Module::Install::RTx::VERSION = '0.10';
+
+use strict;
+use FindBin;
+use File::Glob ();
+use File::Basename ();
+
+sub RTx {
+    my ($self, $name) = @_;
+    my $RTx = 'RTx';
+    $RTx = $1 if $name =~ s/^(\w+)-//;
+    my $fname = $name;
+    $fname =~ s!-!/!g;
+
+    $self->name("$RTx-$name")
+        unless $self->name;
+    $self->abstract("RT $name Extension")
+        unless $self->abstract;
+    $self->version_from (-e "$name.pm" ? "$name.pm" : "lib/$RTx/$fname.pm")
+        unless $self->version;
+
+    my @prefixes = (qw(/opt /usr/local /home /usr /sw ));
+    my $prefix = $ENV{PREFIX};
+    @ARGV = grep { /PREFIX=(.*)/ ? (($prefix = $1), 0) : 1 } @ARGV;
+
+    if ($prefix) {
+        $RT::LocalPath = $prefix;
+        $INC{'RT.pm'} = "$RT::LocalPath/lib/RT.pm";
+    }
+    else {
+        local @INC = (
+            @INC,
+            $ENV{RTHOME} ? ($ENV{RTHOME}, "$ENV{RTHOME}/lib") : (),
+            map {( "$_/rt3/lib", "$_/lib/rt3", "$_/lib" )} grep $_, @prefixes
+        );
+        until ( eval { require RT; $RT::LocalPath } ) {
+            warn "Cannot find the location of RT.pm that defines \$RT::LocalPath in: @INC\n";
+            $_ = $self->prompt("Path to your RT.pm:") or exit;
+            push @INC, $_, "$_/rt3/lib", "$_/lib/rt3";
+        }
+    }
+
+    my $lib_path = File::Basename::dirname($INC{'RT.pm'});
+    print "Using RT configurations from $INC{'RT.pm'}:\n";
+
+    $RT::LocalVarPath	||= $RT::VarPath;
+    $RT::LocalPoPath	||= $RT::LocalLexiconPath;
+    $RT::LocalHtmlPath	||= $RT::MasonComponentRoot;
+
+    my %path;
+    my $with_subdirs = $ENV{WITH_SUBDIRS};
+    @ARGV = grep { /WITH_SUBDIRS=(.*)/ ? (($with_subdirs = $1), 0) : 1 } @ARGV;
+    my %subdirs = map { $_ => 1 } split(/\s*,\s*/, $with_subdirs);
+
+    foreach (qw(bin etc html po sbin var)) {
+        next unless -d "$FindBin::Bin/$_";
+        next if %subdirs and !$subdirs{$_};
+        $self->no_index( directory => $_ );
+
+        no strict 'refs';
+        my $varname = "RT::Local" . ucfirst($_) . "Path";
+        $path{$_} = ${$varname} || "$RT::LocalPath/$_";
+    }
+
+    $path{$_} .= "/$name" for grep $path{$_}, qw(etc po var);
+    my $args = join(', ', map "q($_)", %path);
+    $path{lib} = "$RT::LocalPath/lib" unless %subdirs and !$subdirs{'lib'};
+    print "./$_\t=> $path{$_}\n" for sort keys %path;
+
+    if (my @dirs = map { (-D => $_) } grep $path{$_}, qw(bin html sbin)) {
+        my @po = map { (-o => $_) } grep -f, File::Glob::bsd_glob("po/*.po");
+        $self->postamble(<< ".") if @po;
+lexicons ::
+\t\$(NOECHO) \$(PERL) -MLocale::Maketext::Extract::Run=xgettext -e \"xgettext(qw(@dirs @po))\"
+.
+    }
+
+    my $postamble = << ".";
+install ::
+\t\$(NOECHO) \$(PERL) -MExtUtils::Install -e \"install({$args})\"
+.
+
+    if ($path{var} and -d $RT::MasonDataDir) {
+        my ($uid, $gid) = (stat($RT::MasonDataDir))[4, 5];
+        $postamble .= << ".";
+\t\$(NOECHO) chown -R $uid:$gid $path{var}
+.
+    }
+
+    my %has_etc;
+    if (File::Glob::bsd_glob("$FindBin::Bin/etc/schema.*")) {
+        # got schema, load factory module
+        $has_etc{schema}++;
+        $self->load('RTxFactory');
+        $self->postamble(<< ".");
+factory ::
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxFactory(qw($RTx $name))"
+
+dropdb ::
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxFactory(qw($RTx $name drop))"
+
+.
+    }
+    if (File::Glob::bsd_glob("$FindBin::Bin/etc/acl.*")) {
+        $has_etc{acl}++;
+    }
+    if (-e 'etc/initialdata') {
+        $has_etc{initialdata}++;
+    }
+
+    $self->postamble("$postamble\n");
+    if (%subdirs and !$subdirs{'lib'}) {
+        $self->makemaker_args(
+            PM => { "" => "" },
+        )
+    }
+    else {
+        $self->makemaker_args( INSTALLSITELIB => "$RT::LocalPath/lib" );
+    }
+
+    if (%has_etc) {
+        $self->load('RTxInitDB');
+        print "For first-time installation, type 'make initdb'.\n";
+        my $initdb = '';
+        $initdb .= <<"." if $has_etc{schema};
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(schema))"
+.
+        $initdb .= <<"." if $has_etc{acl};
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(acl))"
+.
+        $initdb .= <<"." if $has_etc{initialdata};
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(insert))"
+.
+        $self->postamble("initdb ::\n$initdb\n");
+        $self->postamble("initialize-database ::\n$initdb\n");
+    }
+}
+
+sub RTxInit {
+    unshift @INC, substr(delete($INC{'RT.pm'}), 0, -5) if $INC{'RT.pm'};
+    require RT;
+    RT::LoadConfig();
+    RT::ConnectToDatabase();
+
+    die "Cannot load RT" unless $RT::Handle and $RT::DatabaseType;
+}
+
+1;
+
+__END__
+
+#line 221
+
+#line 242

Added: RT-Extension-QueueWizard/inc/Module/Install/RTx/Factory.pm
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/inc/Module/Install/RTx/Factory.pm	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,479 @@
+#line 1 "inc/Module/Install/RTx/Factory.pm - /usr/local/share/perl/5.8.4/Module/Install/RTx/Factory.pm"
+package Module::Install::RTx::Factory;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+use strict;
+use File::Basename ();
+
+sub RTxInitDB {
+    my ($self, $action) = @_;
+
+    unshift @INC, substr(delete($INC{'RT.pm'}), 0, -5) if $INC{'RT.pm'};
+
+    require RT;
+    $RT::SbinPath ||= $RT::LocalPath;
+    $RT::SbinPath =~ s/local$/sbin/;
+
+    foreach my $file ($RT::CORE_CONFIG_FILE, $RT::SITE_CONFIG_FILE) {
+        next if !-e $file or -r $file;
+        die "No permission to read $file\n-- please re-run $0 with suitable privileges.\n";
+    }
+
+    RT::LoadConfig();
+
+    my $lib_path = File::Basename::dirname($INC{'RT.pm'});
+    my @args = (
+        "-Ilib", "-I$lib_path",
+        "$RT::SbinPath/rt-setup-database",
+        "--action"      => $action,
+        "--datadir"     => "etc",
+        "--datafile"    => "etc/initialdata",
+        "--dba"         => $RT::DatabaseUser,
+        "--prompt-for-dba-password" => ''
+    );
+    print "$^X @args\n";
+    (system($^X, @args) == 0) or die "...returned with error: $?\n";
+}
+
+sub RTxFactory {
+    my ($self, $RTx, $name, $drop) = @_;
+    my $namespace = "$RTx\::$name";
+
+    $self->RTxInit;
+
+    my $dbh = $RT::Handle->dbh;
+    # get all tables out of database
+    my @tables = $dbh->tables;
+    my ( %tablemap, %typemap, %modulemap );
+    my $driver = $RT::DatabaseType;
+
+    my $CollectionBaseclass = 'RT::SearchBuilder';
+    my $RecordBaseclass     = 'RT::Record';
+    my $LicenseBlock = << '.';
+# BEGIN LICENSE BLOCK
+# 
+# END LICENSE BLOCK
+.
+    my $Attribution = << '.';
+# Autogenerated by Module::Intall::RTx::Factory
+# WARNING: THIS FILE IS AUTOGENERATED. ALL CHANGES TO THIS FILE WILL BE LOST.  
+# 
+# !! DO NOT EDIT THIS FILE !!
+#
+
+use strict;
+.
+    my $RecordInit = '';
+
+    @tables = map { do { {
+	my $table = $_;
+	$table =~ s/.*\.//g;
+	$table =~ s/\W//g;
+	$table =~ s/^\Q$name\E_//i or next;
+	$table ne 'sessions' or next;
+
+	$table = ucfirst(lc($table));
+	$table =~ s/$_/\u$_/ for qw(field group custom member value);
+	$table =~ s/(?<=Scrip)$_/\u$_/ for qw(action condition);
+	$table =~ s/$_/\U$_/ for qw(Acl);
+	$table = $name . '_' . $table;
+
+	$tablemap{$table}  = $table;
+	$modulemap{$table} = $table;
+	if ( $table =~ /^(.*)s$/ ) {
+	    $tablemap{$1}  = $table;
+	    $modulemap{$1} = $1;
+	}
+	$table;
+    } } } @tables;
+
+    $tablemap{'CreatedBy'} = 'User';
+    $tablemap{'UpdatedBy'} = 'User';
+
+    $typemap{'id'}            = 'ro';
+    $typemap{'Creator'}       = 'auto';
+    $typemap{'Created'}       = 'auto';
+    $typemap{'Updated'}       = 'auto';
+    $typemap{'UpdatedBy'}     = 'auto';
+    $typemap{'LastUpdated'}   = 'auto';
+    $typemap{'LastUpdatedBy'} = 'auto';
+
+    $typemap{lc($_)} = $typemap{$_} for keys %typemap;
+
+    foreach my $table (@tables) {
+	if ($drop) {
+	    $dbh->do("DROP TABLE $table");
+	    $dbh->do("DROP sequence ${table}_id_seq") if $driver eq 'Pg';
+	    $dbh->do("DROP sequence ${table}_seq") if $driver eq 'Oracle';
+	    next;
+	}
+
+	my $tablesingle = $table;
+	$tablesingle =~ s/^\Q$name\E_//i;
+	$tablesingle =~ s/s$//;
+	my $tableplural = $tablesingle . "s";
+
+	if ( $tablesingle eq 'ACL' ) {
+	    $tablesingle = "ACE";
+	    $tableplural = "ACL";
+	}
+
+	my %requirements;
+
+	my $CollectionClassName = $namespace . "::" . $tableplural;
+	my $RecordClassName     = $namespace . "::" . $tablesingle;
+
+	my $path = $namespace;
+	$path =~ s/::/\//g;
+
+	my $RecordClassPath     = $path . "/" . $tablesingle . ".pm";
+	my $CollectionClassPath = $path . "/" . $tableplural . ".pm";
+
+	#create a collection class
+	my $CreateInParams;
+	my $CreateOutParams;
+	my $ClassAccessible = "";
+	my $FieldsPod       = "";
+	my $CreatePod       = "";
+	my $CreateSub       = "";
+	my %fields;
+	my $sth = $dbh->prepare("DESCRIBE $table");
+
+	if ( $driver eq 'Pg' ) {
+	    $sth = $dbh->prepare(<<".");
+  SELECT a.attname, format_type(a.atttypid, a.atttypmod),
+         a.attnotnull, a.atthasdef, a.attnum
+    FROM pg_class c, pg_attribute a
+   WHERE c.relname ILIKE '$table'
+         AND a.attnum > 0
+         AND a.attrelid = c.oid
+ORDER BY a.attnum
+.
+	}
+	elsif ( $driver eq 'mysql' ) {
+	    $sth = $dbh->prepare("DESCRIBE $table");
+	}
+	else {
+	    die "$driver is currently unsupported";
+	}
+
+	$sth->execute;
+
+	while ( my $row = $sth->fetchrow_hashref() ) {
+	    my ( $field, $type, $default );
+	    if ( $driver eq 'Pg' ) {
+
+		$field   = $row->{'attname'};
+		$type    = $row->{'format_type'};
+		$default = $row->{'atthasdef'};
+
+		if ( $default != 0 ) {
+		    my $tth = $dbh->prepare(<<".");
+SELECT substring(d.adsrc for 128)
+  FROM pg_attrdef d, pg_class c
+ WHERE c.relname = 'acct'
+       AND c.oid = d.adrelid
+       AND d.adnum = $row->{'attnum'}
+.
+		    $tth->execute();
+		    my @default = $tth->fetchrow_array;
+		    $default = $default[0];
+		}
+
+	    }
+	    elsif ( $driver eq 'mysql' ) {
+		$field   = $row->{'Field'};
+		$type    = $row->{'Type'};
+		$default = $row->{'Default'};
+	    }
+
+	    $fields{$field} = 1;
+
+	    #generate the 'accessible' datastructure
+
+	    if ( $typemap{$field} eq 'auto' ) {
+		$ClassAccessible .= "        $field => 
+		    {read => 1, auto => 1,";
+	    }
+	    elsif ( $typemap{$field} eq 'ro' ) {
+		$ClassAccessible .= "        $field =>
+		    {read => 1,";
+	    }
+	    else {
+		$ClassAccessible .= "        $field => 
+		    {read => 1, write => 1,";
+
+	    }
+
+	    $ClassAccessible .= " type => '$type', default => '$default'},\n";
+
+	    #generate pod for the accessible fields
+	    $FieldsPod .= $self->_pod(<<".");
+^head2 $field
+
+Returns the current value of $field. 
+(In the database, $field is stored as $type.)
+
+.
+
+	    unless ( $typemap{$field} eq 'auto' || $typemap{$field} eq 'ro' ) {
+		$FieldsPod .= $self->_pod(<<".");
+
+^head2 Set$field VALUE
+
+
+Set $field to VALUE. 
+Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
+(In the database, $field will be stored as a $type.)
+
+.
+	    }
+
+	    $FieldsPod .= $self->_pod(<<".");
+^cut
+
+.
+
+	    if ( $modulemap{$field} ) {
+		$FieldsPod .= $self->_pod(<<".");
+^head2 ${field}Obj
+
+Returns the $modulemap{$field} Object which has the id returned by $field
+
+
+^cut
+
+sub ${field}Obj {
+	my \$self = shift;
+	my \$$field =  ${namespace}::$modulemap{$field}->new(\$self->CurrentUser);
+	\$$field->Load(\$self->__Value('$field'));
+	return(\$$field);
+}
+.
+		$requirements{ $tablemap{$field} } =
+		"use ${namespace}::$modulemap{$field};";
+
+	    }
+
+	    unless ( $typemap{$field} eq 'auto' || $field eq 'id' ) {
+
+		#generate create statement
+		$CreateInParams .= "                $field => '$default',\n";
+		$CreateOutParams .=
+		"                         $field => \$args{'$field'},\n";
+
+		#gerenate pod for the create statement	
+		$CreatePod .= "  $type '$field'";
+		$CreatePod .= " defaults to '$default'" if ($default);
+		$CreatePod .= ".\n";
+
+	    }
+
+	}
+
+	$CreateSub = <<".";
+sub Create {
+    my \$self = shift;
+    my \%args = ( 
+$CreateInParams
+		\@_);
+    \$self->SUPER::Create(
+$CreateOutParams);
+
+}
+.
+	$CreatePod .= "\n=cut\n\n";
+
+	my $CollectionClass = $LicenseBlock . $Attribution . $self->_pod(<<".") . $self->_magic_import($CollectionClassName);
+
+^head1 NAME
+
+$CollectionClassName -- Class Description
+
+^head1 SYNOPSIS
+
+use $CollectionClassName
+
+^head1 DESCRIPTION
+
+
+^head1 METHODS
+
+^cut
+
+package $CollectionClassName;
+
+use $CollectionBaseclass;
+use $RecordClassName;
+
+use vars qw( \@ISA );
+\@ISA= qw($CollectionBaseclass);
+
+
+sub _Init {
+    my \$self = shift;
+    \$self->{'table'} = '$table';
+    \$self->{'primary_key'} = 'id';
+
+.
+
+    if ( $fields{'SortOrder'} ) {
+
+	$CollectionClass .= $self->_pod(<<".");
+
+# By default, order by name
+\$self->OrderBy( ALIAS => 'main',
+		FIELD => 'SortOrder',
+		ORDER => 'ASC');
+.
+    }
+    $CollectionClass .= $self->_pod(<<".");
+    return ( \$self->SUPER::_Init(\@_) );
+}
+
+
+^head2 NewItem
+
+Returns an empty new $RecordClassName item
+
+^cut
+
+sub NewItem {
+    my \$self = shift;
+    return($RecordClassName->new(\$self->CurrentUser));
+}
+.
+
+    my $RecordClassHeader = $Attribution . "
+
+^head1 NAME
+
+$RecordClassName
+
+
+^head1 SYNOPSIS
+
+^head1 DESCRIPTION
+
+^head1 METHODS
+
+^cut
+
+package $RecordClassName;
+use $RecordBaseclass; 
+";
+
+    foreach my $key ( keys %requirements ) {
+	$RecordClassHeader .= $requirements{$key} . "\n";
+    }
+    $RecordClassHeader .= <<".";
+
+use vars qw( \@ISA );
+\@ISA= qw( $RecordBaseclass );
+
+sub _Init {
+my \$self = shift; 
+
+\$self->Table('$table');
+\$self->SUPER::_Init(\@_);
+}
+
+.
+
+    my $RecordClass = $LicenseBlock . $RecordClassHeader . $self->_pod(<<".") . $self->_magic_import($RecordClassName);
+
+$RecordInit
+
+^head2 Create PARAMHASH
+
+Create takes a hash of values and creates a row in the database:
+
+$CreatePod
+
+$CreateSub
+
+$FieldsPod
+
+sub _CoreAccessible {
+    {
+    
+$ClassAccessible
+}
+};
+
+.
+
+	print "About to make $RecordClassPath, $CollectionClassPath\n";
+	`mkdir -p $path`;
+
+	open( RECORD, ">$RecordClassPath" );
+	print RECORD $RecordClass;
+	close(RECORD);
+
+	open( COL, ">$CollectionClassPath" );
+	print COL $CollectionClass;
+	close(COL);
+
+    }
+}
+
+sub _magic_import {
+    my $self = shift;
+    my $class = ref($self) || $self;
+
+    #if (exists \$warnings::{unimport})  {
+    #        no warnings qw(redefine);
+
+    my $path = $class;
+    $path =~ s#::#/#gi;
+
+
+    my $content = $self->_pod(<<".");
+        eval \"require ${class}_Overlay\";
+        if (\$@ && \$@ !~ qr{^Can't locate ${path}_Overlay.pm}) {
+            die \$@;
+        };
+
+        eval \"require ${class}_Vendor\";
+        if (\$@ && \$@ !~ qr{^Can't locate ${path}_Vendor.pm}) {
+            die \$@;
+        };
+
+        eval \"require ${class}_Local\";
+        if (\$@ && \$@ !~ qr{^Can't locate ${path}_Local.pm}) {
+            die \$@;
+        };
+
+
+
+
+^head1 SEE ALSO
+
+This class allows \"overlay\" methods to be placed
+into the following files _Overlay is for a System overlay by the original author,
+_Vendor is for 3rd-party vendor add-ons, while _Local is for site-local customizations.  
+
+These overlay files can contain new subs or subs to replace existing subs in this module.
+
+If you'll be working with perl 5.6.0 or greater, each of these files should begin with the line 
+
+   no warnings qw(redefine);
+
+so that perl does not kick and scream when you redefine a subroutine or variable in your overlay.
+
+${class}_Overlay, ${class}_Vendor, ${class}_Local
+
+^cut
+
+
+1;
+.
+
+    return $content;
+}
+
+sub _pod {
+    my ($self, $text) = @_;
+    $text =~ s/^\^/=/mg;
+    return $text;
+}

Added: RT-Extension-QueueWizard/inc/Module/Install/Win32.pm
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/inc/Module/Install/Win32.pm	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,63 @@
+#line 1 "inc/Module/Install/Win32.pm - /usr/local/share/perl/5.8.4/Module/Install/Win32.pm"
+package Module::Install::Win32;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.02';
+
+use strict;
+
+# determine if the user needs nmake, and download it if needed
+sub check_nmake {
+    my $self = shift;
+    $self->load('can_run');
+    $self->load('get_file');
+
+    require Config;
+    return unless (
+        $Config::Config{make}                   and
+        $Config::Config{make} =~ /^nmake\b/i    and
+        $^O eq 'MSWin32'                        and
+        !$self->can_run('nmake')
+    );
+
+    print "The required 'nmake' executable not found, fetching it...\n";
+
+    require File::Basename;
+    my $rv = $self->get_file(
+        url         => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe',
+        ftp_url     => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe',
+        local_dir   => File::Basename::dirname($^X),
+        size        => 51928,
+        run         => 'Nmake15.exe /o > nul',
+        check_for   => 'Nmake.exe',
+        remove      => 1,
+    );
+
+    if (!$rv) {
+        die << '.';
+
+-------------------------------------------------------------------------------
+
+Since you are using Microsoft Windows, you will need the 'nmake' utility
+before installation. It's available at:
+
+  http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe
+      or
+  ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe
+
+Please download the file manually, save it to a directory in %PATH% (e.g.
+C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to
+that directory, and run "Nmake15.exe" from there; that will create the
+'nmake.exe' file needed by this module.
+
+You may then resume the installation process described in README.
+
+-------------------------------------------------------------------------------
+.
+    }
+}
+
+1;
+
+__END__
+

Added: RT-Extension-QueueWizard/inc/Module/Install/WriteAll.pm
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/inc/Module/Install/WriteAll.pm	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,36 @@
+#line 1 "inc/Module/Install/WriteAll.pm - /usr/local/share/perl/5.8.4/Module/Install/WriteAll.pm"
+package Module::Install::WriteAll;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+sub WriteAll {
+    my $self = shift;
+    my %args = (
+        meta => 1,
+        sign => 0,
+        inline => 0,
+        check_nmake => 1,
+        @_
+    );
+
+    $self->sign(1) if $args{sign};
+    $self->Meta->write if $args{meta};
+    $self->admin->WriteAll(%args) if $self->is_admin;
+
+    if ($0 =~ /Build.PL$/i) {
+	$self->Build->write;
+    }
+    else {
+	$self->check_nmake if $args{check_nmake};
+        $self->makemaker_args( PL_FILES => {} )
+            unless $self->makemaker_args->{'PL_FILES'};
+
+        if ($args{inline}) {
+            $self->Inline->write;
+        }
+        else {
+            $self->Makefile->write;
+        }
+    }
+}
+
+1;

Added: RT-Extension-QueueWizard/includeall.rc
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/includeall.rc	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,7 @@
+:0
+* LIST ?? ^^()^^
+{ NEXTONE   LIST = `ls auto` }  # happens on first run only
+
+:0
+* $ LIST ?? ^$\NEXTONE^?\/.+
+{ NEXTONE = $MATCH   INCLUDERC = auto/$NEXTONE  SWITCHRC = $_ }

Added: RT-Extension-QueueWizard/lib/RT/Extension/QueueWizard.pm
==============================================================================
--- (empty file)
+++ RT-Extension-QueueWizard/lib/RT/Extension/QueueWizard.pm	Thu Jul 27 01:37:02 2006
@@ -0,0 +1,3 @@
+package RT::Extension::QueueWizard;
+
+our $VERSION = '0.6';


More information about the Rt-commit mailing list