[freeside-commits] freeside/httemplate/config config-view.cgi, 1.36, 1.37 config-process.cgi, 1.21, 1.22

Ivan,,, ivan at wavetail.420.am
Tue Nov 3 17:04:37 PST 2009


Update of /home/cvs/cvsroot/freeside/httemplate/config
In directory wavetail.420.am:/tmp/cvs-serv29210/httemplate/config

Modified Files:
	config-view.cgi config-process.cgi 
Log Message:
reconcile breakage from stale accounts, RT#6407

Index: config-process.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/config/config-process.cgi,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- config-process.cgi	3 Nov 2009 03:13:09 -0000	1.21
+++ config-process.cgi	4 Nov 2009 01:04:35 -0000	1.22
@@ -1,3 +1,74 @@
+<% header('Configuration set') %>
+  <SCRIPT TYPE="text/javascript">
+%   my $n = 0;
+%   foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
+    var configCell = window.top.document.getElementById('<% $agentnum. $i->key. $n %>');
+    if ( ! configCell ) {
+      window.top.location.reload();
+    }
+    //alert('found cell ' + configCell);
+%     if (    $type eq 'textarea'
+%          || $type eq 'editlist'
+%          || $type eq 'selectmultiple' ) {
+        configCell.innerHTML =
+          '<font size="-2"><pre>' + "\n" +
+          <% encode_entities(join("\n",
+               map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
+                   $conf->config($i->key, $agentnum)
+             ) )
+          |js_string %> +
+          '</pre></font>';
+
+%     } elsif ( $type eq 'checkbox' ) {
+%       if ( $conf->exists($i->key, $agentnum) ) {
+          configCell.style.backgroundColor = '#00ff00';
+          configCell.innerHTML = 'YES';
+%       } else {
+          configCell.style.backgroundColor = '#ff0000';
+          configCell.innerHTML = 'NO';
+%       }
+%     } elsif ( $type eq 'select' && $i->select_hash ) {
+%       my %hash;
+%       if ( ref($i->select_hash) eq 'ARRAY' ) {
+%         tie %hash, 'Tie::IxHash', '' => '', @{ $i->select_hash };
+%       } else {
+%         tie %hash, 'Tie::IxHash', '' => '', %{ $i->select_hash };
+%       }
+        configCell.innerHTML = <% $conf->exists($i->key, $agentnum) ? $hash{ $conf->config($i->key, $agentnum) } : '' |js_string %>;
+
+%     } elsif ( $type eq 'text' || $type eq 'select' ) {
+        configCell.innerHTML = <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' |js_string %>;
+%     } elsif ( $type =~ /^select-(part_svc|part_pkg|pkg_class)$/ && ! $i->multiple ) {
+%       my $table = $1;
+%       my $namecol = $namecol{$table};
+%       my $pkey = dbdef->table($table)->primary_key;
+%       my $key = $conf->config($i->key, $agentnum);
+%       my $record = qsearchs($table, { $pkey => $key });
+%       my $value = $record ? "$key: ".$record->$namecol() : $key;
+        configCell.innerHTML = <% $value |js_string %>;
+%     } elsif ( $type eq 'select-sub' ) {
+        configCell.innerHTML =
+          <% $conf->config($i->key, $agentnum) |js_string %> + ': ' +
+          <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) |js_string %>;
+%     } else {
+        //alert('unknown type <% $type %>');
+        window.top.location.reload();
+%     }
+
+%     $n++;
+%   }
+    parent.cClick();
+  </SCRIPT>
+</BODY>
+</HTML>
+<%once>
+#false laziness w/config-view.cgi
+my %namecol = (
+  'part_svc'  => 'svc',
+  'part_pkg'  => 'pkg',
+  'pkg_class' => 'classname',
+);
+</%once>
 <%init>
 die "access denied\n"
   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
@@ -65,62 +136,3 @@
 $conf->delete($_, $agentnum) foreach @delete;
 
 </%init>
