From: ivan Date: Sat, 23 Mar 2002 16:16:00 +0000 (+0000) Subject: group editing seems to be working... everything except defaults... oh and X-Git-Tag: freeside_1_4_0_pre12~133 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=8fe83dcb8807a86209625a5aab7e574073f0a907 group editing seems to be working... everything except defaults... oh and export... --- 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(). < Job Args Date Status - Account - END + $html .= 'Account' unless $hashref->{svcnum}; + $html .= ''; 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! remove )!; } 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!$label!; - } else { - $account = ''; - } + $html .= < $jobnum - $hashref->{job} + $queue_hashref->{job} $args $date $status - $account - END + unless ( $hashref->{svcnum} ) { + my $account; + if ( $cust_svc ) { + my $table = $cust_svc->part_svc->svcdb; + my $label = ( $cust_svc->label )[1]; + $account = qq!$label!; + } else { + $account = ''; + } + $html .= "$account"; + } + + $html .= ''; + } $html .= ''; @@ -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 - I -=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) should be defined. An FS::cust_svc record will be created and inserted. +The additional field I can optionally be defined; if so it should +contain an arrayref of group names. See L. (used in +sqlradius export only) + If the configuration value (see L) 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 can optionally be defined; if so it should +contain an arrayref of group names. See L. (used in +sqlradius export only) + If the configuration value (see L) 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 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 = ""; } !. diff --git a/httemplate/edit/process/svc_acct.cgi b/httemplate/edit/process/svc_acct.cgi index 5e8a16f4a..950a8602f 100755 --- a/httemplate/edit/process/svc_acct.cgi +++ b/httemplate/edit/process/svc_acct.cgi @@ -20,12 +20,15 @@ if ( $cgi->param('_password') eq '*HIDDEN*' ) { $cgi->param('_password',$old->getfield('_password')); } +#unmunge usergroup +$cgi->param('usergroup', [ $cgi->param('radius_usergroup') ] ); + my $new = new FS::svc_acct ( { map { $_, scalar($cgi->param($_)); #} qw(svcnum pkgnum svcpart username _password popnum uid gid finger dir # shell quota slipip) - } ( fields('svc_acct'), qw( pkgnum svcpart ) ) + } ( fields('svc_acct'), qw( pkgnum svcpart usergroup ) ) } ); my $error; diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index 6846b5c93..8a80d4c72 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -4,7 +4,7 @@ my $conf = new FS::Conf; my @shells = $conf->config('shells'); -my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct); +my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups); if ( $cgi->param('error') ) { $svc_acct = new FS::svc_acct ( { map { $_, scalar($cgi->param($_)) } fields('svc_acct') @@ -14,6 +14,7 @@ if ( $cgi->param('error') ) { $svcpart = $cgi->param('svcpart'); $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); die "No part_svc entry!" unless $part_svc; + @groups = $cgi->param('radius_usergroup'); } else { my($query) = $cgi->keywords; if ( $query =~ /^(\d+)$/ ) { #editing @@ -30,6 +31,8 @@ if ( $cgi->param('error') ) { $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); die "No part_svc entry!" unless $part_svc; + @groups = $svc_acct->radius_groups; + } else { #adding $svc_acct = new FS::svc_acct({}); @@ -63,6 +66,8 @@ if ( $cgi->param('error') ) { ); } + #SET DEFAULT GROUP(S) FROM PART_SVC!!!! + } } my $action = $svcnum ? 'Edit' : 'Add'; @@ -100,7 +105,7 @@ print qq!Error: !, $cgi->param('error'), print 'Service # '. ( $svcnum ? "$svcnum" : " (NEW)" ). '
'. 'Service: '. $part_svc->svc. '

'. < +
@@ -240,7 +245,7 @@ foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) { } print 'RADIUS groups'. - &FS::svc_acct::radius_usergroup_selector( [ $svc_acct->radius_groups ] ). + &FS::svc_acct::radius_usergroup_selector( \@groups ). ''; #submit