[freeside-commits]
freeside/FS/FS/TicketSystem RT_External.pm, 1.15,
1.16 RT_Internal.pm, 1.7, 1.8
Ivan,,,
ivan at wavetail.420.am
Sat Oct 15 04:29:56 PDT 2005
Update of /home/cvs/cvsroot/freeside/FS/FS/TicketSystem
In directory wavetail:/tmp/cvs-serv8761/FS/FS/TicketSystem
Modified Files:
RT_External.pm RT_Internal.pm
Log Message:
agent option to select RT queue
Index: RT_External.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/TicketSystem/RT_External.pm,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- RT_External.pm 3 Jun 2005 01:51:12 -0000 1.15
+++ RT_External.pm 15 Oct 2005 11:29:53 -0000 1.16
@@ -3,11 +3,13 @@
use strict;
use vars qw( $conf $default_queueid
$priority_field $priority_field_queue $field
- $external_dbh $external_url );
+ $dbh $external_url );
use URI::Escape;
-use FS::UID;
+use FS::UID qw(dbh);
+use FS::Record qw(qsearchs);
+use FS::cust_main;
-install_callback FS::UID sub {
+FS::UID->install_callback( sub {
my $conf = new FS::Conf;
$default_queueid = $conf->config('ticket_system-default_queueid');
$priority_field =
@@ -24,20 +26,19 @@
}
$external_url = '';
+ $dbh = dbh;
if ($conf->config('ticket_system') eq 'RT_External') {
my ($datasrc, $user, $pass) = $conf->config('ticket_system-rt_external_datasrc');
- $external_dbh = DBI->connect($datasrc, $user, $pass, { 'ChopBlanks' => 1 })
+ $dbh = DBI->connect($datasrc, $user, $pass, { 'ChopBlanks' => 1 })
or die "RT_External DBI->connect error: $DBI::errstr\n";
$external_url = $conf->config('ticket_system-rt_external_url');
}
-};
+} );
sub num_customer_tickets {
- my( $self, $custnum, $priority, $dbh ) = @_;
-
- $dbh ||= $external_dbh;
+ my( $self, $custnum, $priority ) = @_;
my( $from_sql, @param) = $self->_from_customer( $custnum, $priority );
@@ -50,11 +51,9 @@
}
sub customer_tickets {
- my( $self, $custnum, $limit, $priority, $dbh ) = @_;
+ my( $self, $custnum, $limit, $priority ) = @_;
$limit ||= 0;
- $dbh ||= $external_dbh;
-
my( $from_sql, @param) = $self->_from_customer( $custnum, $priority );
my $sql = "select tickets.*, queues.name".
( length($priority) ? ", ticketcustomfieldvalues.content" : '' ).
@@ -131,12 +130,14 @@
}
-sub _href_customer_tickets {
+sub href_customer_tickets {
my( $self, $custnum, $priority ) = @_;
+ my $href = $self->baseurl;
+
#i snarfed this from an RT bookmarked search, it could be unescaped in the
#source for readability and run through uri_escape
- my $href =
+ $href .=
'Search/Results.html?Order=ASC&Query=%20MemberOf%20%3D%20%27freeside%3A%2F%2Ffreeside%2Fcust_main%2F'.
$custnum.
'%27%20%20AND%20%28%20Status%20%3D%20%27open%27%20%20OR%20Status%20%3D%20%27new%27%20%20OR%20Status%20%3D%20%27stalled%27%20%29%20'
@@ -178,35 +179,52 @@
}
-sub href_customer_tickets {
- my $self = shift;
- $self->baseurl. $self->_href_customer_tickets(@_);
-}
-
+sub href_new_ticket {
+ my( $self, $custnum_or_cust_main, $requestors ) = @_;
-sub _href_new_ticket {
- my( $self, $custnum, $requestors ) = @_;
+ my( $custnum, $cust_main );
+ if ( ref($custnum_or_cust_main) ) {
+ $cust_main = $custnum_or_cust_main;
+ $custnum = $cust_main->custnum;
+ } else {
+ $custnum = $custnum_or_cust_main;
+ $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+ }
+ my $queueid = $cust_main->agent->ticketing_queueid || $default_queueid;
+ $self->baseurl.
'Ticket/Create.html?'.
- "Queue=$default_queueid".
+ "Queue=$queueid".
"&new-MemberOf=freeside://freeside/cust_main/$custnum".
( $requestors ? '&Requestors='. uri_escape($requestors) : '' )
;
}
-sub href_new_ticket {
- my $self = shift;
- $self->baseurl. $self->_href_new_ticket(@_);
+sub href_ticket {
+ my($self, $ticketnum) = @_;
+ $self->baseurl. 'Ticket/Display.html?id='.$ticketnum;
}
-sub _href_ticket {
- my($self, $ticketnum) = @_;
- 'Ticket/Display.html?id='.$ticketnum;
+sub queues {
+ my($self) = @_;
+
+ my $sql = "select id, name from queues where disabled = 0";
+ my $sth = $dbh->prepare($sql) or die $dbh->errstr. " preparing $sql";
+ $sth->execute() or die $sth->errstr. " executing $sql";
+
+ map { $_->[0] => $_->[1] } @{ $sth->fetchall_arrayref([]) };
+
}
-sub href_ticket {
- my $self = shift;
- $self->baseurl. $self->_href_ticket(@_);
+sub queue {
+ my($self, $queueid) = @_;
+
+ my $sql = "select name from queues where id = ?";
+ my $sth = $dbh->prepare($sql) or die $dbh->errstr. " preparing $sql";
+ $sth->execute($queueid) or die $sth->errstr. " executing $sql";
+
+ $sth->fetchrow_arrayref->[0];
+
}
sub baseurl {
Index: RT_Internal.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/TicketSystem/RT_Internal.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- RT_Internal.pm 1 Jun 2005 20:31:56 -0000 1.7
+++ RT_Internal.pm 15 Oct 2005 11:29:53 -0000 1.8
@@ -16,16 +16,6 @@
)";
}
-sub num_customer_tickets {
- my( $self, $custnum, $priority ) = ( shift, shift, shift );
- $self->SUPER::num_customer_tickets( $custnum, $priority, dbh );
-}
-
-sub customer_tickets {
- my( $self, $custnum, $limit, $priority ) = ( shift, shift, shift, shift );
- $self->SUPER::customer_tickets( $custnum, $limit, $priority, dbh );
-}
-
sub baseurl {
#my $self = shift;
if ( $RT::URI::freeside::URL ) {
More information about the freeside-commits
mailing list