inc/record.inc.php
changeset 115 b1d7998a903e
parent 111 0a2342a64b83
child 119 f74e4f88b680
equal deleted inserted replaced
114:7c8af2b598eb 115:b1d7998a903e
   730 
   730 
   731 // TODO: letterstart limitation and userid permission limitiation should be applied at the same time?
   731 // TODO: letterstart limitation and userid permission limitiation should be applied at the same time?
   732 function zone_count_ng($perm, $letterstart=all) {
   732 function zone_count_ng($perm, $letterstart=all) {
   733 	global $db;
   733 	global $db;
   734 	global $sql_regexp;
   734 	global $sql_regexp;
       
   735 
       
   736 	$fromTable = 'domains';
       
   737 
   735 	if ($perm != "own" && $perm != "all") {
   738 	if ($perm != "own" && $perm != "all") {
   736 		$zone_count = "0";
   739 		$zone_count = "0";
   737 	} 
   740 	} 
   738 	else 
   741 	else 
   739 	{
   742 	{
   740 		if ($perm == "own") {
   743 		if ($perm == "own") {
   741 			$sql_add = " AND zones.domain_id = domains.id
   744 			$sql_add = " AND zones.domain_id = domains.id
   742 					AND zones.owner = ".$db->quote($_SESSION['userid']);
   745 					AND zones.owner = ".$db->quote($_SESSION['userid']);
       
   746 			$fromTable .= ',zones';
   743 		}
   747 		}
   744 		if ($letterstart!=all && $letterstart!=1) {
   748 		if ($letterstart!=all && $letterstart!=1) {
   745 			$sql_add .=" AND domains.name LIKE ".$db->quote($letterstart."%")." ";
   749 			$sql_add .=" AND domains.name LIKE ".$db->quote($letterstart."%")." ";
   746 		} elseif ($letterstart==1) {
   750 		} elseif ($letterstart==1) {
   747 			$sql_add .=" AND substring(domains.name,1,1) ".$sql_regexp." '^[[:digit:]]'";
   751 			$sql_add .=" AND substring(domains.name,1,1) ".$sql_regexp." '^[[:digit:]]'";
   748 		}
   752 		}
   749 
   753 
   750 		$sqlq = "SELECT COUNT(distinct domains.id) AS count_zones 
   754 		$sqlq = "SELECT COUNT(distinct domains.id) AS count_zones 
   751 			FROM domains,zones 
   755 			FROM ".$fromTable."	WHERE 1=1
   752 			WHERE 1=1
       
   753 			".$sql_add.";";
   756 			".$sql_add.";";
   754 
   757 
   755 		$zone_count = $db->queryOne($sqlq);
   758 		$zone_count = $db->queryOne($sqlq);
   756 	}
   759 	}
   757 	return $zone_count;
   760 	return $zone_count;