Changeset 714 for trunk


Ignore:
Timestamp:
03/27/15 17:03:27 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Revise getTypeList() to accept another parameter to flag the the
"selected" type.

File:
1 edited

Legend:

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

    r713 r714  
    750750  my $tgroup = shift || 'a';    # technically optional, like this, but should
    751751                                # really be specified in the call for clarity
    752   my $tlist;
     752  my $seltype = shift || '';
     753
     754  my $sql = "SELECT type,listname,type=? AS sel FROM alloctypes WHERE listorder <= 500";
    753755  if ($tgroup eq 'n') {
    754756    # grouping 'p' - all netblock types.  These include routed blocks, containers (_c)
    755757    # and contained (_r) types, dynamic-allocation ranges (_e), static IP pools (_d and _p),
    756758    # and the "miscellaneous" cn, in, and en types.
    757     $tlist = $dbh->selectall_arrayref("SELECT type,listname FROM alloctypes WHERE listorder <= 500 ".
    758         "AND type NOT LIKE '_i' ORDER BY listorder", { Slice => {} });
     759    $sql .= " AND type NOT LIKE '_i'";
    759760  } elsif ($tgroup eq 'p') {
    760761    # grouping 'p' - primary allocation types.  As with 'n' above but without the _r contained types.
    761     $tlist = $dbh->selectall_arrayref("SELECT type,listname FROM alloctypes WHERE listorder <= 500 ".
    762         "AND type NOT LIKE '_i' AND type NOT LIKE '_r' ORDER BY listorder", { Slice => {} });
     762    $sql .= " AND type NOT LIKE '_i' AND type NOT LIKE '_r'";
    763763  } elsif ($tgroup eq 'c') {
    764764    # grouping 'c' - contained types.  These include all static IPs and all _r types.
    765     $tlist = $dbh->selectall_arrayref("SELECT type,listname FROM alloctypes WHERE listorder <= 500 ".
    766         " AND (type LIKE '_i' OR type LIKE '_r') ORDER BY listorder", { Slice => {} });
     765    $sql .= " AND (type LIKE '_i' OR type LIKE '_r')";
    767766  } elsif ($tgroup eq 'i') {
    768767    # grouping 'i' - static IP types.
    769     $tlist = $dbh->selectall_arrayref("SELECT type,listname FROM alloctypes WHERE listorder <= 500 ".
    770         " AND type LIKE '_i' ORDER BY listorder", { Slice => {} });
     768    $sql .= " AND type LIKE '_i'";
    771769  } else {
    772770    # grouping 'a' - all standard allocation types.  This includes everything
    773771    # but mm (present only as a formality).  Make this the default.
    774     $tlist = $dbh->selectall_arrayref("SELECT type,listname FROM alloctypes WHERE listorder <= 500 ".
    775         " ORDER BY listorder", { Slice => {} });
    776   }
     772    # ... whee!  no extra WHERE clauses
     773  }
     774  $sql .= " ORDER BY listorder";
     775  my $tlist = $dbh->selectall_arrayref($sql, { Slice => {} }, $seltype);
    777776  return $tlist;
    778777}
Note: See TracChangeset for help on using the changeset viewer.