-<% header('Configuration set') %>
-  <SCRIPT TYPE="text/javascript">
-%   my $n = 0;
-%   foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
-    var configCell = window.top.document.getElementById('<% $agentnum. $i->key. $n %>');
-    if ( ! configCell ) {
-      window.top.location.reload();
-    }
-    //alert('found cell ' + configCell);
-%     if (    $type eq 'textarea'
-%          || $type eq 'editlist'
-%          || $type eq 'selectmultiple' ) {
-        configCell.innerHTML =
-          '<font size="-2"><pre>' + "\n" +
-          <% encode_entities(join("\n",
-               map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
-                   $conf->config($i->key, $agentnum)
-             ) )
-          |js_string %> +
-          '</pre></font>';
-
-%     } elsif ( $type eq 'checkbox' ) {
-%       if ( $conf->exists($i->key, $agentnum) ) {
-          configCell.style.backgroundColor = '#00ff00';
-          configCell.innerHTML = 'YES';
-%       } else {
-          configCell.style.backgroundColor = '#ff0000';
-          configCell.innerHTML = 'NO';
-%       }
-%     } elsif ( $type eq 'select' && $i->select_hash ) {
-%       my %hash;
-%       if ( ref($i->select_hash) eq 'ARRAY' ) {
-%         tie %hash, 'Tie::IxHash', '' => '', @{ $i->select_hash };
-%       } else {
-%         tie %hash, 'Tie::IxHash', '' => '', %{ $i->select_hash };
-%       }
-        configCell.innerHTML = <% $conf->exists($i->key, $agentnum) ? $hash{ $conf->config($i->key, $agentnum) } : '' |js_string %>;
-
-%     } elsif ( $type eq 'text' || $type eq 'select' ) {
-        configCell.innerHTML = <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' |js_string %>;
-%     } elsif ( $type =~ /^select-(part_svc|part_pkg|pkg_class)$/ && ! $i->multiple ) {
-        configCell.innerHTML =
-          <% $conf->config($i->key, $agentnum) |js_string %>
-%# + ': ' +
-%#          <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) |js_string %>;
-%     } elsif ( $type eq 'select-sub' ) {
-        configCell.innerHTML =
-          <% $conf->config($i->key, $agentnum) |js_string %> + ': ' +
-          <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) |js_string %>;
-%     } else {
-        //alert('unknown type <% $type %>');
-        window.top.location.reload();
-%     }
-
-%     $n++;
-%   }
-    parent.cClick();
-  </SCRIPT>
-  </BODY></HTML>

Index: config-view.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/config/config-view.cgi,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- config-view.cgi	3 Nov 2009 03:13:09 -0000	1.36
+++ config-view.cgi	4 Nov 2009 01:04:35 -0000	1.37
@@ -210,13 +210,21 @@
             </tr>
 
 %   } elsif ( $type =~ /^select-(part_svc|part_pkg|pkg_class)$/ ) {
+%
+%     my $table = $1;
+%     my $namecol = $namecol{$table};
+%     my $pkey = dbdef->table($table)->primary_key;
+%
 %     my @keys = $conf->config($i->key, $agentnum);
 
             <tr>
               <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
-                <% join('<BR>', map { $_ # ': '. $svc, $pkg, whatever
-                                    }
-                                    @keys
+                <% join( '<BR>',
+                         map {
+                           my $key = $_;
+                           my $record = qsearchs($table, { $pkey => $key });
+                           $record ? "$key: ".$record->$namecol() : $key;
+                         } @keys
                        )
                 %>
               </td>
@@ -301,6 +309,14 @@
 </SCRIPT>
 
 </body></html>
+<%once>
+#false laziness w/config-process.cgi
+my %namecol = (
+  'part_svc'  => 'svc',
+  'part_pkg'  => 'pkg',
+  'pkg_class' => 'classname',
+);
+</%once>
 <%init>
 
 die "access denied"
@@ -343,6 +359,5 @@
 if ( $cgi->param('showagent') ) {
   @all_agents = qsearch('agent', { 'disabled' => '' } );
 }
-warn 'all agents: '. join('-', @all_agents);
 
 </%init>



More information about the freeside-commits mailing list