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


Ignore:
Timestamp:
04/27/18 15:28:45 (7 years ago)
Author:
Kris Deugau
Message:

/trunk

Start adding a generalized in-your-face infonotice space to attach warnings
to a netblock. See #17 and #23, sort of.

  • table to hold the notices, since they're likely to be far fewer than the overall allocation count
  • show any notices for the parent chain for new allocations in the admin tools
File:
1 edited

Legend:

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

    r913 r915  
    3535        &getBlockRDNS &getRDNSbyIP &getRevID
    3636        &getNodeList &getNodeName &getNodeInfo
     37        &getBlockNotices
    3738        &mailNotify
    3839        );
     
    5152                &getBlockRDNS &getRDNSbyIP &getRevID
    5253                &getNodeList &getNodeName &getNodeInfo
     54                &getBlockNotices
    5355                &mailNotify
    5456                )]
     
    35533555
    35543556
     3557## IPDB::getBlockNotices()
     3558# Retrieve any infonotes for a block and all of its parents
     3559# Takes the block ID to trace down the stack
     3560# Returns an arrayref to the block and all of its parents, containing the CIDR,
     3561# description, and notice (if any) associated to each block.
     3562sub getBlockNotices {
     3563  my $dbh = shift;
     3564  my $bid = shift;
     3565  my $nlist = $dbh->selectall_arrayref(q(
     3566        WITH RECURSIVE blockparents (id, cidr, description, parent_id, notice, depth) AS (
     3567                SELECT a.id, a.cidr, a.description, a.parent_id, bn.notice, 1 AS depth FROM allocations a
     3568                LEFT JOIN blocknotices bn ON a.id = bn.alloc_id
     3569                WHERE a.id = ?
     3570                UNION
     3571                SELECT b.id, b.cidr, b.description, b.parent_id, bn2.notice, t.depth AS depth FROM allocations b
     3572                JOIN blockparents t ON t.parent_id = b.id
     3573                LEFT JOIN blocknotices bn2 ON b.id = bn2.alloc_id
     3574        ) SELECT id, cidr, description, parent_id, notice FROM blockparents ORDER BY depth DESC;
     3575), {Slice=>{}}, $bid);
     3576
     3577  return $nlist;
     3578} # end getBlockNotices()
     3579
     3580
    35553581## IPDB::mailNotify()
    35563582# Sends notification mail to recipients regarding an IPDB operation
Note: See TracChangeset for help on using the changeset viewer.