" />
        <a href="http://dev.mysql.com/doc/refman/5.0/en/data-type-overview.html" target="_blank">MySQL Data Types &gt;&gt;</a>
      </div>
    </td></tr></table>
  </div>

  <div style="display: none" class="fieldOption indexed clear"><br/>
    <div class="label"><?php 
echo t('MySQL Indexing');
?>
</div>
    <div>
      <input type="hidden" name="indexed" value="0"/>
      <label>
        <input type="checkbox" name="indexed" value="1" <?php 
checkedIf(@$field['indexed'], '1');
?>
 />
        <?php 
$format = t('Create %scolumn index%s - speeds up sorting and some searches but slows down adding and saving records.');
echo sprintf($format, '<a href="http://dev.mysql.com/doc/refman/5.0/en/column-indexes.html" target="_blank">', '</a>');
?>
      </label>
    </div>
  </div>

  </div>
  </fieldset>

<div style="padding: 10px 0px 10px 0px">
  <div class="divider_line"></div>
        You can safely ignore these options if you don't need them.<br/><br/><br/>

          <h4>Development/Staging Servers</h4>
        <table border="0" cellpadding="0" cellspacing="2">
         <tr>
          <td>Use Custom Settings File</td>
          <td>
           <input type="hidden" name="useCustomSettingsFile" value="0" />
           <label>
             <?php 
if (file_exists(SETTINGS_DEV_FILEPATH)) {
    $_REQUEST['useCustomSettingsFile'] = 1;
}
?>
             <input type="checkbox" name="useCustomSettingsFile" value="1" <?php 
