inc/record.inc.php
changeset 140 e68c3d6094d1
parent 138 3e36ebbfe048
child 141 1ede5203910d
equal deleted inserted replaced
139:98ce0ffae5b8 140:e68c3d6094d1
   559 		error(sprintf(ERR_INV_ARG, "get_name_from_record_id"));
   559 		error(sprintf(ERR_INV_ARG, "get_name_from_record_id"));
   560 	}
   560 	}
   561 }
   561 }
   562 
   562 
   563 
   563 
   564 /*
   564 function get_zone_name_from_id($zid)
   565  * Get domain name from a given id
   565 {
   566  * return values: the name of the domain associated with the id.
   566 	global $db;
   567  */
   567 
   568 function get_domain_name_from_id($id)
   568 	if (is_numeric($zid))
   569 {
   569 	{
   570 	global $db;
   570 		$result = $db->query("SELECT name FROM domains WHERE id=".$db->quote($zid));
   571 
       
   572 	if (is_numeric($id))
       
   573 	{
       
   574 		$result = $db->query("SELECT name FROM domains WHERE id=".$db->quote($id));
       
   575 		$rows = $result->numRows() ;
   571 		$rows = $result->numRows() ;
   576 		if ($rows == 1) {
   572 		if ($rows == 1) {
   577  			$r = $result->fetchRow();
   573  			$r = $result->fetchRow();
   578  			return $r["name"];
   574  			return $r["name"];
   579 		} elseif ($rows == "0") {
   575 		} elseif ($rows == "0") {
   580 			error(sprintf("Zone does not exist."));
   576 			error(sprintf("Zone does not exist."));
   581 			return false;
   577 			return false;
   582 		} else {
   578 		} else {
   583 	 		error(sprintf(ERR_INV_ARGC, "get_domain_name_from_id", "more than one domain found?! whaaa! BAD! BAD! Contact admin!"));
   579 	 		error(sprintf(ERR_INV_ARGC, "get_zone_name_from_id", "more than one domain found?! whaaa! BAD! BAD! Contact admin!"));
   584 			return false;
   580 			return false;
   585 		}
   581 		}
   586 	}
   582 	}
   587 	else
   583 	else
   588 	{
   584 	{
   589 		error(sprintf(ERR_INV_ARGC, "get_domain_name_from_id", "Not a valid domainid: $id"));
   585 		error(sprintf(ERR_INV_ARGC, "get_zone_name_from_id", "Not a valid domainid: $id"));
   590 	}
   586 	}
   591 }
   587 }
   592 
   588 
   593 function get_zone_info_from_id($zone_id) {
   589 function get_zone_info_from_id($zid) {
   594 
   590 
   595 	if (verify_permission('zone_content_view_others')) { $perm_view = "all" ; } 
   591 	if (verify_permission('zone_content_view_others')) { $perm_view = "all" ; } 
   596 	elseif (verify_permission('zone_content_view_own')) { $perm_view = "own" ; }
   592 	elseif (verify_permission('zone_content_view_own')) { $perm_view = "own" ; }
   597 	else { $perm_view = "none" ;}
   593 	else { $perm_view = "none" ;}
   598 
   594 
   604 		$query = "SELECT 	domains.type AS type, 
   600 		$query = "SELECT 	domains.type AS type, 
   605 					domains.name AS name, 
   601 					domains.name AS name, 
   606 					domains.master AS master_ip,
   602 					domains.master AS master_ip,
   607 					count(records.domain_id) AS record_count
   603 					count(records.domain_id) AS record_count
   608 					FROM domains LEFT OUTER JOIN records ON domains.id = records.domain_id 
   604 					FROM domains LEFT OUTER JOIN records ON domains.id = records.domain_id 
   609 					WHERE domains.id = " . $db->quote($zone_id) . "
   605 					WHERE domains.id = " . $db->quote($zid) . "
   610 					GROUP BY domains.id, domains.type, domains.name, domains.master";
   606 					GROUP BY domains.id, domains.type, domains.name, domains.master";
   611 		$result = $db->query($query);
   607 		$result = $db->query($query);
   612 		if (PEAR::isError($result)) { error($result->getMessage()); return false; }
   608 		if (PEAR::isError($result)) { error($result->getMessage()); return false; }
   613 
   609 
   614 		if($result->numRows() != 1) {
   610 		if($result->numRows() != 1) {