X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fqueue.pm;h=9bbaf3431202f47b94870acfb45822909aeb3d1c;hb=79437a9f5d2e0fc41b40b2e5dd985181af3100cc;hp=99e349c61e9ede437caf2c6b748e6c6b56be7615;hpb=624b2d44625f69d71175c3348cae635d580c890b;p=freeside.git diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm index 99e349c61..9bbaf3431 100644 --- a/FS/FS/queue.pm +++ b/FS/FS/queue.pm @@ -12,7 +12,7 @@ use FS::Record qw( qsearch qsearchs dbh ); use FS::queue_arg; use FS::queue_depend; use FS::cust_svc; -use FS::CGI qw (rooturl); +use FS::CGI qw(rooturl); @ISA = qw(FS::Record); @EXPORT_OK = qw( joblisting ); @@ -67,6 +67,20 @@ Job status (new, locked, or failed) Freeform text status message +=cut + +sub statustext { + my $self = shift; + if ( defined ( $_[0] ) ) { + $self->SUPER::statustext(@_); + } else { + my $value = $self->SUPER::statustext(); + my $rooturl = rooturl(); + $value =~ s/%%%ROOTURL%%%/$rooturl/g; + $value; + } +} + =item _date UNIX timestamp @@ -84,6 +98,10 @@ Optional link to customer (see L). Secure flag, 'Y' indicates that when using encryption, the job needs to be run on a machine with the private key. +=item usernum + +For access_user that created the job + =cut =back @@ -138,6 +156,8 @@ sub insert { $self->custnum( $args{'custnum'} ) if $args{'custnum'}; + $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum; + my $error = $self->SUPER::insert; if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -249,6 +269,7 @@ sub check { || $self->ut_enum('status',['', qw( new locked failed done )]) || $self->ut_anything('statustext') || $self->ut_numbern('svcnum') + || $self->ut_foreign_keyn('usernum', 'access_user', 'usernum') ; return $error if $error; @@ -363,7 +384,7 @@ If there is an error, returns the error, otherwise returns false. use vars qw($_update_statustext_dbh); sub update_statustext { my( $self, $statustext ) = @_; - return '' if $statustext eq $self->statustext; + return '' if $statustext eq $self->get('statustext'); #avoid rooturl expansion warn "updating statustext for $self to $statustext" if $DEBUG; $_update_statustext_dbh ||= myconnect; @@ -374,7 +395,7 @@ sub update_statustext { $sth->execute($statustext, $self->jobnum) or return $sth->errstr; $_update_statustext_dbh->commit or die $_update_statustext_dbh->errstr; - $self->statustext($statustext); + $self->set('statustext', $statustext); #avoid rooturl expansion ''; #my $new = new FS::queue { $self->hash }; @@ -385,6 +406,20 @@ sub update_statustext { #''; } +=item access_user + +Returns FS::access_user object (if any) associated with this user. + +Returns nothing if not found. + +=cut + +sub access_user { + my $self = shift; + my $usernum = $self->usernum || return (); + return qsearchs('access_user',{ 'usernum' => $usernum }) || (); +} + =back =head1 SUBROUTINES