Changeset 697 for trunk/cgi-bin/IPDB.pm


Ignore:
Timestamp:
02/18/15 17:16:21 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Add "breadcrumb" navigation trace to most pages.

File:
1 edited

Legend:

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

    r696 r697  
    3131        &listSummary &listSubs &listContainers &listAllocations &listFree &listPool
    3232        &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
    33         &ipParent &subParent &blockParent &getRoutedCity
     33        &ipParent &subParent &blockParent &getBreadCrumbs &getRoutedCity
    3434        &allocateBlock &updateBlock &deleteBlock &getBlockData &getBlockRDNS &getRDNSbyIP
    3535        &getNodeList &getNodeName &getNodeInfo
     
    4646                &listSummary &listSubs &listContainers &listAllocations &listFree &listPool
    4747                &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
    48                 &ipParent &subParent &blockParent &getRoutedCity
     48                &ipParent &subParent &blockParent &getBreadCrumbs &getRoutedCity
    4949                &allocateBlock &updateBlock &deleteBlock &getBlockData &getBlockRDNS &getRDNSbyIP
    5050                &getNodeList &getNodeName &getNodeInfo
     
    950950
    951951
     952## IPDB::getBreadCrumbs()
     953# Retrieve the ID and CIDR of a block's parent(s) up to the master block
     954# Returns an arrayref to a list of hashrefs with CIDR and block ID
     955sub getBreadCrumbs {
     956  my $dbh = shift;
     957  my $parent = shift;
     958  my @result;
     959
     960  my $sth = $dbh-> prepare("SELECT cidr,type,id,parent_id FROM allocations WHERE id=?");
     961
     962  while ($parent != 0) {
     963    $sth->execute($parent);
     964    my ($cidr,$type,$id,$pid) = $sth->fetchrow_array;
     965    push @result, {cidr => $cidr, link => $id, ispool => ($type =~ /^.[dp]$/ ? 1 : 0)};
     966    $parent = $pid;
     967  }
     968
     969  return \@result;
     970} # end getBread()
     971
     972
    952973## IPDB::getRoutedCity()
    953974# Get the city for a routed block.
Note: See TracChangeset for help on using the changeset viewer.