diff options
author | ivan <ivan> | 2009-05-09 00:39:13 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-05-09 00:39:13 +0000 |
commit | f920fdb29a19105c9102d29e532f8cbb40dd1171 (patch) | |
tree | 0ca481886abeacd7f46a1189cc4dfc99f22414b3 /FS | |
parent | 277ef4d5ea367fa4819fde5bed75ede8e53a7d9d (diff) |
add ability to configure service labels per-package (still need to actually use the labels), RT#4081
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Schema.pm | 1 | ||||
-rw-r--r-- | FS/FS/part_svc.pm | 75 | ||||
-rw-r--r-- | FS/FS/part_svc_column.pm | 5 | ||||
-rw-r--r-- | FS/FS/svc_acct.pm | 18 |
4 files changed, 59 insertions, 40 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 5d5331ab4..e70a12c1e 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1268,6 +1268,7 @@ sub tables_hashref { 'columnnum', 'serial', '', '', '', '', 'svcpart', 'int', '', '', '', '', 'columnname', 'varchar', '', 64, '', '', + 'columnlabel', 'varchar', 'NULL', $char_d, '', '', 'columnvalue', 'varchar', 'NULL', $char_d, '', '', 'columnflag', 'char', 'NULL', 1, '', '', ], diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index 580038be2..e57efe4d0 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -133,7 +133,8 @@ sub insert { # fields('part_svc'); foreach my $field ( grep { $_ ne 'svcnum' - && defined( $self->getfield($svcdb.'__'.$_.'_flag') ) + && ( defined( $self->getfield($svcdb.'__'.$_.'_flag') ) + || $self->getfield($svcdb.'__'.$_.'_label') !~ /^\s*$/ ) } (fields($svcdb), @fields) ) { my $part_svc_column = $self->part_svc_column($field); @@ -142,20 +143,28 @@ sub insert { 'columnname' => $field, } ); - my $flag = $self->getfield($svcdb.'__'.$field.'_flag'); - #if ( uc($flag) =~ /^([DFMAX])$/ ) { - if ( uc($flag) =~ /^([A-Z])$/ ) { #part_svc_column will test it - my $parser = FS::part_svc->svc_table_fields($svcdb)->{$field}->{parse} - || sub { shift }; - $part_svc_column->setfield('columnflag', $1); - $part_svc_column->setfield('columnvalue', - &$parser($self->getfield($svcdb.'__'.$field)) - ); + my $flag = $self->getfield($svcdb.'__'.$field.'_flag'); + my $label = $self->getfield($svcdb.'__'.$field.'_label'); + if ( uc($flag) =~ /^([A-Z])$/ || $label !~ /^\s*$/ ) { + + if ( uc($flag) =~ /^([A-Z])$/ ) { + my $parser = FS::part_svc->svc_table_fields($svcdb)->{$field}->{parse} + || sub { shift }; + $part_svc_column->setfield('columnflag', $1); + $part_svc_column->setfield('columnvalue', + &$parser($self->getfield($svcdb.'__'.$field)) + ); + } + + $part_svc_column->setfield('columnlabel', $label) + if $label !~ /^\s*$/; + if ( $previous ) { $error = $part_svc_column->replace($previous); } else { $error = $part_svc_column->insert; } + } else { $error = $previous ? $previous->delete : ''; } @@ -254,7 +263,8 @@ sub replace { my $svcdb = $new->svcdb; foreach my $field ( grep { $_ ne 'svcnum' - && defined( $new->getfield($svcdb.'__'.$_.'_flag') ) + && ( defined( $new->getfield($svcdb.'__'.$_.'_flag') ) + || $new->getfield($svcdb.'__'.$_.'_label') !~ /^\s*$/ ) } (fields($svcdb),@fields) ) { my $part_svc_column = $new->part_svc_column($field); @@ -263,15 +273,23 @@ sub replace { 'columnname' => $field, } ); - my $flag = $new->getfield($svcdb.'__'.$field.'_flag'); - #if ( uc($flag) =~ /^([DFMAX])$/ ) { - if ( uc($flag) =~ /^([A-Z])$/ ) { #part_svc_column will test it - my $parser = FS::part_svc->svc_table_fields($svcdb)->{$field}->{parse} + my $flag = $new->getfield($svcdb.'__'.$field.'_flag'); + my $label = $new->getfield($svcdb.'__'.$field.'_label'); + + if ( uc($flag) =~ /^([A-Z])$/ || $label !~ /^\s*$/ ) { + + if ( uc($flag) =~ /^([A-Z])$/ ) { + my $parser = FS::part_svc->svc_table_fields($svcdb)->{$field}->{parse} || sub { shift }; - $part_svc_column->setfield('columnflag', $1); - $part_svc_column->setfield('columnvalue', - &$parser($new->getfield($svcdb.'__'.$field)) - ); + $part_svc_column->setfield('columnflag', $1); + $part_svc_column->setfield('columnvalue', + &$parser($new->getfield($svcdb.'__'.$field)) + ); + } + + $part_svc_column->setfield('columnlabel', $label) + if $label !~ /^\s*$/; + if ( $previous ) { $error = $part_svc_column->replace($previous); } else { @@ -713,17 +731,16 @@ sub process { push @fields, 'usergroup' if $svcdb eq 'svc_acct'; #kludge map { - if ( $param->{ $svcdb.'__'.$_.'_flag' } =~ /^[MA]$/ ) { - $param->{ $svcdb.'__'.$_ } = - delete( $param->{ $svcdb.'__'.$_.'_classnum' } ); + my $f = $svcdb.'__'.$_; + if ( $param->{ $f.'_flag' } =~ /^[MA]$/ ) { + $param->{ $f } = delete( $param->{ $f.'_classnum' } ); } - if ( $param->{ $svcdb.'__'.$_.'_flag' } =~ /^S$/ ) { - $param->{ $svcdb.'__'.$_} = - ref($param->{ $svcdb.'__'.$_}) - ? join(',', @{$param->{ $svcdb.'__'.$_ }} ) - : $param->{ $svcdb.'__'.$_ }; + if ( $param->{ $f.'_flag' } =~ /^S$/ ) { + $param->{ $f } = ref($param->{ $f }) + ? join(',', @{$param->{ $f }} ) + : $param->{ $f }; } - ( $svcdb.'__'.$_, $svcdb.'__'.$_.'_flag' ); + ( $f, $f.'_flag', $f.'_label' ); } @fields; @@ -738,7 +755,7 @@ sub process { my $error; if ( $param->{'svcpart'} ) { $error = $new->replace( $old, - '1.3-COMPAT', + '1.3-COMPAT', #totally bunk, as jeff noted [ 'usergroup' ], \%exportnums, $job diff --git a/FS/FS/part_svc_column.pm b/FS/FS/part_svc_column.pm index d2b8fd91b..f5b39c049 100644 --- a/FS/FS/part_svc_column.pm +++ b/FS/FS/part_svc_column.pm @@ -39,6 +39,8 @@ fields are currently supported: =item columnname - column name in part_svc.svcdb table +=item columnlabel - label for the column + =item columnvalue - default or fixed value for the column =item columnflag - null or empty (no default), `D' for default, `F' for fixed (unchangeable), `S' for selectable choice, `M' for manual selection from inventory, or `A' for automatic selection from inventory. For virtual fields, can also be 'X' for excluded. @@ -87,11 +89,12 @@ sub check { $self->ut_numbern('columnnum') || $self->ut_number('svcpart') || $self->ut_alpha('columnname') + || $self->ut_textn('columnlabel') || $self->ut_anything('columnvalue') ; return $error if $error; - $self->columnflag =~ /^([DFSMAX])$/ + $self->columnflag =~ /^([DFSMAX]?)$/ or return "illegal columnflag ". $self->columnflag; $self->columnflag(uc($1)); diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 955547b73..8b5c7b9c9 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -215,9 +215,9 @@ sub table_info { 'fields' => { 'dir' => 'Home directory', 'uid' => { - label => 'UID', - def_label => 'UID (set to fixed and blank for no UIDs)', - type => 'text', + label => 'UID', + def_info => 'set to fixed and blank for no UIDs', + type => 'text', }, 'slipip' => 'IP address', # 'popnum' => qq!<A HREF="$p/browse/svc_acct_pop.cgi/">POP number</A>!, @@ -244,15 +244,14 @@ sub table_info { }, '_password' => 'Password', 'gid' => { - label => 'GID', - def_label => 'GID (when blank, defaults to UID)', - type => 'text', + label => 'GID', + def_info => 'when blank, defaults to UID', + type => 'text', }, 'shell' => { - #desc =>'Shell (all service definitions should have a default or fixed shell that is present in the <b>shells</b> configuration file, set to blank for no shell tracking)', label => 'Shell', - def_label=> 'Shell (set to blank for no shell tracking)', - type =>'select', + def_info => 'set to blank for no shell tracking', + type => 'select', #select_list => [ $conf->config('shells') ], select_list => [ $conf ? $conf->config('shells') : () ], disable_inventory => 1, @@ -261,7 +260,6 @@ sub table_info { 'finger' => 'Real name', # (GECOS)', 'domsvc' => { label => 'Domain', - #def_label => 'svcnum from svc_domain', type => 'select', select_table => 'svc_domain', select_key => 'svcnum', |