yow. fix up group handling
[freeside.git] / httemplate / edit / svc_acct.cgi
index bc5d96a..14d6759 100755 (executable)
@@ -68,18 +68,22 @@ unless ( $svcnum || $cgi->param('error') ) { #adding
     }
   }
 
-  #set fixed and default fields from part_svc
-  foreach my $part_svc_column (
-    grep { $_->columnflag } $part_svc->all_part_svc_column
-  ) {
-    if ( $part_svc_column->columnname eq 'usergroup' ) {
-      @groups = split(',', $part_svc_column->columnvalue);
-    } else {
-      $svc_acct->setfield( $part_svc_column->columnname,
-                           $part_svc_column->columnvalue,
-                         );
+  $svc_acct->set_default_and_fixed( {
+    #false laziness w/svc-acct::_fieldhandlers
+    'usergroup' => sub { 
+                         my( $self, $groups ) = @_;
+                         if ( ref($groups) eq 'ARRAY' ) {
+                           @groups = @$groups;
+                           $groups;
+                         } elsif ( length($groups) ) {
+                           @groups = split(/\s*,\s*/, $groups);
+                           [ @groups ];
+                         } else {
+                           @groups = ();
+                           [];
+                         }
     }
-  }
+  );
 
 }
 
@@ -119,7 +123,7 @@ my $p1 = popurl(1);
 
 %>
 
-<%= header("$action $svc account") %>
+<%= include("/elements/header.html","$action $svc account") %>
 
 <% if ( $cgi->param('error') ) { %>
   <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
@@ -274,7 +278,7 @@ if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) {
 <% foreach my $xid (qw( uid gid )) { %>
 
   <%
-  if ( $part_svc->part_svc_column($xid)->columnflag eq 'F'
+  if ( $part_svc->part_svc_column($xid)->columnflag =~ /^[FA]$/
        || ! $conf->exists("svc_acct-edit_$xid")
      ) {
   %>
@@ -288,12 +292,10 @@ if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) {
         </TD>
       </TR>
   
-    <% } else { %>
-  
-      <INPUT TYPE="hidden" NAME="<%= $xid %>" VALUE="<%= $svc_acct->$xid() %>">
-  
     <% } %>
   
+    <INPUT TYPE="hidden" NAME="<%= $xid %>" VALUE="<%= $svc_acct->$xid() %>">
+  
   <% } else { %>
   
     <TR>
@@ -378,7 +380,7 @@ if ( $part_svc->part_svc_column('shell')->columnflag eq 'F'
 <% } %>
 
 
-<% if ( $part_svc->part_svc_column('slipip')->columnflag eq 'F' ) { %>
+<% if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) { %>
 
   <INPUT TYPE="hidden" NAME="slipip" VALUE="<%= $svc_acct->slipip %>">
 
@@ -398,7 +400,7 @@ foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
   my $a = $2;
 %>
 
-  <% if ( $part_svc->part_svc_column($r)->columnflag eq 'F' ) { %>
+  <% if ( $part_svc->part_svc_column($r)->columnflag =~ /^[FA]$/ ) { %>
 
     <INPUT TYPE="hidden" NAME="<%= $r %>" VALUE="<%= $svc_acct->getfield($r) %>">