inc/record.inc.php
changeset 79 0c0aa144356a
parent 78 effde559e0e9
child 81 c72d6d51f3d3
equal deleted inserted replaced
78:effde559e0e9 79:0c0aa144356a
   953  * Get all domains from the database 
   953  * Get all domains from the database 
   954  * This function gets all the domains from the database unless a user id is below 5.
   954  * This function gets all the domains from the database unless a user id is below 5.
   955  * if a user id is below 5 this function will only retrieve records for that user.
   955  * if a user id is below 5 this function will only retrieve records for that user.
   956  * return values: the array of domains or -1 if nothing is found.
   956  * return values: the array of domains or -1 if nothing is found.
   957  */
   957  */
   958 function get_domains($userid=true,$letterstart=all,$rowstart=0,$rowamount=999999)
   958 function get_domains($userid=true,$letterstart='all',$rowstart=0,$rowamount=999999)
   959 {
   959 {
   960 	global $db;
   960 	global $db;
   961 	global $sql_regexp;
   961 	global $sql_regexp;
   962 	if((!level(5) || !$userid) && !level(10) && !level(5))
   962 	if((!level(5) || !$userid) && !level(10) && !level(5))
   963 	{
   963 	{
   974 	domains.name AS domainname
   974 	domains.name AS domainname
   975 	FROM domains
   975 	FROM domains
   976 	LEFT JOIN zones ON domains.id=zones.domain_id 
   976 	LEFT JOIN zones ON domains.id=zones.domain_id 
   977 	LEFT JOIN records ON records.domain_id=domains.id
   977 	LEFT JOIN records ON records.domain_id=domains.id
   978 	WHERE 1=1 $add ";
   978 	WHERE 1=1 $add ";
   979 	if ($letterstart!=all && $letterstart!=1) {
   979 	if ($letterstart!='all' && $letterstart!=1) {
   980 	   $sqlq.=" AND substring(domains.name,1,1) ".$sql_regexp." ".$db->quote("^".$letterstart);
   980 	   $sqlq.=" AND substring(domains.name,1,1) ".$sql_regexp." ".$db->quote("^".$letterstart);
   981 	} elseif ($letterstart==1) {
   981 	} elseif ($letterstart==1) {
   982 	   $sqlq.=" AND substring(domains.name,1,1) ".$sql_regexp." '^[[:digit:]]'";
   982 	   $sqlq.=" AND substring(domains.name,1,1) ".$sql_regexp." '^[[:digit:]]'";
   983 	}
   983 	}
   984 	$sqlq.=" GROUP BY domainname, domains.id
   984 	$sqlq.=" GROUP BY domainname, domains.id
  1006 	else
  1006 	else
  1007 	{
  1007 	{
  1008 		$andnot="";
  1008 		$andnot="";
  1009 	}
  1009 	}
  1010 
  1010 
  1011 	if ($letterstart!=all && $letterstart!=1) {
  1011 	if ($letterstart!='all' && $letterstart!=1) {
  1012 
  1012 
  1013 		$sqlq = "SELECT domains.id AS domain_id,
  1013 		$sqlq = "SELECT domains.id AS domain_id,
  1014 		count(DISTINCT record_owners.record_id) AS aantal,
  1014 		count(DISTINCT record_owners.record_id) AS aantal,
  1015 		domains.name AS domainname
  1015 		domains.name AS domainname
  1016 		FROM domains, record_owners,records, zones
  1016 		FROM domains, record_owners,records, zones
  1054 		"numrec"        =>              $r["aantal"]
  1054 		"numrec"        =>              $r["aantal"]
  1055 		);
  1055 		);
  1056 	}
  1056 	}
  1057 
  1057 
  1058 
  1058 
  1059 	if ($letterstart!=all && $letterstart!=1) {
  1059 	if ($letterstart!='all' && $letterstart!=1) {
  1060 
  1060 
  1061 		while($r = $result_extra->fetchRow())
  1061 		while($r = $result_extra->fetchRow())
  1062 		{
  1062 		{
  1063 		       $ret[$r["domainname"]] = array(
  1063 		       $ret[$r["domainname"]] = array(
  1064 		       "name"          =>              $r["domainname"]."*",
  1064 		       "name"          =>              $r["domainname"]."*",
  1103  * @todo: see whether or not it is possible to add the records
  1103  * @todo: see whether or not it is possible to add the records
  1104  * @param $userid integer The userid of the current user
  1104  * @param $userid integer The userid of the current user
  1105  * @return integer the number of zones
  1105  * @return integer the number of zones
  1106  */
  1106  */
  1107 
  1107 
  1108 function zone_count($userid=true, $letterstart=all) {
  1108 function zone_count($userid=true, $letterstart='all') {
  1109         global $db;
  1109         global $db;
  1110 	global $sql_regexp;
  1110 	global $sql_regexp;
  1111         if((!level(5) || !$userid) && !level(10) && !level(5))
  1111         if((!level(5) || !$userid) && !level(10) && !level(5))
  1112         {
  1112         {
  1113 		// First select the zones for which we have ownership on one or more records.
  1113 		// First select the zones for which we have ownership on one or more records.
  1128         else
  1128         else
  1129         {
  1129         {
  1130                 $add = "";
  1130                 $add = "";
  1131         }
  1131         }
  1132 
  1132 
  1133         if ($letterstart!=all && $letterstart!=1) {
  1133         if ($letterstart!='all' && $letterstart!=1) {
  1134            $add .=" AND domains.name LIKE ".$db->quote($letterstart."%")." ";
  1134            $add .=" AND domains.name LIKE ".$db->quote($letterstart."%")." ";
  1135         } elseif ($letterstart==1) {
  1135         } elseif ($letterstart==1) {
  1136            $add .=" AND substring(domains.name,1,1) ".$sql_regexp." '^[[:digit:]]'";
  1136            $add .=" AND substring(domains.name,1,1) ".$sql_regexp." '^[[:digit:]]'";
  1137         }
  1137         }
  1138 
  1138 
  1365 }
  1365 }
  1366 
  1366 
  1367 function change_domain_type($type, $id)
  1367 function change_domain_type($type, $id)
  1368 {
  1368 {
  1369 	global $db;
  1369 	global $db;
  1370 	unset($add);
  1370 	$add = '';
  1371         if (is_numeric($id))
  1371         if (is_numeric($id))
  1372 	{
  1372 	{
  1373 		// It is not really neccesary to clear the master field if a 
  1373 		// It is not really neccesary to clear the master field if a 
  1374 		// zone is not of the type "slave" as powerdns will ignore that
  1374 		// zone is not of the type "slave" as powerdns will ignore that
  1375 		// fiedl, but it is cleaner anyway.
  1375 		// fiedl, but it is cleaner anyway.