inc/toolkit.inc.php
changeset 55 a885f557678f
parent 47 ae140472d97c
child 65 ce1c4d5e1576
equal deleted inserted replaced
54:e858e7e1aab4 55:a885f557678f
   144 }
   144 }
   145 
   145 
   146 function zone_letter_start($letter,$userid=true)
   146 function zone_letter_start($letter,$userid=true)
   147 {
   147 {
   148         global $db;
   148         global $db;
       
   149 	global $sql_regexp;
   149         $sqlq = "SELECT domains.id AS domain_id,
   150         $sqlq = "SELECT domains.id AS domain_id,
   150         zones.owner,
   151         zones.owner,
   151         records.id,
   152         records.id,
   152         domains.name AS domainname
   153         domains.name AS domainname
   153         FROM domains
   154         FROM domains
   154         LEFT JOIN zones ON domains.id=zones.domain_id 
   155         LEFT JOIN zones ON domains.id=zones.domain_id 
   155         LEFT JOIN records ON records.domain_id=domains.id
   156         LEFT JOIN records ON records.domain_id=domains.id
   156         WHERE 1";
   157         WHERE 1=1";
   157         if((!level(5) || !$userid) && !level(10) && !level(5))
   158         if((!level(5) || !$userid) && !level(10) && !level(5))
   158         {
   159         {
   159 		// First select the zones for which we have ownership on one or more records.
   160 		// First select the zones for which we have ownership on one or more records.
   160 		$query = 'SELECT records.domain_id FROM records, record_owners WHERE user_id = '.$_SESSION['userid'].' AND records.id = record_owners.record_id';
   161 		$query = 'SELECT records.domain_id FROM records, record_owners WHERE user_id = '.$_SESSION['userid'].' AND records.id = record_owners.record_id';
   161 		$result = $db->query($query);
   162 		$result = $db->query($query);
   169 			$sqlq .= ' OR zones.domain_id IN ('.implode(',', $zones).') '; 
   170 			$sqlq .= ' OR zones.domain_id IN ('.implode(',', $zones).') '; 
   170 
   171 
   171 		}
   172 		}
   172 		$sqlq .= ')';
   173 		$sqlq .= ')';
   173         }
   174         }
   174         $sqlq .= " AND substring(domains.name,1,1) REGEXP '^".$letter."' LIMIT 1";
   175         $sqlq .= " AND substring(domains.name,1,1) ".$sql_regexp." '^".$letter."' LIMIT 1";
   175         $result = $db->query($sqlq);
   176         $result = $db->query($sqlq);
   176         $numrows = $result->numRows();
   177         $numrows = $result->numRows();
   177         if ( $numrows == "1" ) 
   178         if ( $numrows == "1" ) 
   178         {
   179         {
   179                 return 1;
   180                 return 1;