diff options
author | ivan <ivan> | 2002-03-23 16:16:00 +0000 |
---|---|---|
committer | ivan <ivan> | 2002-03-23 16:16:00 +0000 |
commit | 8fe83dcb8807a86209625a5aab7e574073f0a907 (patch) | |
tree | 95f5de468804a2266fbfe9b5cdb9472b280df430 /FS | |
parent | 4fb679b29788a552a1ce33a0cdf293d648e797bc (diff) |
group editing seems to be working... everything except defaults... oh and
export...
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/part_export.pm | 8 | ||||
-rw-r--r-- | FS/FS/queue.pm | 44 | ||||
-rw-r--r-- | FS/FS/svc_acct.pm | 76 |
3 files changed, 103 insertions, 25 deletions
diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index 3f184be07..9aedd9f7a 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -505,9 +505,11 @@ sub _export_replace { } my @del = grep { !exists $new{$_} } keys %old; - my $error = $self->sqlradius_queue( $new->svcnum, 'sqlradius_attrib_delete', - $table, $new->username, @del ); - return $error if $error; + if ( @del ) { + my $error = $self->sqlradius_queue( $new->svcnum, 'attrib_delete', + $table, $new->username, @del ); + return $error if $error; + } } ''; diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm index a6d78e143..7a38a6eef 100644 --- a/FS/FS/queue.pm +++ b/FS/FS/queue.pm @@ -222,7 +222,7 @@ sub cust_svc { qsearchs('cust_svc', { 'svcnum' => $self->svcnum } ); } -=item joblisting HASHREF +=item joblisting HASHREF NOACTIONS =cut @@ -232,21 +232,24 @@ sub joblisting { use Date::Format; use FS::CGI; + my @queue = qsearch( 'queue', $hashref ); + return '' unless scalar(@queue); + my $html = FS::CGI::table(). <<END; <TR> <TH COLSPAN=2>Job</TH> <TH>Args</TH> <TH>Date</TH> <TH>Status</TH> - <TH>Account</TH> - </TR> END + $html .= '<TH>Account</TH>' unless $hashref->{svcnum}; + $html .= '</TR>'; my $p = FS::CGI::popurl(2); foreach my $queue ( sort { $a->getfield('jobnum') <=> $b->getfield('jobnum') - } qsearch( 'queue', $hashref ) ) { - my $hashref = $queue->hashref; + } @queue ) { + my $queue_hashref = $queue->hashref; my $jobnum = $queue->jobnum; my $args = join(' ', $queue->args); my $date = time2str( "%a %b %e %T %Y", $queue->_date ); @@ -258,26 +261,31 @@ END qq! <A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=del">remove</A> )!; } my $cust_svc = $queue->cust_svc; - my $account; - if ( $cust_svc ) { - my $table = $cust_svc->part_svc->svcdb; - my $label = ( $cust_svc->label )[1]; - $account = qq!<A HREF="../view/$table.cgi?!. $queue->svcnum. - qq!">$label</A>!; - } else { - $account = ''; - } + $html .= <<END; <TR> <TD>$jobnum</TD> - <TD>$hashref->{job}</TD> + <TD>$queue_hashref->{job}</TD> <TD>$args</TD> <TD>$date</TD> <TD>$status</TD> - <TD>$account</TD> - </TR> END + unless ( $hashref->{svcnum} ) { + my $account; + if ( $cust_svc ) { + my $table = $cust_svc->part_svc->svcdb; + my $label = ( $cust_svc->label )[1]; + $account = qq!<A HREF="../view/$table.cgi?!. $queue->svcnum. + qq!">$label</A>!; + } else { + $account = ''; + } + $html .= "<TD>$account</TD>"; + } + + $html .= '</TR>'; + } $html .= '</TABLE>'; @@ -290,7 +298,7 @@ END =head1 VERSION -$Id: queue.pm,v 1.7 2002-03-07 14:10:10 ivan Exp $ +$Id: queue.pm,v 1.8 2002-03-23 16:16:00 ivan Exp $ =head1 BUGS diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 9da5a6671..bb6b9959b 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -192,8 +192,6 @@ FS::svc_Common. The following fields are currently supported: =item radius_I<Radius_Attribute> - I<Radius-Attribute> -=item domsvc - service number of svc_domain with which to associate - =back =head1 METHODS @@ -216,6 +214,10 @@ otherwise returns false. The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be defined. An FS::cust_svc record will be created and inserted. +The additional field I<usergroup> can optionally be defined; if so it should +contain an arrayref of group names. See L<FS::radius_usergroup>. (used in +sqlradius export only) + If the configuration value (see L<FS::Conf>) shellmachine exists, and the username, uid, and dir fields are defined, the command(s) specified in the shellmachine-useradd configuration are added to the job queue (see @@ -289,6 +291,20 @@ sub insert { return $error; } + if ( $self->usergroup ) { + foreach my $groupname ( @{$self->usergroup} ) { + my $radius_usergroup = new FS::radius_usergroup ( { + svcnum => $self->svcnum, + groupname => $groupname, + } ); + my $error = $radius_usergroup->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + } + #new-style exports! unless ( $noexport_hack ) { foreach my $part_export ( $self->cust_svc->part_svc->part_export ) { @@ -561,6 +577,16 @@ sub delete { } } + foreach my $radius_usergroup ( + qsearch('radius_usergroup', { 'svcnum' => $self->svcnum } ) + ) { + my $error = $radius_usergroup->delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + my $error = $self->SUPER::delete; if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -700,6 +726,10 @@ sub vpopmail_delete { Replaces OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false. +The additional field I<usergroup> can optionally be defined; if so it should +contain an arrayref of group names. See L<FS::radius_usergroup>. (used in +sqlradius export only) + If the configuration value (see L<FS::Conf>) shellmachine exists, and the dir field has changed, the command(s) specified in the shellmachine-usermod configuraiton file are added to the job queue (see L<FS::queue> and @@ -760,6 +790,40 @@ sub replace { return $error if $error; } + $old->usergroup( [ $old->radius_groups ] ); + + if ( $new->usergroup ) { + + foreach my $groupname ( @{$old->usergroup} ) { + if ( grep { $groupname eq $_ } @{$new->usergroup} ) { + $new->usergroup( [ grep { $groupname ne $_ } @{$new->usergroup} ] ); + next; + } + my $radius_usergroup = qsearch('radius_usergroup', { + svcnum => $old->svcnum, + groupname => $groupname, + } ); + my $error = $radius_usergroup->delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "error deleting radius_usergroup $groupname: $error"; + } + } + + foreach my $groupname ( @{$new->usergroup} ) { + my $radius_usergroup = new FS::radius_usergroup ( { + svcnum => $new->svcnum, + groupname => $groupname, + } ); + my $error = $radius_usergroup->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "error adding radius_usergroup $groupname: $error"; + } + } + + } + #new-style exports! unless ( $noexport_hack ) { foreach my $part_export ( $new->cust_svc->part_svc->part_export ) { @@ -1299,7 +1363,7 @@ sub radius_groups { =head1 SUBROUTINES -=item radius_usergroup_selector GROUPS_ARRAYREF +=item radius_usergroup_selector GROUPS_ARRAYREF [ SELECTNAME ] =cut @@ -1323,6 +1387,7 @@ sub radius_usergroup_selector { var optionName = new Option(myvalue,myvalue,false,true); var length = object.$selectname.length; object.$selectname.options[length] = optionName; + object.${selectname}_add.value = ""; } </SCRIPT> <SELECT MULTIPLE NAME="$selectname"> @@ -1330,9 +1395,12 @@ END foreach my $group ( @all_groups ) { $html .= '<OPTION'; - $html .= ' SELECTED' if $sel_groups{$group}; + $html .= ' SELECTED' if $sel_groups{$group}--; $html .= ">$group</OPTION>\n"; } + foreach my $group ( grep { $sel_groups{$_} } keys %sel_groups ) { + $html .= "<OPTION SELECTED>$group</OPTION>\n"; + }; $html .= '</SELECT>'; $html .= qq!<BR><INPUT TYPE="text" NAME="${selectname}_add">!. |