inc/record.inc.php
changeset 37 b785e54690ce
parent 36 4ec5ab29f634
child 40 ee5300058c9d
equal deleted inserted replaced
36:4ec5ab29f634 37:b785e54690ce
  1004 
  1004 
  1005 function zone_count($userid=true, $letterstart=all) {
  1005 function zone_count($userid=true, $letterstart=all) {
  1006         global $db;
  1006         global $db;
  1007         if((!level(5) || !$userid) && !level(10) && !level(5))
  1007         if((!level(5) || !$userid) && !level(10) && !level(5))
  1008         {
  1008         {
  1009                 $add = " AND zones.owner=".$_SESSION["userid"];
  1009 		// First select the zones for which we have ownership on one or more records.
       
  1010 		$query = 'SELECT records.domain_id FROM records, record_owners WHERE user_id = '.$_SESSION['userid'].' AND records.id = record_owners.record_id';
       
  1011 		$result = $db->query($query);
       
  1012 		$zones = array();
       
  1013 		if (!PEAR::isError($result)) {
       
  1014 			$zones = $result->fetchCol();
       
  1015 		}
       
  1016 	
       
  1017                 $add = " AND (zones.owner=".$_SESSION["userid"];
       
  1018 		if (count($zones) > 0) {
       
  1019 			$add .= ' OR zones.domain_id IN ('.implode(',', $zones).') '; 
       
  1020 
       
  1021 		}
       
  1022 		$add .= ')';
  1010         }
  1023         }
  1011         else
  1024         else
  1012         {
  1025         {
  1013                 $add = "";
  1026                 $add = "";
  1014         }
  1027         }