Changeset 529 for trunk/cgi-bin/main.cgi


Ignore:
Timestamp:
10/25/12 15:43:55 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Clean up and move SQL behind block assignment page to IPDB.pm. See #34.

File:
1 edited

Legend:

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

    r528 r529  
    327327    if ($webvar{fbtype} ne 'y') {
    328328      # Snag the type of the container block from the database.
    329       $sth = $ip_dbh->prepare("select type from allocations where cidr >>='$block'");
    330       $sth->execute;
    331       my @data = $sth->fetchrow_array;
    332       $data[0] =~ s/c$/r/;      # Munge the type into the correct form
    333       $page->param(fbdisptype => $list_alloctypes{$data[0]});
    334       $page->param(type => $data[0]);
     329## hmm.  need a flag for parent class/type, sort of?
     330      my $pblock = getParent($ip_dbh, $webvar{block});
     331      my $ptype = $pblock->{type};
     332      $ptype =~ s/c$/r/;
     333      $page->param(fbdisptype => $list_alloctypes{$ptype});
     334      $page->param(type => $ptype);
    335335    } else {
    336       $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 500 ".
    337         "and type not like '_i' and type not like '_r' order by listorder");
    338       $sth->execute;
    339       my @typelist;
    340       my $selflag = 0;
    341       while (my @data = $sth->fetchrow_array) {
    342         my %row = (tval => $data[0],
    343                 type => $data[1],
    344                 sel => ($selflag == 0 ? ' selected' : '')
    345                 );
    346         push (@typelist, \%row);
    347         $selflag++;
    348       }
    349       $page->param(typelist => \@typelist);
     336      # get "primary" alloctypes, since these are all that can correctly be assigned if we're in this branch
     337      my $tlist = getTypeList($ip_dbh, 'p');
     338      $tlist->[0]->{sel} = 1;
     339      $page->param(typelist => $tlist);
    350340    }
    351341  } else {
     
    364354    $page->param(pops => \@pops);
    365355
    366     # could arguably include routing (500) in the list, but ATM it doesn't
    367     # make sense, and in any case that shouldn't be structurally possible here.
    368     $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder <= 500 order by listorder");
    369     $sth->execute;
    370     my @typelist;
    371     my $selflag = 0;
    372     while (my @data = $sth->fetchrow_array) {
    373       my %row = (tval => $data[0],
    374         type => $data[1],
    375         sel => ($selflag == 0 ? ' selected' : '')
    376         );
    377       push (@typelist, \%row);
    378       $selflag++;
    379     }
    380     $page->param(typelist => \@typelist);
     356    # get all standard alloctypes
     357    my $tlist = getTypeList($ip_dbh, 'a');
     358    $tlist->[0]->{sel} = 1;
     359    $page->param(typelist => $tlist);
    381360  }
    382361
Note: See TracChangeset for help on using the changeset viewer.