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
197 #(perhaps keep this check with a config option to turn on?)
199 #return gettext('username_in_use'). ": ". $self->username
200 # if qsearchs( 'svc_acct', { 'username' => $self->username,
201 # 'domsvc' => $self->domsvc,
204 if ( $self->svcnum ) {
205 my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$self->svcnum});
206 unless ( $cust_svc ) {
207 $dbh->rollback if $oldAutoCommit;
208 return "no cust_svc record found for svcnum ". $self->svcnum;
210 $self->pkgnum($cust_svc->pkgnum);
211 $self->svcpart($cust_svc->svcpart);
214 #new duplicate username checking
216 my @dup_user = qsearch( 'svc_acct', { 'username' => $self->username } );
217 my @dup_userdomain = qsearchs( 'svc_acct', { 'username' => $self->username,
218 'domsvc' => $self->domsvc } );
220 if ( @dup_user || @dup_userdomain ) {
221 my $exports = FS::part_export::export_info('svc_acct');
222 my( %conflict_user_svcpart, %conflict_userdomain_svcpart );
224 my $part_svc = qsearchs('part_svc', { 'svcpart' => $self->svcpart } );
225 unless ( $part_svc ) {
226 $dbh->rollback if $oldAutoCommit;
227 return 'unknown svcpart '. $self->svcpart;
230 foreach my $part_export ( $part_svc->part_export ) {
232 #this will catch to the same exact export
233 my @svcparts = map { $_->svcpart }
234 qsearch('export_svc', { 'exportnum' => $part_export->exportnum });
236 #this will catch to exports w/same exporthost+type ???
237 #my @other_part_export = qsearch('part_export', {
238 # 'machine' => $part_export->machine,
239 # 'exporttype' => $part_export->exporttype,
241 #foreach my $other_part_export ( @other_part_export ) {
242 # push @svcparts, map { $_->svcpart }
243 # qsearch('export_svc', { 'exportnum' => $part_export->exportnum });
246 my $nodomain = $exports->{$part_export->exporttype}{'nodomain'};
247 if ( $nodomain =~ /^Y/i ) {
248 $conflict_user_svcpart{$_} = $part_export->exportnum
251 $conflict_userdomain_svcpart{$_} = $part_export->exportnum
256 foreach my $dup_user ( @dup_user ) {
257 my $dup_svcpart = $dup_user->cust_svc->svcpart;
258 if ( exists($conflict_user_svcpart{$dup_svcpart}) ) {
259 return "duplicate username: conflicts with svcnum ". $dup_user->svcnum.
260 " via exportnum ". $conflict_user_svcpart{$dup_svcpart};
264 foreach my $dup_userdomain ( @dup_userdomain ) {
265 my $dup_svcpart = $dup_userdomain->cust_svc->svcpart;
266 if ( exists($conflict_user_svcpart{$dup_svcpart}) ) {
267 return "duplicate username\@domain: conflicts with svcnum ".
268 $dup_userdomain->svcnum. " via exportnum ".
269 $conflict_user_svcpart{$dup_svcpart};
275 #see? i told you it was more complicated
277 my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
278 return "Unknown svcpart" unless $part_svc;
280 if $part_svc->part_svc_column('uid')->columnflag ne 'F'
281 && qsearchs( 'svc_acct', { 'uid' => $self->uid } )
282 && $self->username !~ /^(hyla)?fax$/
283 && $self->username !~ /^toor$/ #FreeBSD
286 $error = $self->SUPER::insert;
288 $dbh->rollback if $oldAutoCommit;
292 if ( $self->usergroup ) {
293 foreach my $groupname ( @{$self->usergroup} ) {
294 my $radius_usergroup = new FS::radius_usergroup ( {
295 svcnum => $self->svcnum,
296 groupname => $groupname,
298 my $error = $radius_usergroup->insert;
300 $dbh->rollback if $oldAutoCommit;
306 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
312 Deletes this account from the database. If there is an error, returns the
313 error, otherwise returns false.
315 The corresponding FS::cust_svc record will be deleted as well.
317 (TODOC: new exports! $noexport_hack)
324 if ( defined( $FS::Record::dbdef->table('svc_acct_sm') ) ) {
325 return "Can't delete an account which has (svc_acct_sm) mail aliases!"
326 if $self->uid && qsearch( 'svc_acct_sm', { 'domuid' => $self->uid } );
329 return "Can't delete an account which is a (svc_forward) source!"
330 if qsearch( 'svc_forward', { 'srcsvc' => $self->svcnum } );
332 return "Can't delete an account which is a (svc_forward) destination!"
333 if qsearch( 'svc_forward', { 'dstsvc' => $self->svcnum } );
335 return "Can't delete an account with (svc_www) web service!"
336 if qsearch( 'svc_www', { 'usersvc' => $self->usersvc } );
338 # what about records in session ? (they should refer to history table)
340 local $SIG{HUP} = 'IGNORE';
341 local $SIG{INT} = 'IGNORE';
342 local $SIG{QUIT} = 'IGNORE';
343 local $SIG{TERM} = 'IGNORE';
344 local $SIG{TSTP} = 'IGNORE';
345 local $SIG{PIPE} = 'IGNORE';
347 my $oldAutoCommit = $FS::UID::AutoCommit;
348 local $FS::UID::AutoCommit = 0;
351 foreach my $cust_main_invoice (
352 qsearch( 'cust_main_invoice', { 'dest' => $self->svcnum } )
354 unless ( defined($cust_main_invoice) ) {
355 warn "WARNING: something's wrong with qsearch";
358 my %hash = $cust_main_invoice->hash;
359 $hash{'dest'} = $self->email;
360 my $new = new FS::cust_main_invoice \%hash;
361 my $error = $new->replace($cust_main_invoice);
363 $dbh->rollback if $oldAutoCommit;
368 foreach my $svc_domain (
369 qsearch( 'svc_domain', { 'catchall' => $self->svcnum } )
371 my %hash = new FS::svc_domain->hash;
372 $hash{'catchall'} = '';
373 my $new = new FS::svc_domain \%hash;
374 my $error = $new->replace($svc_domain);
376 $dbh->rollback if $oldAutoCommit;
381 foreach my $radius_usergroup (
382 qsearch('radius_usergroup', { 'svcnum' => $self->svcnum } )
384 my $error = $radius_usergroup->delete;
386 $dbh->rollback if $oldAutoCommit;
391 my $error = $self->SUPER::delete;
393 $dbh->rollback if $oldAutoCommit;
397 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
401 =item replace OLD_RECORD
403 Replaces OLD_RECORD with this one in the database. If there is an error,
404 returns the error, otherwise returns false.
406 The additional field I<usergroup> can optionally be defined; if so it should
407 contain an arrayref of group names. See L<FS::radius_usergroup>. (used in
408 sqlradius export only)
413 my ( $new, $old ) = ( shift, shift );
416 return "Username in use"
417 if $old->username ne $new->username &&
418 qsearchs( 'svc_acct', { 'username' => $new->username,
419 'domsvc' => $new->domsvc,
422 #no warnings 'numeric'; #alas, a 5.006-ism
424 return "Can't change uid!" if $old->uid != $new->uid;
427 #change homdir when we change username
428 $new->setfield('dir', '') if $old->username ne $new->username;
430 local $SIG{HUP} = 'IGNORE';
431 local $SIG{INT} = 'IGNORE';
432 local $SIG{QUIT} = 'IGNORE';
433 local $SIG{TERM} = 'IGNORE';
434 local $SIG{TSTP} = 'IGNORE';
435 local $SIG{PIPE} = 'IGNORE';
437 my $oldAutoCommit = $FS::UID::AutoCommit;
438 local $FS::UID::AutoCommit = 0;
441 $error = $new->SUPER::replace($old);
443 $dbh->rollback if $oldAutoCommit;
444 return $error if $error;
447 $old->usergroup( [ $old->radius_groups ] );
448 if ( $new->usergroup ) {
449 #(sorta) false laziness with FS::part_export::sqlradius::_export_replace
450 my @newgroups = @{$new->usergroup};
451 foreach my $oldgroup ( @{$old->usergroup} ) {
452 if ( grep { $oldgroup eq $_ } @newgroups ) {
453 @newgroups = grep { $oldgroup ne $_ } @newgroups;
456 my $radius_usergroup = qsearchs('radius_usergroup', {
457 svcnum => $old->svcnum,
458 groupname => $oldgroup,
460 my $error = $radius_usergroup->delete;
462 $dbh->rollback if $oldAutoCommit;
463 return "error deleting radius_usergroup $oldgroup: $error";
467 foreach my $newgroup ( @newgroups ) {
468 my $radius_usergroup = new FS::radius_usergroup ( {
469 svcnum => $new->svcnum,
470 groupname => $newgroup,
472 my $error = $radius_usergroup->insert;
474 $dbh->rollback if $oldAutoCommit;
475 return "error adding radius_usergroup $newgroup: $error";
481 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
487 Suspends this account by prefixing *SUSPENDED* to the password. If there is an
488 error, returns the error, otherwise returns false.
490 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
496 my %hash = $self->hash;
497 unless ( $hash{_password} =~ /^\*SUSPENDED\* /
498 || $hash{_password} eq '*'
500 $hash{_password} = '*SUSPENDED* '.$hash{_password};
501 my $new = new FS::svc_acct ( \%hash );
502 my $error = $new->replace($self);
503 return $error if $error;
506 $self->SUPER::suspend;
511 Unsuspends this account by removing *SUSPENDED* from the password. If there is
512 an error, returns the error, otherwise returns false.
514 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
520 my %hash = $self->hash;
521 if ( $hash{_password} =~ /^\*SUSPENDED\* (.*)$/ ) {
522 $hash{_password} = $1;
523 my $new = new FS::svc_acct ( \%hash );
524 my $error = $new->replace($self);
525 return $error if $error;
528 $self->SUPER::unsuspend;
533 Just returns false (no error) for now.
535 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
539 Checks all fields to make sure this is a valid service. If there is an error,
540 returns the error, otherwise returns false. Called by the insert and replace
543 Sets any fixed values; see L<FS::part_svc>.
550 my($recref) = $self->hashref;
552 my $x = $self->setfixed;
553 return $x unless ref($x);
556 if ( $part_svc->part_svc_column('usergroup')->columnflag eq "F" ) {
558 [ split(',', $part_svc->part_svc_column('usergroup')->columnvalue) ] );
561 my $error = $self->ut_numbern('svcnum')
562 || $self->ut_number('domsvc')
563 || $self->ut_textn('sec_phrase')
565 return $error if $error;
567 my $ulen = $usernamemax || $self->dbdef_table->column('username')->length;
568 if ( $username_uppercase ) {
569 $recref->{username} =~ /^([a-z0-9_\-\.\&]{$usernamemin,$ulen})$/i
570 or return gettext('illegal_username'). " ($usernamemin-$ulen): ". $recref->{username};
571 $recref->{username} = $1;
573 $recref->{username} =~ /^([a-z0-9_\-\.\&]{$usernamemin,$ulen})$/
574 or return gettext('illegal_username'). " ($usernamemin-$ulen): ". $recref->{username};
575 $recref->{username} = $1;
578 if ( $username_letterfirst ) {
579 $recref->{username} =~ /^[a-z]/ or return gettext('illegal_username');
580 } elsif ( $username_letter ) {
581 $recref->{username} =~ /[a-z]/ or return gettext('illegal_username');
583 if ( $username_noperiod ) {
584 $recref->{username} =~ /\./ and return gettext('illegal_username');
586 if ( $username_nounderscore ) {
587 $recref->{username} =~ /_/ and return gettext('illegal_username');
589 if ( $username_nodash ) {
590 $recref->{username} =~ /\-/ and return gettext('illegal_username');
592 unless ( $username_ampersand ) {
593 $recref->{username} =~ /\&/ and return gettext('illegal_username');
596 $recref->{popnum} =~ /^(\d*)$/ or return "Illegal popnum: ".$recref->{popnum};
597 $recref->{popnum} = $1;
598 return "Unknown popnum" unless
599 ! $recref->{popnum} ||
600 qsearchs('svc_acct_pop',{'popnum'=> $recref->{popnum} } );
602 unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
604 $recref->{uid} =~ /^(\d*)$/ or return "Illegal uid";
605 $recref->{uid} = $1 eq '' ? $self->unique('uid') : $1;
607 $recref->{gid} =~ /^(\d*)$/ or return "Illegal gid";
608 $recref->{gid} = $1 eq '' ? $recref->{uid} : $1;
609 #not all systems use gid=uid
610 #you can set a fixed gid in part_svc
612 return "Only root can have uid 0"
613 if $recref->{uid} == 0
614 && $recref->{username} ne 'root'
615 && $recref->{username} ne 'toor';
617 # $error = $self->ut_textn('finger');
618 # return $error if $error;
619 $self->getfield('finger') =~
620 /^([\w \t\!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\*\<\>]*)$/
621 or return "Illegal finger: ". $self->getfield('finger');
622 $self->setfield('finger', $1);
624 $recref->{dir} =~ /^([\/\w\-\.\&]*)$/
625 or return "Illegal directory";
627 return "Illegal directory"
628 if $recref->{dir} =~ /(^|\/)\.+(\/|$)/; #no .. component
629 return "Illegal directory"
630 if $recref->{dir} =~ /\&/ && ! $username_ampersand;
631 unless ( $recref->{dir} ) {
632 $recref->{dir} = $dir_prefix . '/';
633 if ( $dirhash > 0 ) {
634 for my $h ( 1 .. $dirhash ) {
635 $recref->{dir} .= substr($recref->{username}, $h-1, 1). '/';
637 } elsif ( $dirhash < 0 ) {
638 for my $h ( reverse $dirhash .. -1 ) {
639 $recref->{dir} .= substr($recref->{username}, $h, 1). '/';
642 $recref->{dir} .= $recref->{username};
646 unless ( $recref->{username} eq 'sync' ) {
647 if ( grep $_ eq $recref->{shell}, @shells ) {
648 $recref->{shell} = (grep $_ eq $recref->{shell}, @shells)[0];
650 return "Illegal shell \`". $self->shell. "\'; ".
651 $conf->dir. "/shells contains: @shells";
654 $recref->{shell} = '/bin/sync';
657 $recref->{quota} =~ /^(\d*)$/ or return "Illegal quota (unimplemented)";
658 $recref->{quota} = $1;
661 $recref->{gid} ne '' ?
662 return "Can't have gid without uid" : ( $recref->{gid}='' );
663 $recref->{finger} ne '' ?
664 return "Can't have finger-name without uid" : ( $recref->{finger}='' );
665 $recref->{dir} ne '' ?
666 return "Can't have directory without uid" : ( $recref->{dir}='' );
667 $recref->{shell} ne '' ?
668 return "Can't have shell without uid" : ( $recref->{shell}='' );
669 $recref->{quota} ne '' ?
670 return "Can't have quota without uid" : ( $recref->{quota}='' );
673 unless ( $part_svc->part_svc_column('slipip')->columnflag eq 'F' ) {
674 unless ( $recref->{slipip} eq '0e0' ) {
675 $recref->{slipip} =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/
676 or return "Illegal slipip". $self->slipip;
677 $recref->{slipip} = $1;
679 $recref->{slipip} = '0e0';
684 #arbitrary RADIUS stuff; allow ut_textn for now
685 foreach ( grep /^radius_/, fields('svc_acct') ) {
689 #generate a password if it is blank
690 $recref->{_password} = join('',map($pw_set[ int(rand $#pw_set) ], (0..7) ) )
691 unless ( $recref->{_password} );
693 #if ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([^\t\n]{4,16})$/ ) {
694 if ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([^\t\n]{$passwordmin,$passwordmax})$/ ) {
695 $recref->{_password} = $1.$3;
696 #uncomment this to encrypt password immediately upon entry, or run
697 #bin/crypt_pw in cron to give new users a window during which their
698 #password is available to techs, for faxing, etc. (also be aware of
700 #$recref->{password} = $1.
701 # crypt($3,$saltset[int(rand(64))].$saltset[int(rand(64))]
703 } elsif ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([\w\.\/\$]{13,34})$/ ) {
704 $recref->{_password} = $1.$3;
705 } elsif ( $recref->{_password} eq '*' ) {
706 $recref->{_password} = '*';
707 } elsif ( $recref->{_password} eq '!!' ) {
708 $recref->{_password} = '!!';
710 #return "Illegal password";
711 return gettext('illegal_password'). "$passwordmin-$passwordmax".
712 FS::Msgcat::_gettext('illegal_password_characters').
713 ": ". $recref->{_password};
721 Depriciated, use radius_reply instead.
726 carp "FS::svc_acct::radius depriciated, use radius_reply";
732 Returns key/value pairs, suitable for assigning to a hash, for any RADIUS
733 reply attributes of this record.
735 Note that this is now the preferred method for reading RADIUS attributes -
736 accessing the columns directly is discouraged, as the column names are
737 expected to change in the future.
746 my($column, $attrib) = ($1, $2);
747 #$attrib =~ s/_/\-/g;
748 ( $FS::raddb::attrib{lc($attrib)}, $self->getfield($column) );
749 } grep { /^radius_/ && $self->getfield($_) } fields( $self->table );
750 if ( $self->ip && $self->ip ne '0e0' ) {
751 $reply{'Framed-IP-Address'} = $self->ip;
758 Returns key/value pairs, suitable for assigning to a hash, for any RADIUS
759 check attributes of this record.
761 Note that this is now the preferred method for reading RADIUS attributes -
762 accessing the columns directly is discouraged, as the column names are
763 expected to change in the future.
769 ( 'Password' => $self->_password,
772 my($column, $attrib) = ($1, $2);
773 #$attrib =~ s/_/\-/g;
774 ( $FS::raddb::attrib{lc($attrib)}, $self->getfield($column) );
775 } grep { /^rc_/ && $self->getfield($_) } fields( $self->table )
781 Returns the domain associated with this account.
787 if ( $self->domsvc ) {
788 #$self->svc_domain->domain;
789 my $svc_domain = $self->svc_domain
790 or die "no svc_domain.svcnum for svc_acct.domsvc ". $self->domsvc;
793 $mydomain or die "svc_acct.domsvc is null and no legacy domain config file";
799 Returns the FS::svc_domain record for this account's domain (see
808 : qsearchs( 'svc_domain', { 'svcnum' => $self->domsvc } );
813 Returns the FS::cust_svc record for this account (see L<FS::cust_svc>).
817 qsearchs( 'cust_svc', { 'svcnum' => $self->svcnum } );
822 Returns an email address associated with the account.
828 $self->username. '@'. $self->domain;
831 =item seconds_since TIMESTAMP
833 Returns the number of seconds this account has been online since TIMESTAMP.
836 TIMESTAMP is specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
837 L<Time::Local> and L<Date::Parse> for conversion functions.
841 #note: POD here, implementation in FS::cust_svc
844 $self->cust_svc->seconds_since(@_);
849 Returns all RADIUS groups for this account (see L<FS::radius_usergroup>).
855 map { $_->groupname }
856 qsearch('radius_usergroup', { 'svcnum' => $self->svcnum } );
863 =item radius_usergroup_selector GROUPS_ARRAYREF [ SELECTNAME ]
867 sub radius_usergroup_selector {
868 my $sel_groups = shift;
869 my %sel_groups = map { $_=>1 } @$sel_groups;
871 my $selectname = shift || 'radius_usergroup';
874 my $sth = $dbh->prepare(
875 'SELECT DISTINCT(groupname) FROM radius_usergroup ORDER BY groupname'
876 ) or die $dbh->errstr;
877 $sth->execute() or die $sth->errstr;
878 my @all_groups = map { $_->[0] } @{$sth->fetchall_arrayref};
882 function ${selectname}_doadd(object) {
883 var myvalue = object.${selectname}_add.value;
884 var optionName = new Option(myvalue,myvalue,false,true);
885 var length = object.$selectname.length;
886 object.$selectname.options[length] = optionName;
887 object.${selectname}_add.value = "";
890 <SELECT MULTIPLE NAME="$selectname">
893 foreach my $group ( @all_groups ) {
895 if ( $sel_groups{$group} ) {
896 $html .= ' SELECTED';
897 $sel_groups{$group} = 0;
899 $html .= ">$group</OPTION>\n";
901 foreach my $group ( grep { $sel_groups{$_} } keys %sel_groups ) {
902 $html .= "<OPTION SELECTED>$group</OPTION>\n";
904 $html .= '</SELECT>';
906 $html .= qq!<BR><INPUT TYPE="text" NAME="${selectname}_add">!.
907 qq!<INPUT TYPE="button" VALUE="Add new group" onClick="${selectname}_doadd(this.form)">!;
914 The $recref stuff in sub check should be cleaned up.
916 The suspend, unsuspend and cancel methods update the database, but not the
917 current object. This is probably a bug as it's unexpected and
920 radius_usergroup_selector? putting web ui components in here? they should
921 probably live somewhere else...
925 L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface,
926 export.html from the base documentation, L<FS::Record>, L<FS::Conf>,
927 L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, L<FS::queue>,
928 L<freeside-queued>), L<Net::SSH>, L<ssh>, L<FS::svc_acct_pop>,
929 schema.html from the base documentation.