- Timestamp:
- 08/13/12 17:26:35 (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r382 r383 42 42 &loadConfig &connectDB &finish 43 43 &addDomain &delZone &domainName &revName &domainID &revID &addRDNS 44 &getZoneCount &getZoneList 44 &getZoneCount &getZoneList &getZoneLocation 45 45 &addGroup &delGroup &getChildren &groupName 46 46 &getGroupCount &getGroupList … … 69 69 &loadConfig &connectDB &finish 70 70 &addDomain &delZone &domainName &revName &domainID &revID &addRDNS 71 &getZoneCount &getZoneList 71 &getZoneCount &getZoneList &getZoneLocation 72 72 &addGroup &delGroup &getChildren &groupName 73 73 &getGroupCount &getGroupList … … 2182 2182 2183 2183 2184 ## DNSDB::getZoneLocation() 2185 # Retrieve the default locatino for a zone. 2186 # Takes a database handle, forward/reverse flag, and zone ID 2187 sub getZoneLocation { 2188 my $dbh = shift; 2189 my $revrec = shift; 2190 my $zoneid = shift; 2191 2192 my ($loc) = $dbh->selectrow_array("SELECT default_location FROM ". 2193 ($revrec eq 'n' ? 'domains WHERE domain_id = ?' : 'revzones WHERE rdns_id = ?'), 2194 undef, ($zoneid)); 2195 return $loc; 2196 } # end getZoneLocation() 2197 2198 2184 2199 ## DNSDB::addGroup() 2185 2200 # Add a group … … 3101 3116 3102 3117 ## DNSDB::getLocDropdown() 3118 # Get a list of location names for use in a dropdown menu. 3119 # Takes a database handle, current group, and optional "tag this as selected" flag. 3120 # Returns a reference to a list of hashrefs suitable to feeding to HTML::Template 3121 sub getLocDropdown { 3122 my $dbh = shift; 3123 my $grp = shift; 3124 my $sel = shift || ''; 3125 3126 my $sth = $dbh->prepare(qq( 3127 SELECT description,location FROM locations 3128 WHERE group_id=? 3129 ORDER BY description 3130 ) ); 3131 $sth->execute($grp); 3132 3133 my @loclist; 3134 push @loclist, { locname => "(None/public)", loc => '', selected => ($sel ? 0 : ($sel eq '' ? 1 : 0)) }; 3135 while (my ($locname, $loc) = $sth->fetchrow_array) { 3136 my %row = ( 3137 locname => $locname, 3138 loc => $loc, 3139 selected => ($sel eq $loc ? 1 : 0) 3140 ); 3141 push @loclist, \%row; 3142 } 3143 return \@loclist; 3144 } # end getLocDropdown() 3103 3145 3104 3146 -
trunk/dns.cgi
r381 r383 346 346 $webvar{group} = $curgroup if !$webvar{group}; 347 347 fill_grouplist("grouplist", $webvar{group}); 348 fill_loclist(); 348 349 349 350 if ($session->param('add_failed')) { … … 630 631 631 632 fill_recdata(); 633 634 if ($webvar{defrec} eq 'n') { 635 my $defloc = getZoneLocation($dbh, $webvar{revrec}, $webvar{parentid}); 636 fill_loclist($curgroup, $defloc); 637 } 632 638 633 639 } elsif ($webvar{recact} eq 'add') { … … 663 669 $page->param(id => $webvar{id}); 664 670 fill_recdata(); # populate the form... er, mostly. 671 if ($webvar{defrec} eq 'n') { 672 fill_loclist($curgroup, $webvar{location}); 673 } 665 674 } 666 675 … … 682 691 $page->param(ttl => $recdata->{ttl}); 683 692 $page->param(typelist => getTypelist($dbh, $webvar{revrec}, $recdata->{type})); 693 694 if ($webvar{defrec} eq 'n') { 695 fill_loclist($curgroup, $recdata->{location}); 696 } 684 697 685 698 } elsif ($webvar{recact} eq 'update') { … … 1638 1651 $page->param(mayrdns => 1); 1639 1652 1640 $page->param(mayloc => ($permissions{admin} || $permissions{loc _view}));1653 $page->param(mayloc => ($permissions{admin} || $permissions{location_view})); 1641 1654 1642 1655 $page->param(maydefrec => $permissions{admin}); … … 1848 1861 $rec->{record_edit} = ($permissions{admin} || $permissions{record_edit}); 1849 1862 $rec->{record_delete} = ($permissions{admin} || $permissions{record_delete}); 1863 $rec->{locname} = '' unless ($permissions{admin} || $permissions{location_view}); 1850 1864 } 1851 1865 $page->param(reclist => $foo2); … … 2101 2115 2102 2116 2117 sub fill_loclist { 2118 my $cur = shift || $curgroup; 2119 my $defloc = shift || ''; 2120 2121 return unless ($permissions{admin} || $permissions{location_view}); 2122 2123 my $loclist = getLocDropdown($dbh, $cur, $defloc); 2124 2125 $page->param(location_view => ($permissions{admin} || $permissions{location_view})); 2126 $page->param(loclist => $loclist); 2127 } # end fill_loclist() 2128 2129 2103 2130 sub list_users { 2104 2131 -
trunk/templates/newdomain.tmpl
r310 r383 32 32 <td>Make domain active on next DNS propagation</td><td><input type="checkbox" name="makeactive"<TMPL_UNLESS addinactive> checked="checked"</TMPL_UNLESS> /></td> 33 33 </tr> 34 <TMPL_IF location_view> 35 <tr class="datalinelight"> 36 <td>Default location/view:</td> 37 <td><select name="defloc"> 38 <option value="">(None/public)</option> 39 <TMPL_LOOP name=loclist> <option value="<TMPL_VAR NAME=loc>"<TMPL_IF selected> selected="selected"</TMPL_IF>><TMPL_VAR NAME=locname></option> 40 </TMPL_LOOP> 41 </select></td> 42 </tr> 43 </TMPL_IF> 34 44 <tr><td colspan="2" class="tblsubmit"><input type="submit" value="Add domain" /></td></tr> 35 45 </table> -
trunk/templates/reclist.tmpl
r379 r383 62 62 <tr class="row<TMPL_VAR NAME=row>"> 63 63 <TMPL_IF fwdzone> 64 <td><TMPL_IF record_edit><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=record&parentid=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&revrec=<TMPL_VAR NAME=revrec>&recact=edit&id=<TMPL_VAR NAME=record_id>"><TMPL_VAR NAME=host></a><TMPL_ ELSE><TMPL_VAR NAME=host></TMPL_IF></td>64 <td><TMPL_IF record_edit><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=record&parentid=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&revrec=<TMPL_VAR NAME=revrec>&recact=edit&id=<TMPL_VAR NAME=record_id>"><TMPL_VAR NAME=host></a><TMPL_IF locname> (<TMPL_VAR NAME=locname>)</TMPL_IF><TMPL_ELSE><TMPL_VAR NAME=host><TMPL_IF locname> (<TMPL_VAR NAME=locname>)</TMPL_IF></TMPL_IF></td> 65 65 <td><TMPL_VAR NAME=type></td> 66 66 <td><TMPL_VAR NAME=val></td> … … 69 69 <td><TMPL_VAR NAME=port></td> 70 70 <TMPL_ELSE> 71 <td><TMPL_IF record_edit><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=record&parentid=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&revrec=<TMPL_VAR NAME=revrec>&recact=edit&id=<TMPL_VAR NAME=record_id>"><TMPL_VAR NAME=val></a><TMPL_ ELSE><TMPL_VAR NAME=val></TMPL_IF></td>71 <td><TMPL_IF record_edit><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=record&parentid=<TMPL_VAR NAME=id>&defrec=<TMPL_VAR NAME=defrec>&revrec=<TMPL_VAR NAME=revrec>&recact=edit&id=<TMPL_VAR NAME=record_id>"><TMPL_VAR NAME=val></a><TMPL_IF locname> (<TMPL_VAR NAME=locname>)</TMPL_IF><TMPL_ELSE><TMPL_VAR NAME=val><TMPL_IF locname> (<TMPL_VAR NAME=locname>)</TMPL_IF></TMPL_IF></td> 72 72 <td><TMPL_VAR NAME=type></td> 73 73 <td><TMPL_VAR NAME=host></td> -
trunk/templates/record.tmpl
r271 r383 70 70 <td><input size="7" maxlength="20" type="text" name="ttl" value="<TMPL_VAR NAME=ttl>" /></td> 71 71 </tr> 72 <TMPL_IF location_view> 73 <tr class="datalinelight"> 74 <td>Location/view</td> 75 <td><select name="location"> 76 <TMPL_LOOP name=loclist> <option value="<TMPL_VAR NAME=loc>"<TMPL_IF selected> selected="selected"</TMPL_IF>><TMPL_VAR NAME=locname></option> 77 </TMPL_LOOP> 78 </select></td> 79 </tr> 80 </TMPL_IF> 72 81 <tr class="datalinelight"> 73 82 <td colspan="2" align="center"><input type="submit" value=" <TMPL_VAR NAME=todo> " /></td>
Note:
See TracChangeset
for help on using the changeset viewer.