Changeset 519 for trunk


Ignore:
Timestamp:
10/19/12 16:15:59 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Move SQL for node search page into IPDB.pm. See #34.
Also tweak some handling for the lingering global statement handle
variable, since it may be undefined instead of a statement handle.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r518 r519  
    2626        %allocated %free %routed %bigfree %IPDBacl %aclmsg
    2727        &initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock &addMaster
    28         &deleteBlock &getBlockData &mailNotify
     28        &deleteBlock &getBlockData
     29        &getNodeList
     30        &mailNotify
    2931        );
    3032
     
    3436                @masterblocks %allocated %free %routed %bigfree %IPDBacl %aclmsg
    3537                &initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock
    36                 &addMaster &deleteBlock &getBlockData &mailNotify
     38                &addMaster &deleteBlock &getBlockData
     39                &getNodeList
     40                &mailNotify
    3741                )]
    3842        );
     
    832836
    833837
     838## IPDB::getNodeList()
     839# Gets a list of node ID+name pairs as an arrayref to a list of hashrefs
     840sub getNodeList {
     841  my $dbh = shift;
     842 
     843  my $ret = $dbh->selectall_arrayref("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id",
     844        { Slice => {} });
     845  return $ret;
     846} # end getNodeList()
     847
     848
    834849## IPDB::mailNotify()
    835850# Sends notification mail to recipients regarding an IPDB operation
  • trunk/cgi-bin/main.cgi

    r517 r519  
    155155}
    156156elsif ($webvar{action} eq 'nodesearch') {
    157   $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
    158   $sth->execute() or $page->param(errmsg => $sth->errstr);
    159   my @nodelist;
    160   while (my ($nid,$nname) = $sth->fetchrow_array()) {
    161     my %row = (nodeid => $nid, nodename => $nname);
    162     push @nodelist, \%row;
    163   }
    164   $page->param(nodelist => \@nodelist);
     157  my $nodelist = getNodeList($ip_dbh);
     158  $page->param(nodelist => $nodelist);
    165159}
    166160
     
    201195}
    202196
    203 
     197$sth->finish if $sth;
    204198# Clean up IPDB globals, DB handle, etc.
    205199finish($ip_dbh);
  • trunk/templates/nodesearch.tmpl

    r517 r519  
    1111<td><select name="node">
    1212        <option>--</option>
    13 <TMPL_LOOP NAME=nodelist>       <option value="<TMPL_VAR NAME=nodeid>"><TMPL_VAR NAME=nodename></option>
     13<TMPL_LOOP NAME=nodelist>       <option value="<TMPL_VAR NAME=node_id>"><TMPL_VAR NAME=node_name></option>
    1414</TMPL_LOOP>
    1515</select></td>
Note: See TracChangeset for help on using the changeset viewer.