Index: /trunk/DNSDB.pm
===================================================================
--- /trunk/DNSDB.pm	(revision 388)
+++ /trunk/DNSDB.pm	(revision 389)
@@ -3261,5 +3261,5 @@
   my $id = shift;
 
-  my $sql = "SELECT record_id,host,type,val,ttl".($revrec eq 'n' ? ',distance,weight,port' : '').
+  my $sql = "SELECT record_id,host,type,val,ttl,location".($revrec eq 'n' ? ',distance,weight,port' : '').
 	(($defrec eq 'y') ? ',group_id FROM ' : ',domain_id,rdns_id FROM ').
 	_rectable($defrec,$revrec)." WHERE record_id=?";
@@ -3402,4 +3402,6 @@
   my $val = shift;
   my $ttl = shift;
+  my $location = shift;
+  $location  = '' if !$location;
 
   # prep for validation
@@ -3440,6 +3442,6 @@
 
   # Set up database fields and bind parameters
-  $fields .= "host,type,val,ttl,"._recparent($defrec,$revrec);
-  push @vallist, ($$host,$$rectype,$$val,$ttl,$id);
+  $fields .= "host,type,val,ttl,location,"._recparent($defrec,$revrec);
+  push @vallist, ($$host,$$rectype,$$val,$ttl,$location,$id);
   my $vallen = '?'.(',?'x$#vallist);
 
@@ -3468,5 +3470,5 @@
   $logdata{entry} .= " [priority $dist] [weight $weight] [port $port]"
 	if $typemap{$$rectype} eq 'SRV';
-  $logdata{entry} .= "', TTL $ttl";
+  $logdata{entry} .= "', TTL $ttl, location $location";
 
   # Allow transactions, and raise an exception on errors so we can catch it later.
@@ -3518,4 +3520,6 @@
   my $val = shift;
   my $ttl = shift;
+  my $location = shift;	# may be empty/null/undef depending on caller
+  $location  = '' if !$location;
 
   # prep for validation
@@ -3564,6 +3568,6 @@
   # Set up database fields and bind parameters.  Note only the optional fields
   # (distance, weight, port, secondary parent ID) are added in the validation call above
-  $fields .= "host,type,val,ttl,"._recparent($defrec,$revrec);
-  push @vallist, ($$host,$$rectype,$$val,$ttl,
+  $fields .= "host,type,val,ttl,location,"._recparent($defrec,$revrec);
+  push @vallist, ($$host,$$rectype,$$val,$ttl,$location,
 	($defrec eq 'y' ? $oldrec->{group_id} : ($revrec eq 'n' ? $oldrec->{domain_id} : $oldrec->{rdns_id})) );
 
@@ -3618,5 +3622,5 @@
   $logdata{entry} .= " [priority $oldrec->{distance}] [weight $oldrec->{weight}] [port $oldrec->{port}]"
 	if $typemap{$oldrec->{type}} eq 'SRV';
-  $logdata{entry} .= "', TTL $oldrec->{ttl}\nto\n";
+  $logdata{entry} .= "', TTL $oldrec->{ttl}, location $oldrec->{location}\nto\n";
   # More NS special
   if ($revrec eq 'y' && $$rectype == 2) {
@@ -3627,5 +3631,5 @@
   $logdata{entry} .= " [distance $dist]" if $typemap{$$rectype} eq 'MX';
   $logdata{entry} .= " [priority $dist] [weight $weight] [port $port]" if $typemap{$$rectype} eq 'SRV';
-  $logdata{entry} .= "', TTL $ttl";
+  $logdata{entry} .= "', TTL $ttl, location $location";
 
   local $dbh->{AutoCommit} = 0;
Index: /trunk/dns.cgi
===================================================================
--- /trunk/dns.cgi	(revision 388)
+++ /trunk/dns.cgi	(revision 389)
@@ -642,6 +642,10 @@
 	unless ($permissions{admin} || $permissions{record_create});
 
+    # location check - if user does not have record_locchg, set $webvar{location} to default location for zone
+    my $parloc = getZoneLocation($dbh, $webvar{revrec}, $webvar{parentid});
+    $webvar{location} = $parloc unless ($permissions{admin} || $permissions{record_locchg});
+
     my @recargs = ($dbh,$webvar{defrec},$webvar{revrec},$webvar{parentid},
-	\$webvar{name},\$webvar{type},\$webvar{address},$webvar{ttl});
+	\$webvar{name},\$webvar{type},\$webvar{address},$webvar{ttl},$webvar{location});
     if ($webvar{type} == $reverse_typemap{MX} or $webvar{type} == $reverse_typemap{SRV}) {
       push @recargs, $webvar{distance};
@@ -701,6 +705,10 @@
 	unless ($permissions{admin} || $permissions{record_edit});
 
+    # retain old location if user doesn't have permission to fiddle locations
+    my $oldrec = getRecLine($dbh, $webvar{defrec}, $webvar{revrec}, $webvar{id});
+    $webvar{location} = $oldrec->{location} unless ($permissions{admin} || $permissions{record_locchg});
+
     my ($code,$msg) = updateRec($dbh,$webvar{defrec},$webvar{revrec},$webvar{id},$webvar{parentid},
-	\$webvar{name},\$webvar{type},\$webvar{address},$webvar{ttl},
+	\$webvar{name},\$webvar{type},\$webvar{address},$webvar{ttl},$webvar{location},
 	$webvar{distance},$webvar{weight},$webvar{port});
 
