[feladat @ 223]
authorrejo
Mon, 31 Mar 2008 21:10:19 +0000
changeset 120 982f722376b4
parent 119 f74e4f88b680
child 121 90cab8725693
[feladat @ 223] Bugfix. No domain id was provided when entering 'edit record' page from a search query. Changed code so 'edit record' does not rely on domain id provided by user but determines it from the record id that is about to be changed. This closes ticket:31.
edit_record.php
inc/record.inc.php
--- a/edit_record.php	Mon Mar 31 06:43:38 2008 +0000
+++ b/edit_record.php	Mon Mar 31 21:10:19 2008 +0000
@@ -34,9 +34,11 @@
 elseif (verify_permission(zone_meta_edit_own)) { $perm_meta_edit = "own" ; }
 else { $perm_meta_edit = "none" ; }
 
-$user_is_zone_owner = verify_user_is_owner_zoneid($_GET["domain"]);
-$zone_type = get_domain_type($_GET["domain"]);
-$zone_name = get_domain_name_from_id($_GET["domain"]);
+$zid = get_zone_id_from_record_id($_GET["id"]);
+
+$user_is_zone_owner = verify_user_is_owner_zoneid($zid);
+$zone_type = get_domain_type($zid);
+$zone_name = get_domain_name_from_id($zid);
 
 if ($_POST["commit"]) {
 	if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) {
@@ -57,7 +59,7 @@
 	error(ERR_PERM_VIEW_RECORD);
 } else {
 	$record = get_record_from_id($_GET["id"]);
-	echo "     <form method=\"post\" action=\"edit_record.php?domain=" . $_GET["domain"] . "&id=" . $_GET["id"] . "\">\n";
+	echo "     <form method=\"post\" action=\"edit_record.php?domain=" . $zid . "&id=" . $_GET["id"] . "\">\n";
 	echo "      <table>\n";
 	echo "       <tr>\n";
 	echo "        <th>" . _('Name') . "</td>\n";
@@ -79,7 +81,7 @@
 		echo "      </tr>\n";
 	} else {
 		echo "      <input type=\"hidden\" name=\"recordid\" value=\"" . $_GET["id"] . "\">\n";
-		echo "      <input type=\"hidden\" name=\"domainid\" value=\"" . $_GET["domain"] . "\">\n";
+		echo "      <input type=\"hidden\" name=\"domainid\" value=\"" . $zid . "\">\n";
 		echo "      <tr>\n";
 		echo "       <td><input type=\"text\" name=\"name\" value=\"" . trim(str_replace($zone_name, '', $record["name"]), '.') . "\" class=\"input\">." . $zone_name . "</td>\n";
 		echo "       <td>IN</td>\n";
--- a/inc/record.inc.php	Mon Mar 31 06:43:38 2008 +0000
+++ b/inc/record.inc.php	Mon Mar 31 21:10:19 2008 +0000
@@ -19,6 +19,13 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+function get_zone_id_from_record_id($rid) {
+	global $db;
+	$query = "SELECT domain_id FROM records WHERE id = " . $db->quote($rid);
+	$zid = $db->queryOne($query);
+	return $zid;
+}
+
 function count_zone_records($zone_id) {
 	global $db;
 	$sqlq = "SELECT COUNT(id) FROM records WHERE domain_id = ".$db->quote($zone_id);