Changeset 7 for trunk


Ignore:
Timestamp:
09/04/09 17:53:55 (15 years ago)
Author:
Kris Deugau
Message:

/trunk

checkpoint

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r5 r7  
    216216  local $dbh->{RaiseError} = 1;
    217217
     218##fixme
     219return ('OK',"don't wanna!");
     220
    218221  # Wrap all the SQL in a transaction
    219222  eval {
  • trunk/dns.cgi

    r5 r7  
    3131$q->parse_query_string;
    3232
    33 my %webvar;
    3433# This is probably excessive fiddling, but it puts the parameters somewhere my fingers know about...
    35 foreach ($q->param()) {
    36   $webvar{$_} = $q->param($_);
    37 }
     34my %webvar = $q->Vars;
    3835
    3936my $sid = ($webvar{sid} ? $webvar{sid} : undef);
     
    6057my $footer = HTML::Template->new(filename => "$templatedir/footer.tmpl");
    6158
    62 ## hmm.  may want to move this so we can redirect after adding/deleting/etc
    63 print "Content-type: text/html\n\n", $header->output;
    64 
    6559# default
    6660#my $perpage = 15;
    67 my $perpage = 3;
     61my $perpage = 4;
    6862my $offset = ($webvar{offset} ? $webvar{offset} : 0);
    6963
     
    107101  my ($count) = ($sth->fetchrow_array);
    108102
    109 ##fixme
    110   if ($offset eq 'all') {
    111     print "foo!  wanna see'em all\n";
    112   } else {
    113     # all these bits only have sensible behaviour if offset is numeric. err, probably.
    114     if ($count > $perpage) {
    115       # if there are more results than the default, always show the "all" link
    116       $page->param(navall => 1);
    117 
    118       if ($offset > 0) {
    119         $page->param(navfirst => 1);
    120         $page->param(navprev => 1);
    121         $page->param(prevoffs => $offset-1);
    122       }
    123 
    124       # show "next" and "last" links if we're not on the last page of results
    125       if ( (($offset+1) * $perpage - $count) < 0 ) {
    126         $page->param(navnext => 1);
    127         $page->param(nextoffs => $offset+1);
    128         $page->param(navlast => 1);
    129         $page->param(lastoffs => int $count/$perpage);
    130       }
    131     }
    132   }
     103  fill_fpnla($count);
    133104
    134105  $page->param(ndomains => $count);
     
    137108        ( (($offset+1)*$perpage) > $count ? $count : (($offset+1)*$perpage) )
    138109        ));
    139 ##fixme
     110##fixme - group
    140111  $page->param(id => 1);
    141112  my @domlist;
     
    181152  $page->param(nlast => 10);
    182153
    183 ##fixme
    184   if ($offset eq 'all') {
    185     print "foo!  wanna see'em all\n";
    186   } else {
    187     # all these bits only have sensible behaviour if offset is numeric. err, probably.
    188     if ($count > $perpage) {
    189       # if there are more results than the default, always show the "all" link
    190       $page->param(navall => 1);
    191 
    192       if ($offset > 0) {
    193         $page->param(navfirst => 1);
    194         $page->param(navprev => 1);
    195         $page->param(prevoffs => $offset-1);
    196       }
    197 
    198       # show "next" and "last" links if we're not on the last page of results
    199       if ( (($offset+1) * $perpage - $count) < 0 ) {
    200         $page->param(navnext => 1);
    201         $page->param(nextoffs => $offset+1);
    202         $page->param(navlast => 1);
    203         $page->param(lastoffs => int $count/$perpage);
    204       }
    205     }
    206   }
     154  fill_fpnla($count);  # should put some params on this sub...
    207155
    208156##fixme
     
    308256    $page->param(domain => domainName($dbh,$webvar{id}));
    309257# print some neato things?
     258
     259#  } else {
     260#    #whether actually deleting or cancelling we redirect to the domain list, default format
     261
    310262  } elsif ($webvar{del} eq 'ok') {
    311263    my ($code,$msg) = delDomain($dbh, $webvar{id});
     
    372324
    373325
     326## hmm.  may want to move this so we can redirect after adding/deleting/etc
     327print "Content-type: text/html\n\n", $header->output;
     328
    374329# spit it out
    375330print $page->output;
     
    447402  $page->param(ttl      => $soa{ttl});
    448403
    449 ##fixme!
    450 my $roffset = 0;
    451 
    452404#  my @foo2 = getDomRecs($dbh,'def',1);
    453405  my $foo2 = getDomRecs($dbh,$def,$id,$perpage,$webvar{offset});
    454 
    455 #  $sth = $dbh->prepare("select domain_id,domain,status,groups.name from domains".
    456 #       " inner join groups on domains.group_id=groups.group_id".
    457 #       " order by domain".($offset eq 'all' ? '' : " limit $perpage offset ".$offset*$perpage));
    458 #  $sth->execute;
    459 #  my $rownum = 0;
    460 #  while (my @data = $sth->fetchrow_array) {
    461 #    my %row;
    462 #    $row{domainid} = $data[0];
    463 #    $row{domain} = $data[1];
    464 #    $row{status} = ($data[2] ? 'Active' : 'Inactive');
    465 #    $row{group} = $data[3];
    466 #    $row{bg} = ($rownum++)%2;
    467 ##    $row{mkactive} = ($data[2] eq 'inactive' ? 1 : 0);
    468 #    $row{mkactive} = !$data[2];
    469 #    $row{sid} = $sid;
    470 #    $row{offset} = $offset;
    471406
    472407  my $row = 0;
     
    505440  }
    506441}
     442
     443sub fill_fpnla {
     444  my $count = shift;
     445##fixme
     446  if ($offset eq 'all') {
     447    #print "foo!  wanna see'em all\n";
     448  } else {
     449    # all these bits only have sensible behaviour if offset is numeric. err, probably.
     450    if ($count > $perpage) {
     451      # if there are more results than the default, always show the "all" link
     452      $page->param(navall => 1);
     453
     454      if ($offset > 0) {
     455        $page->param(navfirst => 1);
     456        $page->param(navprev => 1);
     457        $page->param(prevoffs => $offset-1);
     458      }
     459
     460      # show "next" and "last" links if we're not on the last page of results
     461      if ( (($offset+1) * $perpage - $count) < 0 ) {
     462        $page->param(navnext => 1);
     463        $page->param(nextoffs => $offset+1);
     464        $page->param(navlast => 1);
     465        $page->param(lastoffs => int $count/$perpage -1);
     466      }
     467    }
     468  }
     469}
  • trunk/templates/deldom.tmpl

    r6 r7  
    55<td align="center">
    66<h3>Are you really sure you want to delete domain <TMPL_VAR NAME=domain>?</h3>
    7 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&del=cancel&id=<TMPL_VAR NAME=id>&">cancel</a> &nbsp; | &nbsp; <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&del=ok&id=<TMPL_VAR NAME=id>&">confirm</a>
     7<a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&del=cancel&id=<TMPL_VAR NAME=id>">cancel</a> &nbsp; | &nbsp; <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&del=ok&id=<TMPL_VAR NAME=id>">confirm</a>
    88</td></tr></table>
    99
    1010<TMPL_ELSE>
    11 <TMPL_IF del_failed>
    12 <!-- Need to find failure mode to cause/test this -->
    13 <h1>FOO!</h1>
    14 <TMPL_VAR NAME=errmsg>
    15 <TMPL_ELSE>
    16 <TMPL_INCLUDE NAME="domlist.tmpl">
     11 <TMPL_IF del_failed>
     12  <div class='errmsg'>Error deleting domain <TMPL_VAR NAME=domain>: <TMPL_VAR NAME=errmsg></div>
     13 </TMPL_IF>
     14 <TMPL_INCLUDE NAME="domlist.tmpl">
    1715</TMPL_IF>
    18 </TMPL_IF>
  • trunk/templates/domlist.tmpl

    r4 r7  
    4242        <td width="1%" nowrap><TMPL_VAR name=group></td>
    4343        <td width="1%" nowrap align=center><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=domlist<TMPL_IF NAME=offset>&offset=<TMPL_VAR NAME=offset></TMPL_IF>&id=<TMPL_VAR NAME=domainid>&action=<TMPL_IF NAME=mkactive>domon<TMPL_ELSE>domoff</TMPL_IF>"><TMPL_IF NAME=mkactive>activate<TMPL_ELSE>deactivate</TMPL_IF></a></td>
    44         <td width="1%" nowrap align=center><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&id=<TMPL_VAR NAME=domainid>&defrec=w"><img src="images/trash2.png" border=0></a></td>
     44        <td width="1%" nowrap align=center><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&id=<TMPL_VAR NAME=domainid>"><img src="images/trash2.png" border=0></a></td>
    4545</tr>
    4646</TMPL_LOOP>
Note: See TracChangeset for help on using the changeset viewer.