inc/record.inc.php
changeset 37 b785e54690ce
parent 36 4ec5ab29f634
child 40 ee5300058c9d
--- a/inc/record.inc.php	Mon Jul 02 23:01:18 2007 +0000
+++ b/inc/record.inc.php	Tue Jul 10 21:24:06 2007 +0000
@@ -1006,7 +1006,20 @@
         global $db;
         if((!level(5) || !$userid) && !level(10) && !level(5))
         {
-                $add = " AND zones.owner=".$_SESSION["userid"];
+		// First select the zones for which we have ownership on one or more records.
+		$query = 'SELECT records.domain_id FROM records, record_owners WHERE user_id = '.$_SESSION['userid'].' AND records.id = record_owners.record_id';
+		$result = $db->query($query);
+		$zones = array();
+		if (!PEAR::isError($result)) {
+			$zones = $result->fetchCol();
+		}
+	
+                $add = " AND (zones.owner=".$_SESSION["userid"];
+		if (count($zones) > 0) {
+			$add .= ' OR zones.domain_id IN ('.implode(',', $zones).') '; 
+
+		}
+		$add .= ')';
         }
         else
         {