diff -r a73ac0ba0401 -r e1c60f72d494 inc/toolkit.inc.php
--- a/inc/toolkit.inc.php Mon Jun 25 22:37:06 2007 +0000
+++ b/inc/toolkit.inc.php Wed Jun 27 20:45:51 2007 +0000
@@ -88,34 +88,67 @@
* Display the alphabetic option: [0-9] [a] [b] .. [z]
*/
-function show_letters($letterstart,$doms)
+function show_letters($letterstart,$userid=true)
{
- foreach ($doms as $dom) {
- if (is_numeric($dom["name"][0])) {
- $letter_taken["0"] = 1;
- } else {
- $letter_taken[$dom["name"][0]] = 1;
- }
- }
+ echo _('Show zones beginning with:') . "
";
+
+ $letter = "[[:digit:]]";
+ if ($letterstart == "0")
+ {
+ echo "[ 0-9 ] ";
+ }
+ elseif (zone_letter_start($letter,$userid))
+ {
+ echo "[ 0-9 ] ";
+ }
+ else
+ {
+ echo "[ 0-9 ] ";
+ }
- echo _('Show zones beginning with:') . "
";
- if ($letterstart == 1) {
- echo "[ 0-9 ] ";
- } elseif ($letter_taken["0"] != 1) {
- echo "[ 0-9 ] ";
- } else {
- echo "[ 0-9 ] ";
- }
-
- foreach (range('a','z') as $letter) {
- if ($letterstart === $letter) {
- echo "[ ".$letter." ] ";
- } elseif ($letter_taken[$letter] != 1) {
- echo "[ ".$letter." ] ";
- } else {
- echo "[ ".$letter." ] ";
- }
- }
+ foreach (range('a','z') as $letter)
+ {
+ if ($letter == $letterstart)
+ {
+ echo "[ ".$letter." ] ";
+ }
+ elseif (zone_letter_start($letter,$userid))
+ {
+ echo "[ ".$letter." ] ";
+ }
+ else
+ {
+ echo "[ ".$letter." ] ";
+ }
+ }
+}
+
+function zone_letter_start($letter,$userid=true)
+{
+ global $db;
+ $sqlq = "SELECT domains.id AS domain_id,
+ zones.owner,
+ records.id,
+ domains.name AS domainname
+ FROM domains
+ LEFT JOIN zones ON domains.id=zones.domain_id
+ LEFT JOIN records ON records.domain_id=domains.id
+ WHERE 1";
+ if((!level(5) || !$userid) && !level(10) && !level(5))
+ {
+ $sqlq .= " AND zones.owner=".$_SESSION["userid"];
+ }
+ $sqlq .= " AND substring(domains.name,1,1) REGEXP '^".$letter."' LIMIT 1";
+ $result = $db->query($sqlq);
+ $numrows = $result->numRows();
+ if ( $numrows == "1" )
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
}
/*