first part of ACL and re-skinning work and some other small stuff
[freeside.git] / FS / FS / UI / Web.pm
index 4a324ec..10ddbf3 100644 (file)
@@ -131,6 +131,7 @@ package FS::UI::Web::JSRPC;
 
 use strict;
 use vars qw($DEBUG);
+use Carp;
 use Storable qw(nfreeze);
 use MIME::Base64;
 use JSON;
@@ -138,7 +139,7 @@ use FS::UID;
 use FS::Record qw(qsearchs);
 use FS::queue;
 
-$DEBUG = 1;
+$DEBUG = 0;
 
 sub new {
         my $class = shift;
@@ -150,7 +151,7 @@ sub new {
 
         bless $self, $class;
 
-        die "CGI object required as second argument" unless $self->{'cgi'};
+        croak "CGI object required as second argument" unless $self->{'cgi'};
 
         return $self;
 }
@@ -164,6 +165,9 @@ sub process {
   # XXX this should parse JSON foo and build a proper data structure
   my @args = $cgi->param('arg');
 
+  #work around konqueror bug!
+  @args = map { s/\x00$//; $_; } @args;
+
   my $sub = $cgi->param('sub'); #????
 
   warn "FS::UI::Web::JSRPC::process:\n".
@@ -180,6 +184,10 @@ sub process {
 
     $self->job_status(@args);
 
+  } else {
+
+    die "unknown sub $sub";
+
   }
 
 }
@@ -224,11 +232,19 @@ sub start_job {
   my $error = $job->insert( '_JOB', encode_base64(nfreeze(\%param)) );
 
   if ( $error ) {
+
+    warn "job not inserted: $error\n"
+      if $DEBUG;
+
     $error;  #this doesn't seem to be handled well,
              # will trigger "illegal jobnum" below?
              # (should never be an error inserting the job, though, only thing
              #  would be Pg f%*kage)
   } else {
+
+    warn "job inserted successfully with jobnum ". $job->jobnum. "\n"
+      if $DEBUG;
+
     $job->jobnum;
   }
   
@@ -249,7 +265,7 @@ sub job_status {
   my @return;
   if ( $job && $job->status ne 'failed' ) {
     @return = ( 'progress', $job->statustext );
-  } elsif ( !$job ) { #handle job gone case : job sucessful
+  } elsif ( !$job ) { #handle job gone case : job successful
                       # so close popup, redirect parent window...
     @return = ( 'complete' );
   } else {