Changeset 751 for trunk/cgi-bin


Ignore:
Timestamp:
06/18/15 17:52:32 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Finally commit last stage of user-facing "merge blocks" process. See #8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/main.cgi

    r750 r751  
    183183elsif($webvar{action} eq 'confmerge') {
    184184  confMerge();
     185}
     186elsif($webvar{action} eq 'domerge') {
     187  doMerge();
    185188}
    186189elsif($webvar{action} eq 'delete') {
     
    12761279
    12771280
     1281# Make it so
     1282sub doMerge {
     1283  if (!$webvar{newmask} || $webvar{newmask} !~ /^\d+$/) {
     1284    $page->param(err => 'New netmask required');
     1285    return;
     1286  }
     1287
     1288  $page->param(block => $webvar{block});
     1289  my $binfo = getBlockData($ip_dbh, $webvar{block});
     1290  my $pinfo = getBlockData($ip_dbh, $binfo->{parent_id});
     1291  my $block = new NetAddr::IP $binfo->{block};
     1292
     1293  # Tree navigation
     1294  my $crumbs = getBreadCrumbs($ip_dbh, $binfo->{parent_id});
     1295  my @rcrumbs = reverse (@$crumbs);
     1296  $utilbar->param(breadcrumb => \@rcrumbs);
     1297
     1298  $page->param(oldblock => $binfo->{block});
     1299  $page->param(oldtype => $disp_alloctypes{$binfo->{type}});
     1300  $page->param(newdisptype => $disp_alloctypes{$webvar{newtype}});
     1301  my $newblock = new NetAddr::IP $block->addr."/$webvar{newmask}";
     1302  $newblock = $newblock->network;
     1303  $page->param(newblock => $newblock);
     1304  $page->param(vis_scope => $merge_display{$webvar{scope}});
     1305
     1306  my $mlist = mergeBlocks($ip_dbh, $webvar{block}, %webvar, user => $authuser);
     1307
     1308  if ($mlist) {
     1309    #(newtype => $webvar{newtype}, newmask => $webvar{newmask}));
     1310    # Slice off first entry (the new parent - note this may be a new allocation,
     1311    # not the same ID that was "merged"!
     1312    my $parent = shift @$mlist;
     1313    $page->param(backpool => $webvar{newtype} =~ /.[dp]/);
     1314    if ($webvar{newtype} =~ /.[enr]/) {
     1315      $page->param(backleaf => 1);
     1316      $page->param(backid => $binfo->{parent_id});
     1317      $page->param(backblock => $pinfo->{block});
     1318    } else {
     1319      $page->param(backid => $parent->{id});
     1320      $page->param(backblock => $parent->{block});
     1321    }
     1322    $page->param(mergelist => $mlist);
     1323  } else {
     1324    $page->param(err => "Merge failed: $IPDB::errstr");
     1325  }
     1326} # doMerge()
     1327
     1328
    12781329# Delete an allocation.
    12791330sub remove {
Note: See TracChangeset for help on using the changeset viewer.