<?php
    if (!isset($config->auth_dbhost)) {
        $config->auth_dbhost = "localhost";
    }
    if (!isset($config->auth_dbtype)) {
        $config->auth_dbtype = "mysql";
    }
    if (!isset($config->auth_dbname)) {
        $config->auth_dbname = "";
    }
    if (!isset($config->auth_dbuser)) {
        $config->auth_dbuser = "";
    }
    if (!isset($config->auth_dbpass)) {
        $config->auth_dbpass = "";
    }
    if (!isset($config->auth_dbtable)) {
        $config->auth_dbtable = "";
    }
    if (!isset($config->auth_dbfielduser)) {
        $config->auth_dbfielduser = "";
    }
    if (!isset($config->auth_dbfieldpass)) {
        $config->auth_dbfieldpass = "";
    }
    if (!isset($config->auth_dbpasstype)) {
        $config->auth_dbpasstype = "plaintext";
    }

    $pluginconfig = get_config('auth/db');
?>

<tr valign="top" class="required">
    <td align="right">auth_dbhost:</td>
    <td>
        <input name="auth_dbhost" type="text" size="30" value="<?php echo $config->auth_dbhost?>" />
    <?php  if (isset($err["auth_dbhost"])) formerr($err["auth_dbhost"]); ?>
    </td>
    <td>
    <?php  print_string("auth_dbhost","auth") ?>
    </td>
</tr>

<tr valign="top" class="required">
    <td align="right">auth_dbtype:</td>
    <td>
    <?php  $dbtypes = array("access","ado_access", "ado", "ado_mssql", "borland_ibase", "csv", "db2", "fbsql", "firebird", "ibase", "informix72", "informix", "mssql", "mysql", "mysqlt", "oci805", "oci8", "oci8po", "odbc", "odbc_mssql", "odbc_oracle", "oracle", "postgres64", "postgres7", "postgres", "proxy", "sqlanywhere", "sybase", "vfp");
       foreach ($dbtypes as $dbtype) {
           $dboptions[$dbtype] = $dbtype;
       }
       choose_from_menu($dboptions, "auth_dbtype", $config->auth_dbtype, "");
    ?>
      
    </td>
    <td>
    <?php  print_string("auth_dbtype","auth") ?>
    </td>
</tr>

<tr valign="top" class="required">
    <td align="right">auth_dbname:</td>
    <td>
    <input name="auth_dbname" type="text" size="30" value="<?php echo $config->auth_dbname?>" />
    <?php  if (isset($err["auth_dbname"]))formerr($err["auth_dbname"]); ?>
    </td>
    <td>
    <?php  print_string("auth_dbname","auth") ?>
    </td>
</tr>

<tr valign="top" class="required">
    <td align="right">auth_dbuser:</td>
    <td>
    <input name="auth_dbuser" type="text" size="30" value="<?php echo $config->auth_dbuser?>" />
    <?php  if (isset($err["auth_dbuser"])) formerr($err["auth_dbuser"]); ?>
    </td>
    <td>
    <?php  print_string("auth_dbuser","auth") ?>
    </td>
</tr>

<tr valign="top" class="required">
    <td align="right">auth_dbpass:</td>
    <td>
    <input name="auth_dbpass" type="text" size="30" value="<?php echo $config->auth_dbpass?>" />
    <?php  if (isset($err["auth_dbpass"])) formerr($err["auth_dbpass"]); ?>
    </td>
    <td>
    <?php  print_string("auth_dbpass","auth") ?>
    </td>
</tr>

<tr valign="top" class="required">
    <td align="right">auth_dbtable:</td>
    <td>
    <input name="auth_dbtable" type="text" size="30" value="<?php echo $config->auth_dbtable?>" />
    <?php  if (isset($err["auth_dbtable"])) formerr($err["auth_dbtable"]); ?>
    </td>
    <td>
    <?php  print_string("auth_dbtable","auth") ?>
    </td>
</tr>

<tr valign="top" class="required">
    <td align="right">auth_dbfielduser:</td>
    <td>
    <input name="auth_dbfielduser" type="text" size="30" value="<?php echo $config->auth_dbfielduser?>" />
    <?php  if (isset($err["auth_dbfielduser"])) formerr($err["auth_dbfielduser"]); ?>
    </td>
    <td>
    <?php  print_string("auth_dbfielduser","auth") ?>
    </td>
</tr>

<tr valign="top" class="required">
    <td align="right">auth_dbfieldpass:</td>
    <td>
    <input name="auth_dbfieldpass" type="text" size="30" value="<?php echo $config->auth_dbfieldpass?>" />
    <?php  if (isset($err["auth_dbfieldpass"])) formerr($err["auth_dbfieldpass"]); ?>
    </td>
    <td>
    <?php  print_string("auth_dbfieldpass","auth") ?>
    </td>
</tr>

<tr valign="top" class="required">
    <td align="right">auth_dbpasstype:</td>
    <td>
    <?php  
       $passtype["plaintext"] = get_string("plaintext", "auth");
       $passtype["md5"]       = get_string("md5", "auth");
       $passtype["internal"]  = get_string("internal", "auth");
       
       choose_from_menu($passtype, "auth_dbpasstype", $config->auth_dbpasstype, "");
    ?>
      
    </td>
    <td>
    <?php  print_string("auth_dbpasstype","auth") ?>
    </td>
</tr>

<?php print_auth_lock_options($auth, $user_fields, get_string("auth_dbextrafields","auth"), true, false);  ?>

<tr valign="top">
    <td align="right"><?php  print_string("instructions", "auth") ?>:</td>
    <td>
    <textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php  p($config->auth_instructions) ?></textarea> 
    </td>
    <td>
    <?php  print_string("authinstructions","auth") ?>
    <?php  helpbutton("text", get_string("helptext")) ?>
    </td>
</tr>