checkedIf(@$_REQUEST['useCustomSettingsFile'], '1');
?>
  />
              For this domain name only (<?php 
echo htmlencode(@$_SERVER['HTTP_HOST']);
?>
) use this setting file: <b>/data/<?php 
echo htmlencode(SETTINGS_DEV_FILENAME);
?>
</b>.<br/>
              Using a separate settings file for development servers ensures you never accidentally overwrite your live server settings
              when uploading CMS /data/ files.  Always use custom settings files for development servers only, not your live servers.<br/>
           </label><br/>
          </td>
         </tr>
    function getTableRow($record, $value, $formType)
    {
        global $TABLE_PREFIX;
        // load access list
        $accessList = array();
        if (@$_REQUEST['num']) {
            $query = "SELECT * FROM `{$TABLE_PREFIX}_accesslist` WHERE userNum = '" . mysql_escape($_REQUEST['num']) . "'";
            $result = mysql_query($query) or die("MySQL Error: " . htmlencode(mysql_error()) . "\n");
            while ($record = mysql_fetch_assoc($result)) {
                $accessList[$record['tableName']] = $record;
            }
        }
        // get section list
        $sectionList = array();
        foreach (getSchemaTables() as $tableName) {
            $schema = loadSchema($tableName);
            $allowedMenuTypes = array('single', 'multi', 'category', 'menugroup', 'link', 'custom');
            if (!in_array(@$schema['menuType'], $allowedMenuTypes)) {
                continue;
            }
            $thisMenu = array();
            $thisMenu['menuName'] = htmlencode($schema['menuName']);
            if (@$schema['menuType'] != 'menugroup') {
                $thisMenu['menuName'] = '&nbsp; &nbsp; &nbsp;' . $thisMenu['menuName'];
            }
            if (@$schema['_indent']) {
                $thisMenu['menuName'] = '&nbsp; &nbsp; &nbsp;' . $thisMenu['menuName'];
            }
            $thisMenu['menuOrder'] = $schema['menuOrder'];
            $thisMenu['tableName'] = $tableName;
            $thisMenu['menuType'] = $schema['menuType'];
            array_push($sectionList, $thisMenu);
        }
        uasort($sectionList, '_sortMenusByOrder');
        // sort menus by order value
        // display field
        $allAccessLevel = @$accessList['all']['accessLevel'];
        $sectionsDivStyle = $allAccessLevel != 1 ? "display: none;" : '';
        //
        ob_start();
        ?>
 <tr>
  <td valign="top" style="padding-top: 2px"><?php 
        echo $this->label;
        ?>
</td>
  <td>

<table border="0" cellspacing="1" cellpadding="0">
<thead>
<tr>
<th width="305"><?php 
        et('Section Name');
        ?>
</th>
<th width="115" style="text-align: center"><?php 
        et('Access');
        ?>
</th>
<th width="100" style="text-align: center"><?php 
        et('Max Records');
        ?>
</th>
</tr>
</thead>
<tr>
<td class="listRow listRowOdd"><?php 
        et('All Sections');
        ?>
</td>
<td class="listRow listRowOdd" style="text-align: center">
  <select name="accessList[all][accessLevel]" style="width: 140px" onchange="(this.value=='1') ? $('.sectionAccessList').slideDown() : $('.sectionAccessList').slideUp();">
  <option value="0" <?php 
        selectedIf($allAccessLevel, '0');
        ?>
><?php 
        et('None');
        ?>
</option>
  <option value="3" <?php 
        selectedIf($allAccessLevel, '3');
        ?>
><?php 
        et('Viewer');
        ?>
</option>
  <option value="6" <?php 
        selectedIf($allAccessLevel, '6');
        ?>
><?php 
        et('Author');
        ?>
</option>
  <option value="7" <?php 
        selectedIf($allAccessLevel, '7');
        ?>
><?php 
        eht('Author & Viewer');
        ?>
</option>
  <option value="9" <?php 
        selectedIf($allAccessLevel, '9');
        ?>
><?php 
        et('Editor');
        ?>
</option>
  <option value="1" <?php 
        selectedIf($allAccessLevel, '1');
        ?>
><?php 
        et('By Section');
        ?>
</option>
  </select>
</td>
<td class="listRow listRowOdd" style="text-align: center"><?php 
        et('No Limit');
        ?>
</td>
</tr>
</table>

<script type="text/javascript">
function toggleDisabledForAccessListMaxRecords(tablename) {
var accessLevel = $("#accesslevel_"+tablename).val();
var disableMaxRecords = (accessLevel == 9 || accessLevel == 3);
if (disableMaxRecords) { $("#maxRecords_"+tablename).attr("disabled", true).css("background-color","#DDD");  }
else                   { $("#maxRecords_"+tablename).removeAttr("disabled").css("background-color","#FFF");  }
}
</script>

<div class="sectionAccessList" style="<?php 
        echo $sectionsDivStyle;
        ?>
">
<div style="width: 0px; height: 0px;"></div><?php 
        /* fixes IE7 issue which caused table to get no layout space, causing overlap and missing table content. the issue seems to be caused by a div with only a table inside. adding anything else inside the div seems to fix it, including &nbsp, but that adds extra whitespace, hence the div with no area */
        ?>
<table border="0" cellspacing="1" cellpadding="0">

<?php 
        // list sections
        foreach ($sectionList as $section) {
            $bgColorClass = @$bgColorClass == "listRowEven" ? 'listRowOdd' : 'listRowEven';
            # rotate bgclass
            $fieldnamePrefix = "accessList[{$section['tableName']}]";
            $accessLevel = @$accessList[$section['tableName']]['accessLevel'];
            $maxRecords = @$accessList[$section['tableName']]['maxRecords'];
            $disableMaxRecords = $accessLevel == 9 || $accessLevel == 3;
            $maxRecordsAttr = $disableMaxRecords ? 'style="text-align: center; background-color: #DDD;" disabled="disabled"' : 'style="text-align: center;"';
            ?>
<tr>
<td class="listRow <?php 
            echo $bgColorClass;
            ?>
" width="305">&nbsp;&nbsp;&nbsp;&nbsp;<?php 
            echo $section['menuName'];
            ?>
</td>
<td class="listRow <?php 
            echo $bgColorClass;
            ?>
" width="115" style="text-align: center">
<?php 
            if ($section['menuType'] == 'single' || $section['tableName'] == 'accounts' || $section['menuType'] == 'menugroup' || $section['menuType'] == 'link') {
                ?>
<input type="hidden"   name="<?php 
                echo $fieldnamePrefix;
                ?>
[accessLevel]" value="0" />
<input type="checkbox" name="<?php 
                echo $fieldnamePrefix;
                ?>
[accessLevel]" value="9" <?php 
                checkedIf($accessLevel, '9');
                ?>
 />
<?php 
            } elseif ($section['menuType'] == 'multi') {
                ?>
  <select name="<?php 
                echo $fieldnamePrefix;
                ?>
[accessLevel]" id="accesslevel_<?php 
                echo $section['tableName'];
                ?>
" style="width: 140px" onchange="toggleDisabledForAccessListMaxRecords('<?php 
                echo $section['tableName'];
                ?>
')">
  <option value="0" <?php 
                selectedIf($accessLevel, '0');
                ?>
><?php 
                et('None');
                ?>
</option>
  <option value="3" <?php 
                selectedIf($accessLevel, '3');
                ?>
><?php 
                et('Viewer');
                ?>
</option>
  <option value="6" <?php 
                selectedIf($accessLevel, '6');
                ?>
><?php 
                et('Author');
                ?>
</option>
  <option value="7" <?php 
                selectedIf($accessLevel, '7');
                ?>
><?php 
                eht('Author & Viewer');
                ?>
</option>
  <option value="9" <?php 
                selectedIf($accessLevel, '9');
                ?>
><?php 
                et('Editor');
                ?>
</option>
  </select>
<?php 
            } elseif ($section['menuType'] == 'category') {
                ?>
  <select name="<?php 
                echo $fieldnamePrefix;
                ?>
[accessLevel]" id="accesslevel_<?php 
                echo $section['tableName'];
                ?>
" style="width: 140px" onchange="toggleDisabledForAccessListMaxRecords('<?php 
                echo $section['tableName'];
                ?>
')">
  <option value="0" <?php 
                selectedIf($accessLevel, '0');
                ?>
><?php 
                et('None');
                ?>
</option>
  <option value="9" <?php 
                selectedIf($accessLevel, '9');
                ?>
><?php 
                et('Editor');
                ?>
</option>
  </select>
<?php 
            }
            ?>

</td>
<td class="<?php 
            echo $bgColorClass;
            ?>
" width="100" style="text-align: center">


<?php 
            if ($section['menuType'] == 'single') {
                printf(t("Single Page"));
            } elseif ($section['tableName'] == 'accounts') {
                ?>

<?php 
            } elseif ($section['menuType'] == 'multi') {
                ?>
  <input class="text-input medium-input" type="text" name="<?php 
                echo $fieldnamePrefix;
                ?>
[maxRecords]" id="maxRecords_<?php 
                echo $section['tableName'];
                ?>
"
         value="<?php 
                echo $maxRecords;
                ?>
" size="6" maxlength="6"
         <?php 
                echo $maxRecordsAttr;
                ?>
 />
<?php 
            }
            ?>
</td>

</tr>
<?php 
        }
        ?>

</table></div>


<br/><div style="font-size: 11px">
  <b><?php 
        et('Access Levels:');
        ?>
</b><br/>
  <div style="padding-left: 20px;">
    <?php 
        et('None - Don\'t allow user to access this section');
        ?>
<br/>
    <?php 
        et('Viewer - User can view any record in this section (must also be enabled in section editor)');
        ?>
<br/>
    <?php 
        et('Author - User can only access records they have created');
        ?>
<br/>
    <?php 
        eht("Author & Viewer - User can view any record and modify records they've created");
        ?>
<br/>
    <?php 
        et('Editor - User can access any records in this section');
        ?>
<br/>
  </div>
  <?php 
        et('Max Records: Max records user is allowed to create (for regular users only - leave blank for unlimited)');
        ?>
</div>

  </td>
 </tr>

<?php 
        $html = ob_get_clean();
        return $html;
    }
        </label>
      </td>
    </tr>



    <tr>
      <td width="200"><?php 
et("Restrict IP Access");
?>
</td>
      <td height="22">
        <input type="hidden" name="restrictByIP" value="0"/>
        <label>
          <input type="checkbox" name="restrictByIP" value="1" <?php 
checkedIf($SETTINGS['advanced']['restrictByIP'], '1');
?>
 />
          <?php 
echo sprintf("Only allow users to login from these IP addresses.  eg: 1.2.3.4, 4.4.4.4 (Your IP is: %s)", $_SERVER['REMOTE_ADDR']);
?>
        </label>
        <div style="padding-left: 25px">
          <input class="text-input wide-input" type="text" name="restrictByIP_allowed" value="<?php 
echo htmlencode(@$SETTINGS['advanced']['restrictByIP_allowed']);
?>
" size="30" />
        </div>
      </td>
    </tr>
 />
        <label for="hideRecordsFromDisabledAccounts"><?php 
echo t('Viewers: Hide records that are "Created By" a user who is: deleted, disabled, or expired');
?>
</label>
      </td>
     </tr>
     <tr>
      <td class="labelColumn"><?php 
echo t('Hide Menu');
?>
</td>
      <td>
        <input type="hidden"   name="menuHidden" value="0" />
        <input type="checkbox" name="menuHidden" id="menuHidden" value="1" <?php 
checkedIf(@$schema['menuHidden'], '1');
?>
 />
        <label for="menuHidden"><?php 
echo t('Don\'t show this section on the menu bar');
?>
</label>
      </td>
     </tr>

     <tr><td colspan="2">&nbsp;</td></tr>
     <tr>
      <td class="labelColumn"><?php 
echo t('Required Plugins');
?>
</td>
function cg2_inputCheckbox($name)
{
    $checkedAttr = checkedIf("1", @$_REQUEST[$name], true);
    $html = "<input type='hidden' name='{$name}' value='0' />";
    $html .= "<input type='checkbox' name='{$name}' id='{$name}' value='1' {$checkedAttr} />";
    return $html;
}