=item radius_I<Radius_Attribute> - I<Radius-Attribute>
-=item domsvc - service number of svc_domain with which to associate
-
=back
=head1 METHODS
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
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
- my $amount = 0;
-
$error = $self->check;
return $error if $error;
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 ) {
}
}
+ foreach my $radius_usergroup (
+ qsearch('radius_usergroup', { 'svcnum' => $self->svcnum } )
+ ) {
+ my $error = $radius_usergroup->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ my $part_svc = $self->cust_svc->part_svc;
+
my $error = $self->SUPER::delete;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
#new-style exports!
unless ( $noexport_hack ) {
- foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
+ foreach my $part_export ( $part_svc->part_export ) {
my $error = $part_export->export_delete($self);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
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
return $error if $error;
}
+ $old->usergroup( [ $old->radius_groups ] );
+ if ( $new->usergroup ) {
+ #(sorta) false laziness with FS::part_export::sqlradius::_export_replace
+ my @newgroups = @{$new->usergroup};
+ foreach my $oldgroup ( @{$old->usergroup} ) {
+ if ( grep { $oldgroup eq $_ } @newgroups ) {
+ @newgroups = grep { $oldgroup ne $_ } @newgroups;
+ next;
+ }
+ my $radius_usergroup = qsearchs('radius_usergroup', {
+ svcnum => $old->svcnum,
+ groupname => $oldgroup,
+ } );
+ my $error = $radius_usergroup->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "error deleting radius_usergroup $oldgroup: $error";
+ }
+ }
+
+ foreach my $newgroup ( @newgroups ) {
+ my $radius_usergroup = new FS::radius_usergroup ( {
+ svcnum => $new->svcnum,
+ groupname => $newgroup,
+ } );
+ my $error = $radius_usergroup->insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "error adding radius_usergroup $newgroup: $error";
+ }
+ }
+
+ }
+
#new-style exports!
unless ( $noexport_hack ) {
foreach my $part_export ( $new->cust_svc->part_svc->part_export ) {
return $x unless ref($x);
my $part_svc = $x;
+ if ( $part_svc->part_svc_column('usergroup')->columnflag eq "F" ) {
+ $self->usergroup(
+ [ split(',', $part_svc->part_svc_column('usergroup')->columnvalue) ] );
+ }
+
my $error = $self->ut_numbern('svcnum')
|| $self->ut_number('domsvc')
;
=head1 SUBROUTINES
-=item radius_usergroup_selector GROUPS_ARRAYREF
+=item radius_usergroup_selector GROUPS_ARRAYREF [ SELECTNAME ]
=cut
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">
foreach my $group ( @all_groups ) {
$html .= '<OPTION';
- $html .= ' SELECTED' if $sel_groups{$group};
+ if ( $sel_groups{$group} ) {
+ $html .= ' SELECTED';
+ $sel_groups{$group} = 0;
+ }
$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">!.