Changeset 476


Ignore:
Timestamp:
08/25/10 15:16:21 (14 years ago)
Author:
Kris Deugau
Message:

/branches/htmlform

Convert finalDelete to template
Add missing node info on update page
Fix backlink on update page
Tweak edit page to use the right name for the node dropdown
See #3.

Location:
branches/htmlform
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/htmlform/cgi-bin/main.cgi

    r474 r476  
    11021102mailNotify($ip_dbh, 's:swi', "SWIPed: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
    11031103        "$webvar{block} had SWIP status changed to \"Yes\" by $authuser") if $webvar{swip} eq 'on';
    1104   open (HTML, "../updated.html")
    1105         or croak "Could not open updated.html :$!";
    1106   my $html = join('', <HTML>);
     1104
     1105## node hack
     1106  if ($webvar{node} && $webvar{node} ne '-') {
     1107    $sth = $ip_dbh->prepare("SELECT node_name FROM nodes WHERE node_id=?");
     1108    $sth->execute($webvar{node});
     1109    my ($nodename) = $sth->fetchrow_array();
     1110    $page->param(nodename => $nodename);
     1111  }
     1112## end node hack
    11071113
    11081114  # Link back to browse-routed or list-pool page on "Update complete" page.
    1109   my $backlink = "/ip/cgi-bin/main.cgi?action=";
    11101115  my $cblock;   # to contain the CIDR of the container block we're retrieving.
    11111116  my $sql;
    11121117  if (my $pooltype = ($webvar{alloctype} =~ /^(.)i$/) ) {
     1118    $page->param(backpool => 1);
    11131119    $sql = "select pool from poolips where ip='$webvar{block}'";
    1114     $backlink .= "listpool&pool=";
    11151120  } else {
    11161121    $sql = "select cidr from routed where cidr >>= '$webvar{block}'";
    1117     $backlink .= "showrouted&block=";
    11181122  }
    11191123  # I define there to be no errors on this operation...  so we don't need to check for them.
     
    11231127  $sth->fetch();
    11241128  $sth->finish;
    1125   $backlink .= $cblock;
    1126 
    1127 my $swiptmp = ($webvar{swip} eq 'on' ? 'Yes' : 'No');
    1128   $html =~ s/\$\$BLOCK\$\$/$webvar{block}/g;
    1129   $webvar{city} = $q->escapeHTML($webvar{city});
    1130   $html =~ s/\$\$CITY\$\$/$webvar{city}/g;
    1131   $html =~ s/\$\$ALLOCTYPE\$\$/$webvar{alloctype}/g;
    1132   $html =~ s/\$\$TYPEFULL\$\$/$disp_alloctypes{$webvar{alloctype}}/g;
    1133   $html =~ s/\$\$CUSTID\$\$/$webvar{custid}/g;
    1134   $html =~ s/\$\$SWIP\$\$/$swiptmp/g;
    1135   $webvar{circid} = $q->escapeHTML($webvar{circid});
    1136   $html =~ s/\$\$CIRCID\$\$/$webvar{circid}/g;
    1137   $webvar{desc} = $q->escapeHTML($webvar{desc});
    1138   $html =~ s/\$\$DESC\$\$/$webvar{desc}/g;
    1139   $webvar{notes} = $q->escapeHTML($webvar{notes});
    1140   $html =~ s/\$\$NOTES\$\$/$webvar{notes}/g;
    1141   $html =~ s/\$\$BACKLINK\$\$/$backlink/g;
    1142   $html =~ s/\$\$BACKBLOCK\$\$/$cblock/g;
    1143 
    1144   if ($IPDBacl{$authuser} =~ /s/) {
    1145     $privdata = qq(<tr class="color2"><td valign="top">Restricted data:</td>).
    1146         qq(<td class="regular">).$q->escapeHTML($webvar{privdata}).qq(</td></tr>\n);
    1147   }
    1148   $html =~ s/\$\$PRIVDATA\$\$/$privdata/g;
    1149 
    1150   print $html;
     1129  $page->param(backblock => $cblock);
     1130
     1131  $page->param(cidr => $webvar{block});
     1132  $page->param(city => $webvar{city});
     1133  $page->param(disptype => $disp_alloctypes{$webvar{alloctype}});
     1134  $page->param(custid => $webvar{custid});
     1135  $page->param(swip => $webvar{swip} eq 'on' ? 'Yes' : 'No');
     1136  $page->param(circid => $q->escapeHTML($webvar{circid}));
     1137  $page->param(desc => $q->escapeHTML($webvar{desc}));
     1138  $page->param(notes => $q->escapeHTML($webvar{notes}));
     1139  $webvar{privdata} = ($webvar{privdata} ? $q->escapeHTML($webvar{privdata}) : "&nbsp;");
     1140  $page->param(privdata => $webvar{privdata})
     1141        if $IPDBacl{$authuser} =~ /s/;
    11511142
    11521143} # update()
     
    12411232sub finalDelete {
    12421233  if ($IPDBacl{$authuser} !~ /d/) {
    1243     printError("You shouldn't have been able to get here.  Access denied.");
     1234    $page->param(aclerr => 1);
    12441235    return;
    12451236  }
     
    12501241  my ($code,$msg) = deleteBlock($ip_dbh, $webvar{block}, $webvar{alloctype});
    12511242
     1243  $page->param(block => $webvar{block});
    12521244  if ($code eq 'OK') {
    1253     print "<div class=heading align=center>Success!  $webvar{block} deallocated.</div>\n";
    12541245    syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block}".
    12551246        " $custid, $city, desc='$description'";
     
    12581249        "CustID: $custid\nCity: $city\nDescription: $description\n");
    12591250  } else {
     1251    $page->param(failmsg => $msg);
    12601252    if ($webvar{alloctype} =~ /^.i$/) {
    12611253      syslog "err", "$authuser could not deallocate static IP '$webvar{block}': '$msg'";
    1262       printError("Could not deallocate static IP $webvar{block}: $msg");
    12631254    } else {
    12641255      syslog "err", "$authuser could not deallocate netblock '$webvar{block}': '$msg'";
    1265       printError("Could not deallocate netblock $webvar{block}: $msg");
     1256      $page->param(netblock => 1);
    12661257    }
    12671258  }
  • branches/htmlform/templates/edit.tmpl

    r470 r476  
    5151<TMPL_IF typesupportsnodes>
    5252<TMPL_IF maychange>
    53 <select name=demarc><TMPL_UNLESS havenodeid>
     53<select name="node"><TMPL_UNLESS havenodeid>
    5454        <option selected="selected">--</option></TMPL_UNLESS>
    5555<TMPL_LOOP NAME=nodelist>
  • branches/htmlform/templates/update.tmpl

    r475 r476  
    1919
    2020<tr class="row1">
     21<td>Demarc/tower:</td>
     22<td><TMPL_IF nodename><TMPL_VAR NAME=nodename><TMPL_ELSE>N/A</TMPL_IF></td>
     23</tr>
     24
     25<tr class="row0">
    2126<td>Customer ID:</td>
    2227<td><TMPL_VAR NAME=custid></td>
    2328</tr>
    2429
    25 <tr class="row0">
     30<tr class="row1">
    2631<td>SWIPed?:</td>
    2732<td><TMPL_VAR NAME=swip></td>
    2833</tr>
    2934
    30 <tr class="row1">
     35<tr class="row0">
    3136<td>Circuit ID:</td>
    3237<td><TMPL_VAR NAME=circid></td>
    3338</tr>
    3439
    35 <tr class="row0">
     40<tr class="row1">
    3641<td valign="top">Description/Name:</td>
    3742<td><TMPL_VAR NAME=desc></td>
    3843</tr>
    3944
    40 <tr class="row1">
     45<tr class="row0">
    4146<td valign="top">Notes:</td>
    4247<td><TMPL_VAR NAME=notes></td>
     
    4449
    4550<TMPL_IF privdata>
    46 <tr class="color1">
     51<tr class="row1">
    4752<td valign="top">Restricted data:</td>
    48 <td><TMPL_VAR NAME=privdata>
    49 </td>
     53<td><TMPL_VAR NAME=privdata></td>
    5054</tr>
    5155</TMPL_IF>
    5256
    5357</table>
    54 <p>
    55 <div name="backlink">
    56 <a href="$$BACKLINK$$">Back to $$BACKBLOCK$$</a>
     58
     59<br>
     60<div class="backlink">
     61<a href="/ip/cgi-bin/main.cgi?action=<TMPL_IF backpool>listpool&amp;pool=<TMPL_ELSE>showrouted&amp;block=</TMPL_IF><TMPL_VAR NAME=backblock>">Back to <TMPL_VAR NAME=backblock></a>
    5762</div>
    58 </p>
Note: See TracChangeset for help on using the changeset viewer.