- Timestamp:
- 10/25/12 17:59:15 (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r529 r530 31 31 &getParent &getRoutedCity 32 32 &allocateBlock &deleteBlock &getBlockData 33 &getNodeList 33 &getNodeList &getNodeName &getNodeInfo 34 34 &mailNotify 35 35 ); … … 45 45 &getParent &getRoutedCity 46 46 &allocateBlock &deleteBlock &getBlockData 47 &getNodeList 47 &getNodeList &getNodeName &getNodeInfo 48 48 &mailNotify 49 49 )] … … 1057 1057 1058 1058 1059 ## IPDB::getNodeName() 1060 # Get node name from the ID 1061 sub getNodeName { 1062 my $dbh = shift; 1063 my $nid = shift; 1064 1065 my ($nname) = $dbh->selectrow_array("SELECT node_name FROM nodes WHERE node_id = ?", undef, ($nid) ); 1066 return $nname; 1067 } # end getNodeName() 1068 1069 1070 ## IPDB::getNodeInfo() 1071 # Get node name and ID associated with a block 1072 sub getNodeInfo { 1073 my $dbh = shift; 1074 my $block = shift; 1075 1076 my ($nid, $nname) = $dbh->selectrow_array("SELECT nodes.node_id,node_name FROM nodes INNER JOIN noderef". 1077 " ON nodes.node_id=noderef.node_id WHERE noderef.block = ?", undef, ($block) ); 1078 return ($nid, $nname); 1079 } # end getNodeInfo() 1080 1081 1059 1082 ## IPDB::mailNotify() 1060 1083 # Sends notification mail to recipients regarding an IPDB operation -
trunk/cgi-bin/main.cgi
r529 r530 368 368 369 369 ## node hack 370 $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id"); 371 $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n"; 372 my @nodes; 373 while (my ($nid,$nname) = $sth->fetchrow_array()) { 374 my %row = (nid => $nid, nname => $nname); 375 push (@nodes, \%row); 376 } 377 $page->param(nodelist => \@nodes); 370 my $nlist = getNodeList($ip_dbh); 371 $page->param(nodelist => $nlist); 378 372 ## end node hack 379 373 … … 428 422 } else { # end show pool options 429 423 424 ##fixme: uninitialized 430 425 if ($webvar{fbassign} eq 'y') { 431 426 $cidr = new NetAddr::IP $webvar{block}; … … 442 437 my $extracond = ''; 443 438 if ($webvar{allocfrom} eq '-') { 439 ##fixme: uninitialized 444 440 $extracond = ($webvar{allowpriv} eq 'on' ? '' : 445 441 " and not (cidr <<= '192.168.0.0/16'". … … 519 515 ## node hack 520 516 if ($webvar{node} && $webvar{node} ne '-') { 521 $sth = $ip_dbh->prepare("SELECT node_name FROM nodes WHERE node_id=?"); 522 $sth->execute($webvar{node}); 523 my ($nodename) = $sth->fetchrow_array(); 517 my $nodename = getNodeName($ip_dbh, $webvar{node}); 524 518 $page->param(nodename => $nodename); 525 519 $page->param(nodeid => $webvar{node}); … … 756 750 757 751 ## node hack 758 $sth = $ip_dbh->prepare("SELECT nodes.node_id,node_name FROM nodes INNER JOIN noderef". 759 " ON nodes.node_id=noderef.node_id WHERE noderef.block='$webvar{block}'"); 760 $sth->execute; 761 my ($nodeid,$nodename) = $sth->fetchrow_array(); 752 my ($nodeid,$nodename) = getNodeInfo($ip_dbh, $webvar{block}); 762 753 $page->param(havenodeid => $nodeid); 763 754 … … 771 762 # (currently) have a nodeid set in the first place. 772 763 if ($IPDBacl{$authuser} =~ /c/) { 773 $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id"); 774 $sth->execute; 775 my @nodelist; 776 while (my ($nid,$nname) = $sth->fetchrow_array()) { 777 my %row = ( 778 selme => ($nodeid == $nid), 779 nodeid => $nid, 780 nodename => $nname, 781 ); 782 push (@nodelist, \%row); 764 my $nlist = getNodeList($ip_dbh); 765 foreach (@{$nlist}) { 766 $$_{selme} = ($$_{node_id} == $nodeid); 783 767 } 784 $page->param(nodelist => \@nodelist);768 $page->param(nodelist => $nlist); 785 769 } 786 770 } … … 870 854 ## node hack 871 855 if ($webvar{node} && $webvar{node} ne '-') { 872 $sth = $ip_dbh->prepare("SELECT node_name FROM nodes WHERE node_id=?"); 873 $sth->execute($webvar{node}); 874 my ($nodename) = $sth->fetchrow_array(); 856 my $nodename = getNodeName($ip_dbh, $webvar{node}); 875 857 $page->param(nodename => $nodename); 876 858 } -
trunk/templates/assign.tmpl
r529 r530 62 62 <td> 63 63 <select name="node"> 64 <option selected ="selected">-</option>64 <option selected>-</option> 65 65 <TMPL_LOOP NAME=nodelist> 66 <option value="<TMPL_VAR NAME=n id>"><TMPL_VAR NAME=nname></option></TMPL_LOOP>66 <option value="<TMPL_VAR NAME=node_id>"><TMPL_VAR NAME=node_name></option></TMPL_LOOP> 67 67 </select> 68 68 <a href="javascript:popNotes('<TMPL_VAR NAME=webpath>/cgi-bin/newnode.cgi')">Add new location</a> -
trunk/templates/edit.tmpl
r517 r530 55 55 <option selected="selected">--</option></TMPL_UNLESS> 56 56 <TMPL_LOOP NAME=nodelist> 57 <option <TMPL_IF selme>selected="selected"</TMPL_IF> value="<TMPL_VAR NAME=nodeid>"><TMPL_VAR NAME=nodename></option></TMPL_LOOP>57 <option value="<TMPL_VAR NAME=node_id>"<TMPL_IF selme> selected</TMPL_IF>><TMPL_VAR NAME=node_name></option></TMPL_LOOP> 58 58 </select> 59 59 <TMPL_ELSE>
Note:
See TracChangeset
for help on using the changeset viewer.