4 use vars qw( @ISA $noexport_hack $conf
5 $dir_prefix @shells $usernamemin
6 $usernamemax $passwordmin $passwordmax
7 $username_ampersand $username_letter $username_letterfirst
8 $username_noperiod $username_nounderscore $username_nodash
15 use FS::UID qw( datasrc );
17 use FS::Record qw( qsearch qsearchs fields dbh );
23 use FS::cust_main_invoice;
27 use FS::radius_usergroup;
30 use FS::Msgcat qw(gettext);
32 @ISA = qw( FS::svc_Common );
34 #ask FS::UID to run this stuff for us later
35 $FS::UID::callback{'FS::svc_acct'} = sub {
37 $dir_prefix = $conf->config('home');
38 @shells = $conf->config('shells');
39 $usernamemin = $conf->config('usernamemin') || 2;
40 $usernamemax = $conf->config('usernamemax');
41 $passwordmin = $conf->config('passwordmin') || 6;
42 $passwordmax = $conf->config('passwordmax') || 8;
43 $username_letter = $conf->exists('username-letter');
44 $username_letterfirst = $conf->exists('username-letterfirst');
45 $username_noperiod = $conf->exists('username-noperiod');
46 $username_nounderscore = $conf->exists('username-nounderscore');
47 $username_nodash = $conf->exists('username-nodash');
48 $username_uppercase = $conf->exists('username-uppercase');
49 $username_ampersand = $conf->exists('username-ampersand');
50 $mydomain = $conf->config('domain');
52 $dirhash = $conf->config('dirhash') || 0;
55 @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
56 @pw_set = ( 'a'..'z', 'A'..'Z', '0'..'9', '(', ')', '#', '!', '.', ',' );
60 my ( $hashref, $cache ) = @_;
61 if ( $hashref->{'svc_acct_svcnum'} ) {
62 $self->{'_domsvc'} = FS::svc_domain->new( {
63 'svcnum' => $hashref->{'domsvc'},
64 'domain' => $hashref->{'svc_acct_domain'},
65 'catchall' => $hashref->{'svc_acct_catchall'},
72 FS::svc_acct - Object methods for svc_acct records
78 $record = new FS::svc_acct \%hash;
79 $record = new FS::svc_acct { 'column' => 'value' };
81 $error = $record->insert;
83 $error = $new_record->replace($old_record);
85 $error = $record->delete;
87 $error = $record->check;
89 $error = $record->suspend;
91 $error = $record->unsuspend;
93 $error = $record->cancel;
95 %hash = $record->radius;
97 %hash = $record->radius_reply;
99 %hash = $record->radius_check;
101 $domain = $record->domain;
103 $svc_domain = $record->svc_domain;
105 $email = $record->email;
107 $seconds_since = $record->seconds_since($timestamp);
111 An FS::svc_acct object represents an account. FS::svc_acct inherits from
112 FS::svc_Common. The following fields are currently supported:
116 =item svcnum - primary key (assigned automatcially for new accounts)
120 =item _password - generated if blank
122 =item sec_phrase - security phrase
124 =item popnum - Point of presence (see L<FS::svc_acct_pop>)
132 =item dir - set automatically if blank (and uid is not)
136 =item quota - (unimplementd)
138 =item slipip - IP address
142 =item domsvc - svcnum from svc_domain
144 =item radius_I<Radius_Attribute> - I<Radius-Attribute>
154 Creates a new account. To add the account to the database, see L<"insert">.
158 sub table { 'svc_acct'; }
162 Adds this account to the database. If there is an error, returns the error,
163 otherwise returns false.
165 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be
166 defined. An FS::cust_svc record will be created and inserted.
168 The additional field I<usergroup> can optionally be defined; if so it should
169 contain an arrayref of group names. See L<FS::radius_usergroup>. (used in
170 sqlradius export only)
172 (TODOC: L<FS::queue> and L<freeside-queued>)
174 (TODOC: new exports! $noexport_hack)
182 local $SIG{HUP} = 'IGNORE';
183 local $SIG{INT} = 'IGNORE';
184 local $SIG{QUIT} = 'IGNORE';
185 local $SIG{TERM} = 'IGNORE';
186 local $SIG{TSTP} = 'IGNORE';
187 local $SIG{PIPE} = 'IGNORE';
189 my $oldAutoCommit = $FS::UID::AutoCommit;
190 local $FS::UID::AutoCommit = 0;
193 $error = $self->check;
194 return $error if $error;
196 #no, duplicate checking just got a whole lot more complicated
198 #return gettext('username_in_use'). ": ". $self->username
199 # if qsearchs( 'svc_acct', { 'username' => $self->username,
200 # 'domsvc' => $self->domsvc,
203 my @dup_user = qsearch( 'svc_acct', { 'username' => $self->username } );
204 my @dup_userdomain = qsearchs( 'svc_acct', { 'username' => $self->username,
205 'domsvc' => $self->domsvc } );
207 if ( @dup_user || @dup_userdomain ) {
208 my $exports = FS::part_export::export_info('svc_acct');
209 my( %conflict_user_svcpart, %conflict_userdomain_svcpart );
211 foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
213 #this will catch to the same exact export
214 my @svcparts = map { $_->svcpart }
215 qsearch('export_svc', { 'exportnum' => $part_export->exportnum });
217 #this will catch exports w/same exporthost+type ???
218 #my @other_part_export = qsearch('part_export', {
219 # 'machine' => $part_export->machine,
220 # 'exporttype' => $part_export->exporttype,
222 #foreach my $other_part_export ( @other_part_export ) {
223 # push @svcparts, map { $_->svcpart }
224 # qsearch('export_svc', { 'exportnum' => $part_export->exportnum });
227 my $nodomain = $exports->{$part_export->exporttype}{'nodomain'};
228 if ( $nodomain =~ /^Y/i ) {
229 $conflict_user_svcpart{$_} = $part_export->exportnum
232 $conflict_userdomain_svcpart{$_} = $part_export->exportnum
237 foreach my $dup_user ( @dup_user ) {
238 my $dup_svcpart = $dup_user->cust_svc->svcpart;
239 if ( exists($conflict_user_svcpart{$dup_svcpart}) ) {
240 return "duplicate username: conflicts with svcnum ". $dup_user->svcnum.
241 " via exportnum ". $conflict_user_svcpart{$dup_svcpart};
245 foreach my $dup_userdomain ( @dup_userdomain ) {
246 my $dup_svcpart = $dup_userdomain->cust_svc->svcpart;
247 if ( exists($conflict_user_svcpart{$dup_svcpart}) ) {
248 return "duplicate username\@domain: conflicts with svcnum ".
249 $dup_userdomain->svcnum. " via exportnum ".
250 $conflict_user_svcpart{$dup_svcpart};
256 #see? i told you it was more complicated
258 if ( $self->svcnum ) {
259 my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$self->svcnum});
260 unless ( $cust_svc ) {
261 $dbh->rollback if $oldAutoCommit;
262 return "no cust_svc record found for svcnum ". $self->svcnum;
264 $self->pkgnum($cust_svc->pkgnum);
265 $self->svcpart($cust_svc->svcpart);
268 my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
269 return "Unknown svcpart" unless $part_svc;
271 if $part_svc->part_svc_column('uid')->columnflag ne 'F'
272 && qsearchs( 'svc_acct', { 'uid' => $self->uid } )
273 && $self->username !~ /^(hyla)?fax$/
274 && $self->username !~ /^toor$/ #FreeBSD
277 $error = $self->SUPER::insert;
279 $dbh->rollback if $oldAutoCommit;
283 if ( $self->usergroup ) {
284 foreach my $groupname ( @{$self->usergroup} ) {
285 my $radius_usergroup = new FS::radius_usergroup ( {
286 svcnum => $self->svcnum,
287 groupname => $groupname,
289 my $error = $radius_usergroup->insert;
291 $dbh->rollback if $oldAutoCommit;
297 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
303 Deletes this account from the database. If there is an error, returns the
304 error, otherwise returns false.
306 The corresponding FS::cust_svc record will be deleted as well.
308 (TODOC: new exports! $noexport_hack)
315 if ( defined( $FS::Record::dbdef->table('svc_acct_sm') ) ) {
316 return "Can't delete an account which has (svc_acct_sm) mail aliases!"
317 if $self->uid && qsearch( 'svc_acct_sm', { 'domuid' => $self->uid } );
320 return "Can't delete an account which is a (svc_forward) source!"
321 if qsearch( 'svc_forward', { 'srcsvc' => $self->svcnum } );
323 return "Can't delete an account which is a (svc_forward) destination!"
324 if qsearch( 'svc_forward', { 'dstsvc' => $self->svcnum } );
326 return "Can't delete an account with (svc_www) web service!"
327 if qsearch( 'svc_www', { 'usersvc' => $self->usersvc } );
329 # what about records in session ? (they should refer to history table)
331 local $SIG{HUP} = 'IGNORE';
332 local $SIG{INT} = 'IGNORE';
333 local $SIG{QUIT} = 'IGNORE';
334 local $SIG{TERM} = 'IGNORE';
335 local $SIG{TSTP} = 'IGNORE';
336 local $SIG{PIPE} = 'IGNORE';
338 my $oldAutoCommit = $FS::UID::AutoCommit;
339 local $FS::UID::AutoCommit = 0;
342 foreach my $cust_main_invoice (
343 qsearch( 'cust_main_invoice', { 'dest' => $self->svcnum } )
345 unless ( defined($cust_main_invoice) ) {
346 warn "WARNING: something's wrong with qsearch";
349 my %hash = $cust_main_invoice->hash;
350 $hash{'dest'} = $self->email;
351 my $new = new FS::cust_main_invoice \%hash;
352 my $error = $new->replace($cust_main_invoice);
354 $dbh->rollback if $oldAutoCommit;
359 foreach my $svc_domain (
360 qsearch( 'svc_domain', { 'catchall' => $self->svcnum } )
362 my %hash = new FS::svc_domain->hash;
363 $hash{'catchall'} = '';
364 my $new = new FS::svc_domain \%hash;
365 my $error = $new->replace($svc_domain);
367 $dbh->rollback if $oldAutoCommit;
372 foreach my $radius_usergroup (
373 qsearch('radius_usergroup', { 'svcnum' => $self->svcnum } )
375 my $error = $radius_usergroup->delete;
377 $dbh->rollback if $oldAutoCommit;
382 my $part_svc = $self->cust_svc->part_svc;
384 my $error = $self->SUPER::delete;
386 $dbh->rollback if $oldAutoCommit;
390 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
394 =item replace OLD_RECORD
396 Replaces OLD_RECORD with this one in the database. If there is an error,
397 returns the error, otherwise returns false.
399 The additional field I<usergroup> can optionally be defined; if so it should
400 contain an arrayref of group names. See L<FS::radius_usergroup>. (used in
401 sqlradius export only)
406 my ( $new, $old ) = ( shift, shift );
409 return "Username in use"
410 if $old->username ne $new->username &&
411 qsearchs( 'svc_acct', { 'username' => $new->username,
412 'domsvc' => $new->domsvc,
415 #no warnings 'numeric'; #alas, a 5.006-ism
417 return "Can't change uid!" if $old->uid != $new->uid;
420 #change homdir when we change username
421 $new->setfield('dir', '') if $old->username ne $new->username;
423 local $SIG{HUP} = 'IGNORE';
424 local $SIG{INT} = 'IGNORE';
425 local $SIG{QUIT} = 'IGNORE';
426 local $SIG{TERM} = 'IGNORE';
427 local $SIG{TSTP} = 'IGNORE';
428 local $SIG{PIPE} = 'IGNORE';
430 my $oldAutoCommit = $FS::UID::AutoCommit;
431 local $FS::UID::AutoCommit = 0;
434 $error = $new->SUPER::replace($old);
436 $dbh->rollback if $oldAutoCommit;
437 return $error if $error;
440 $old->usergroup( [ $old->radius_groups ] );
441 if ( $new->usergroup ) {
442 #(sorta) false laziness with FS::part_export::sqlradius::_export_replace
443 my @newgroups = @{$new->usergroup};
444 foreach my $oldgroup ( @{$old->usergroup} ) {
445 if ( grep { $oldgroup eq $_ } @newgroups ) {
446 @newgroups = grep { $oldgroup ne $_ } @newgroups;
449 my $radius_usergroup = qsearchs('radius_usergroup', {
450 svcnum => $old->svcnum,
451 groupname => $oldgroup,
453 my $error = $radius_usergroup->delete;
455 $dbh->rollback if $oldAutoCommit;
456 return "error deleting radius_usergroup $oldgroup: $error";
460 foreach my $newgroup ( @newgroups ) {
461 my $radius_usergroup = new FS::radius_usergroup ( {
462 svcnum => $new->svcnum,
463 groupname => $newgroup,
465 my $error = $radius_usergroup->insert;
467 $dbh->rollback if $oldAutoCommit;
468 return "error adding radius_usergroup $newgroup: $error";
474 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
480 Suspends this account by prefixing *SUSPENDED* to the password. If there is an
481 error, returns the error, otherwise returns false.
483 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
489 my %hash = $self->hash;
490 unless ( $hash{_password} =~ /^\*SUSPENDED\* /
491 || $hash{_password} eq '*'
493 $hash{_password} = '*SUSPENDED* '.$hash{_password};
494 my $new = new FS::svc_acct ( \%hash );
495 my $error = $new->replace($self);
496 return $error if $error;
499 $self->SUPER::suspend;
504 Unsuspends this account by removing *SUSPENDED* from the password. If there is
505 an error, returns the error, otherwise returns false.
507 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
513 my %hash = $self->hash;
514 if ( $hash{_password} =~ /^\*SUSPENDED\* (.*)$/ ) {
515 $hash{_password} = $1;
516 my $new = new FS::svc_acct ( \%hash );
517 my $error = $new->replace($self);
518 return $error if $error;
521 $self->SUPER::unsuspend;
526 Just returns false (no error) for now.
528 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
532 Checks all fields to make sure this is a valid service. If there is an error,
533 returns the error, otherwise returns false. Called by the insert and replace
536 Sets any fixed values; see L<FS::part_svc>.
543 my($recref) = $self->hashref;
545 my $x = $self->setfixed;
546 return $x unless ref($x);
549 if ( $part_svc->part_svc_column('usergroup')->columnflag eq "F" ) {
551 [ split(',', $part_svc->part_svc_column('usergroup')->columnvalue) ] );
554 my $error = $self->ut_numbern('svcnum')
555 || $self->ut_number('domsvc')
556 || $self->ut_textn('sec_phrase')
558 return $error if $error;
560 my $ulen = $usernamemax || $self->dbdef_table->column('username')->length;
561 if ( $username_uppercase ) {
562 $recref->{username} =~ /^([a-z0-9_\-\.\&]{$usernamemin,$ulen})$/i
563 or return gettext('illegal_username'). " ($usernamemin-$ulen): ". $recref->{username};
564 $recref->{username} = $1;
566 $recref->{username} =~ /^([a-z0-9_\-\.\&]{$usernamemin,$ulen})$/
567 or return gettext('illegal_username'). " ($usernamemin-$ulen): ". $recref->{username};
568 $recref->{username} = $1;
571 if ( $username_letterfirst ) {
572 $recref->{username} =~ /^[a-z]/ or return gettext('illegal_username');
573 } elsif ( $username_letter ) {
574 $recref->{username} =~ /[a-z]/ or return gettext('illegal_username');
576 if ( $username_noperiod ) {
577 $recref->{username} =~ /\./ and return gettext('illegal_username');
579 if ( $username_nounderscore ) {
580 $recref->{username} =~ /_/ and return gettext('illegal_username');
582 if ( $username_nodash ) {
583 $recref->{username} =~ /\-/ and return gettext('illegal_username');
585 unless ( $username_ampersand ) {
586 $recref->{username} =~ /\&/ and return gettext('illegal_username');
589 $recref->{popnum} =~ /^(\d*)$/ or return "Illegal popnum: ".$recref->{popnum};
590 $recref->{popnum} = $1;
591 return "Unknown popnum" unless
592 ! $recref->{popnum} ||
593 qsearchs('svc_acct_pop',{'popnum'=> $recref->{popnum} } );
595 unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
597 $recref->{uid} =~ /^(\d*)$/ or return "Illegal uid";
598 $recref->{uid} = $1 eq '' ? $self->unique('uid') : $1;
600 $recref->{gid} =~ /^(\d*)$/ or return "Illegal gid";
601 $recref->{gid} = $1 eq '' ? $recref->{uid} : $1;
602 #not all systems use gid=uid
603 #you can set a fixed gid in part_svc
605 return "Only root can have uid 0"
606 if $recref->{uid} == 0
607 && $recref->{username} ne 'root'
608 && $recref->{username} ne 'toor';
610 # $error = $self->ut_textn('finger');
611 # return $error if $error;
612 $self->getfield('finger') =~
613 /^([\w \t\!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\*\<\>]*)$/
614 or return "Illegal finger: ". $self->getfield('finger');
615 $self->setfield('finger', $1);
617 $recref->{dir} =~ /^([\/\w\-\.\&]*)$/
618 or return "Illegal directory";
620 return "Illegal directory"
621 if $recref->{dir} =~ /(^|\/)\.+(\/|$)/; #no .. component
622 return "Illegal directory"
623 if $recref->{dir} =~ /\&/ && ! $username_ampersand;
624 unless ( $recref->{dir} ) {
625 $recref->{dir} = $dir_prefix . '/';
626 if ( $dirhash > 0 ) {
627 for my $h ( 1 .. $dirhash ) {
628 $recref->{dir} .= substr($recref->{username}, $h-1, 1). '/';
630 } elsif ( $dirhash < 0 ) {
631 for my $h ( reverse $dirhash .. -1 ) {
632 $recref->{dir} .= substr($recref->{username}, $h, 1). '/';
635 $recref->{dir} .= $recref->{username};
639 unless ( $recref->{username} eq 'sync' ) {
640 if ( grep $_ eq $recref->{shell}, @shells ) {
641 $recref->{shell} = (grep $_ eq $recref->{shell}, @shells)[0];
643 return "Illegal shell \`". $self->shell. "\'; ".
644 $conf->dir. "/shells contains: @shells";
647 $recref->{shell} = '/bin/sync';
650 $recref->{quota} =~ /^(\d*)$/ or return "Illegal quota (unimplemented)";
651 $recref->{quota} = $1;
654 $recref->{gid} ne '' ?
655 return "Can't have gid without uid" : ( $recref->{gid}='' );
656 $recref->{finger} ne '' ?
657 return "Can't have finger-name without uid" : ( $recref->{finger}='' );
658 $recref->{dir} ne '' ?
659 return "Can't have directory without uid" : ( $recref->{dir}='' );
660 $recref->{shell} ne '' ?
661 return "Can't have shell without uid" : ( $recref->{shell}='' );
662 $recref->{quota} ne '' ?
663 return "Can't have quota without uid" : ( $recref->{quota}='' );
666 unless ( $part_svc->part_svc_column('slipip')->columnflag eq 'F' ) {
667 unless ( $recref->{slipip} eq '0e0' ) {
668 $recref->{slipip} =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/
669 or return "Illegal slipip". $self->slipip;
670 $recref->{slipip} = $1;
672 $recref->{slipip} = '0e0';
677 #arbitrary RADIUS stuff; allow ut_textn for now
678 foreach ( grep /^radius_/, fields('svc_acct') ) {
682 #generate a password if it is blank
683 $recref->{_password} = join('',map($pw_set[ int(rand $#pw_set) ], (0..7) ) )
684 unless ( $recref->{_password} );
686 #if ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([^\t\n]{4,16})$/ ) {
687 if ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([^\t\n]{$passwordmin,$passwordmax})$/ ) {
688 $recref->{_password} = $1.$3;
689 #uncomment this to encrypt password immediately upon entry, or run
690 #bin/crypt_pw in cron to give new users a window during which their
691 #password is available to techs, for faxing, etc. (also be aware of
693 #$recref->{password} = $1.
694 # crypt($3,$saltset[int(rand(64))].$saltset[int(rand(64))]
696 } elsif ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([\w\.\/\$]{13,34})$/ ) {
697 $recref->{_password} = $1.$3;
698 } elsif ( $recref->{_password} eq '*' ) {
699 $recref->{_password} = '*';
700 } elsif ( $recref->{_password} eq '!!' ) {
701 $recref->{_password} = '!!';
703 #return "Illegal password";
704 return gettext('illegal_password'). "$passwordmin-$passwordmax".
705 FS::Msgcat::_gettext('illegal_password_characters').
706 ": ". $recref->{_password};
714 Depriciated, use radius_reply instead.
719 carp "FS::svc_acct::radius depriciated, use radius_reply";
725 Returns key/value pairs, suitable for assigning to a hash, for any RADIUS
726 reply attributes of this record.
728 Note that this is now the preferred method for reading RADIUS attributes -
729 accessing the columns directly is discouraged, as the column names are
730 expected to change in the future.
739 my($column, $attrib) = ($1, $2);
740 #$attrib =~ s/_/\-/g;
741 ( $FS::raddb::attrib{lc($attrib)}, $self->getfield($column) );
742 } grep { /^radius_/ && $self->getfield($_) } fields( $self->table );
743 if ( $self->ip && $self->ip ne '0e0' ) {
744 $reply{'Framed-IP-Address'} = $self->ip;
751 Returns key/value pairs, suitable for assigning to a hash, for any RADIUS
752 check attributes of this record.
754 Note that this is now the preferred method for reading RADIUS attributes -
755 accessing the columns directly is discouraged, as the column names are
756 expected to change in the future.
762 ( 'Password' => $self->_password,
765 my($column, $attrib) = ($1, $2);
766 #$attrib =~ s/_/\-/g;
767 ( $FS::raddb::attrib{lc($attrib)}, $self->getfield($column) );
768 } grep { /^rc_/ && $self->getfield($_) } fields( $self->table )
774 Returns the domain associated with this account.
780 if ( $self->domsvc ) {
781 #$self->svc_domain->domain;
782 my $svc_domain = $self->svc_domain
783 or die "no svc_domain.svcnum for svc_acct.domsvc ". $self->domsvc;
786 $mydomain or die "svc_acct.domsvc is null and no legacy domain config file";
792 Returns the FS::svc_domain record for this account's domain (see
801 : qsearchs( 'svc_domain', { 'svcnum' => $self->domsvc } );
806 Returns the FS::cust_svc record for this account (see L<FS::cust_svc>).
810 qsearchs( 'cust_svc', { 'svcnum' => $self->svcnum } );
815 Returns an email address associated with the account.
821 $self->username. '@'. $self->domain;
824 =item seconds_since TIMESTAMP
826 Returns the number of seconds this account has been online since TIMESTAMP.
829 TIMESTAMP is specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
830 L<Time::Local> and L<Date::Parse> for conversion functions.
834 #note: POD here, implementation in FS::cust_svc
837 $self->cust_svc->seconds_since(@_);
842 Returns all RADIUS groups for this account (see L<FS::radius_usergroup>).
848 map { $_->groupname }
849 qsearch('radius_usergroup', { 'svcnum' => $self->svcnum } );
856 =item radius_usergroup_selector GROUPS_ARRAYREF [ SELECTNAME ]
860 sub radius_usergroup_selector {
861 my $sel_groups = shift;
862 my %sel_groups = map { $_=>1 } @$sel_groups;
864 my $selectname = shift || 'radius_usergroup';
867 my $sth = $dbh->prepare(
868 'SELECT DISTINCT(groupname) FROM radius_usergroup ORDER BY groupname'
869 ) or die $dbh->errstr;
870 $sth->execute() or die $sth->errstr;
871 my @all_groups = map { $_->[0] } @{$sth->fetchall_arrayref};
875 function ${selectname}_doadd(object) {
876 var myvalue = object.${selectname}_add.value;
877 var optionName = new Option(myvalue,myvalue,false,true);
878 var length = object.$selectname.length;
879 object.$selectname.options[length] = optionName;
880 object.${selectname}_add.value = "";
883 <SELECT MULTIPLE NAME="$selectname">
886 foreach my $group ( @all_groups ) {
888 if ( $sel_groups{$group} ) {
889 $html .= ' SELECTED';
890 $sel_groups{$group} = 0;
892 $html .= ">$group</OPTION>\n";
894 foreach my $group ( grep { $sel_groups{$_} } keys %sel_groups ) {
895 $html .= "<OPTION SELECTED>$group</OPTION>\n";
897 $html .= '</SELECT>';
899 $html .= qq!<BR><INPUT TYPE="text" NAME="${selectname}_add">!.
900 qq!<INPUT TYPE="button" VALUE="Add new group" onClick="${selectname}_doadd(this.form)">!;
907 The $recref stuff in sub check should be cleaned up.
909 The suspend, unsuspend and cancel methods update the database, but not the
910 current object. This is probably a bug as it's unexpected and
913 radius_usergroup_selector? putting web ui components in here? they should
914 probably live somewhere else...
918 L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface,
919 export.html from the base documentation, L<FS::Record>, L<FS::Conf>,
920 L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, L<FS::queue>,
921 L<freeside-queued>), L<Net::SSH>, L<ssh>, L<FS::svc_acct_pop>,
922 schema.html from the base documentation.