[Rt-commit] [svn] r1950 - in RT-Integration-Textfile: . bin html
html/Integration html/Integration/Textfile lib lib/RT
lib/RT/Integration
jesse at pallas.eruditorum.org
jesse at pallas.eruditorum.org
Tue Nov 30 23:33:23 EST 2004
Author: jesse
Date: Tue Nov 30 23:33:22 2004
New Revision: 1950
Added:
RT-Integration-Textfile/Makefile.PL
RT-Integration-Textfile/bin/
RT-Integration-Textfile/bin/editix
RT-Integration-Textfile/html/
RT-Integration-Textfile/html/Integration/
RT-Integration-Textfile/html/Integration/Textfile/
RT-Integration-Textfile/html/Integration/Textfile/Process.html
RT-Integration-Textfile/lib/
RT-Integration-Textfile/lib/RT/
RT-Integration-Textfile/lib/RT/Integration/
RT-Integration-Textfile/lib/RT/Integration/Textfile.pm
Log:
checking in the code so I at least have the checked in code
Added: RT-Integration-Textfile/Makefile.PL
==============================================================================
--- (empty file)
+++ RT-Integration-Textfile/Makefile.PL Tue Nov 30 23:33:22 2004
@@ -0,0 +1,9 @@
+#!/usr/bin/perl -w
+
+use inc::Module::Install;
+
+RTx('RT-Integration-Textfile');
+
+version_from('lib/RT/Integration/Textfile.pm');
+
+&WriteAll;
Added: RT-Integration-Textfile/bin/editix
==============================================================================
--- (empty file)
+++ RT-Integration-Textfile/bin/editix Tue Nov 30 23:33:22 2004
@@ -0,0 +1,60 @@
+#!/opt/perl-5.8.3/bin/perl -w
+
+use strict;
+use LWP::UserAgent;
+use HTTP::Request::Common;
+use HTTP::Cookies;
+use LWP;
+
+$ENV{'EDITOR'} ||= 'vi';
+$USER = 'root';
+$PASSWORD = 'password';
+$RT_SERVER = 'http://localhost';
+
+
+my $cookie_jar = HTTP::Cookies->new;
+my $agent = LWP::UserAgent->new();
+
+# give the agent a place to stash the cookies
+
+$agent->cookie_jar($cookie_jar);
+
+
+# get the top page
+use Data::Dumper;
+my $url = $RT_SERVER . "/Integration/Textfile/Process.html";
+my $res= $agent->post($url, { user => $USER, pass => $PASSWORD, query => '(Queue ="testing") AND (Status="new" OR Status="open")'});
+ unless ($res->is_success) {
+ die $res->status_line, "\n";
+ }
+
+ my $orig_content = $res->content;
+ my $content = vi($orig_content);
+die "No changes made. Aborting" unless ($content ne $orig_content);
+
+
+$res= $agent->post($url, { user => $USER, pass => $PASSWORD, template => $content });
+ unless ($res->is_success) {
+ die $res->status_line, "\n";
+ }
+
+print $res->content;
+
+
+
+sub vi {
+ my ($text) = shift;
+ my $file = "/tmp/rt.form.$$";
+ my $editor = $ENV{EDITOR} || $ENV{VISUAL} || "vi";
+
+ local *F;
+ local $/ = undef;
+
+ open(F, ">$file") || die "$file: $!\n"; print F $text; close(F);
+ system($editor, $file) && die "Couldn't run $editor.\n";
+ open(F, $file) || die "$file: $!\n"; $text = <F>; close(F);
+ unlink($file);
+
+ return $text;
+}
+
Added: RT-Integration-Textfile/html/Integration/Textfile/Process.html
==============================================================================
--- (empty file)
+++ RT-Integration-Textfile/html/Integration/Textfile/Process.html Tue Nov 30 23:33:22 2004
@@ -0,0 +1,66 @@
+<%args>
+$template => undef
+$query => undef
+</%args>
+<%INIT>
+my @results;
+use RT::Action::CreateTickets;
+
+my $action = RT::Action::CreateTickets->new( CurrentUser => $session{'CurrentUser'} );
+if ($template) {
+ $template =~ s/\r\n/\n/gs;
+ $action->Parse( Content => $template );
+ push @results, $action->CreateByTemplate();
+ push @results, $action->UpdateByTemplate();
+
+ foreach my $line (@results) {
+ $m->out($line."\n");
+ }
+}
+elsif ( $query ) {
+ my $Tickets = RT::Tickets->new( $session{'CurrentUser'} );
+ $Tickets->FromSQL( $query );
+
+ my @rows;
+
+ my @attrs =
+ qw( id QueueObj->Name Subject Status TimeEstimated TimeWorked
+ TimeLeft Priority OwnerObj->Name);
+
+ while ( my $Ticket = $Tickets->Next() ) {
+ my $row;
+ foreach my $attr (@attrs) {
+ my $method = '$Ticket->' . $attr . '()';
+ $row->{$attr} = eval $method;
+ if ($@) { die "Failed to find $attr - " . $@ }
+ }
+ push @rows, $row;
+
+ }
+ $r->content_type('text/plain');
+ my @header;
+ foreach my $attr (@attrs) {
+ my $label = $attr;
+ $label =~ s'Obj-.(AsString|Name)''g;
+ push @header, $label;
+ }
+ $m->out( join( ", ", @header ) . "\n" );
+
+
+
+ my $string = join(', ', @header);
+ $m->out($string, "\n");
+
+
+ foreach my $row (@rows) {
+ my @row;
+ push @row, $row->{$_} for (@attrs);
+ $m->out(join (', ', at row)."\n");
+
+ }
+ $m->out('# '.$query);
+
+}
+ $m->abort();
+</%INIT>
+
Added: RT-Integration-Textfile/lib/RT/Integration/Textfile.pm
==============================================================================
--- (empty file)
+++ RT-Integration-Textfile/lib/RT/Integration/Textfile.pm Tue Nov 30 23:33:22 2004
@@ -0,0 +1,6 @@
+use warnings;
+use strict;
+
+package RT::Integration::Textfile;
+
+our $VERSION ='0.01';
More information about the Rt-commit
mailing list