inc/toolkit.inc.php
changeset 37 b785e54690ce
parent 32 0c2497c1ac01
child 47 ae140472d97c
equal deleted inserted replaced
36:4ec5ab29f634 37:b785e54690ce
   134         LEFT JOIN zones ON domains.id=zones.domain_id 
   134         LEFT JOIN zones ON domains.id=zones.domain_id 
   135         LEFT JOIN records ON records.domain_id=domains.id
   135         LEFT JOIN records ON records.domain_id=domains.id
   136         WHERE 1";
   136         WHERE 1";
   137         if((!level(5) || !$userid) && !level(10) && !level(5))
   137         if((!level(5) || !$userid) && !level(10) && !level(5))
   138         {
   138         {
   139                 $sqlq .= " AND zones.owner=".$_SESSION["userid"];
   139 		// First select the zones for which we have ownership on one or more records.
       
   140 		$query = 'SELECT records.domain_id FROM records, record_owners WHERE user_id = '.$_SESSION['userid'].' AND records.id = record_owners.record_id';
       
   141 		$result = $db->query($query);
       
   142 		$zones = array();
       
   143 		if (!PEAR::isError($result)) {
       
   144 			$zones = $result->fetchCol();
       
   145 		}
       
   146 	
       
   147                 $sqlq .= " AND (zones.owner=".$_SESSION["userid"];
       
   148 		if (count($zones) > 0) {
       
   149 			$sqlq .= ' OR zones.domain_id IN ('.implode(',', $zones).') '; 
       
   150 
       
   151 		}
       
   152 		$sqlq .= ')';
   140         }
   153         }
   141         $sqlq .= " AND substring(domains.name,1,1) REGEXP '^".$letter."' LIMIT 1";
   154         $sqlq .= " AND substring(domains.name,1,1) REGEXP '^".$letter."' LIMIT 1";
   142         $result = $db->query($sqlq);
   155         $result = $db->query($sqlq);
   143         $numrows = $result->numRows();
   156         $numrows = $result->numRows();
   144         if ( $numrows == "1" ) 
   157         if ( $numrows == "1" )