<?php
    $yesno = array('0'=>get_string('no'), '1'=>get_string('yes'));
?>

<table cellspacing="0" cellpadding="5" border="0" class="boxaligncenter">
<tr>
<th colspan="2" scope="col">
    <?php print_string("server_settings", "enrol_database") ?>
</th>
</tr>
<tr>
    <td align="right">enrol_dbtype:</td>
    <td>
    <?php  
       $dbtypes = array("access","ado_access", "ado", "ado_mssql", "borland_ibase", "csv", "db2", "fbsql", "firebird", "ibase", "informix72", "informix", "mssql", "mssql_n", "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;
       }
       if (!isset($frm->enrol_dbtype)) {
           $frm->enrol_dbtype = 'mysql';
       }
       choose_from_menu($dboptions, "enrol_dbtype", $frm->enrol_dbtype, '', '', '');
    ?>
      
    </td>
    <td>
    <?php  print_string("dbtype","enrol_database") ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_dbhost:</td>
    <td>
    <?php 
        if (!isset($frm->enrol_dbhost)) {
            $frm->enrol_dbhost = '';
        } 
    ?>
        <input size="15" type="text" name="enrol_dbhost" value="<?php p($frm->enrol_dbhost) ?>" />
    </td>
    <td>
    <?php  print_string("dbhost","enrol_database") ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_dbuser:</td>
    <td>
        <input size="15" type="text" name="enrol_dbuser" value="<?php echo $frm->enrol_dbuser ?>" />
    </td>
    <td>
    <?php  print_string("dbuser","enrol_database") ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_dbpass:</td>
    <td>
        <input size="15" type="password" name="enrol_dbpass" value="<?php echo $frm->enrol_dbpass ?>" />
    </td>
    <td>
    <?php  print_string("dbpass","enrol_database") ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_dbname:</td>
    <td>
        <input size="15" type="text" name="enrol_dbname" value="<?php echo $frm->enrol_dbname ?>" />
    </td>
    <td>
    <?php  print_string("dbname","enrol_database") ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_dbtable:</td>
    <td>
        <input size="15" type="text" name="enrol_dbtable" value="<?php echo $frm->enrol_dbtable ?>" />
    </td>
    <td>
    <?php  print_string("dbtable","enrol_database") ?>
    </td>
</tr>
<tr>
    <th colspan="2" scope="col">
        <?php print_string("remote_fields_mapping", "enrol_database") ?>
    </th>
</tr>
<tr>
    <td align="right">enrol_localcoursefield:</td>
    <td>
        <input size="15" type="text" name="enrol_localcoursefield" value="<?php echo $frm->enrol_localcoursefield ?>" />
    </td>
    <td>
    <?php  print_string("localcoursefield","enrol_database") ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_localuserfield:</td>
    <td>
        <input size="15" type="text" name="enrol_localuserfield" value="<?php echo $frm->enrol_localuserfield ?>" />
    </td>
    <td>
    <?php  print_string("localuserfield","enrol_database") ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_db_localrolefield:</td>
    <td>
        <input size="15" type="text" name="enrol_db_localrolefield" value="<?php echo $frm->enrol_db_localrolefield ?>" />
    </td>
    <td>
    <?php  print_string("localrolefield","enrol_database") ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_remotecoursefield:</td>
    <td>
        <input size="15" type="text" name="enrol_remotecoursefield" value="<?php echo $frm->enrol_remotecoursefield ?>" />
    </td>
    <td>
    <?php  print_string("remotecoursefield","enrol_database") ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_remoteuserfield:</td>
    <td>
        <input size="15" type="text" name="enrol_remoteuserfield" value="<?php echo $frm->enrol_remoteuserfield ?>" />
    </td>
    <td>
    <?php  print_string("remoteuserfield","enrol_database") ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_db_remoterolefield:</td>
    <td>
        <input size="15" type="text" name="enrol_db_remoterolefield" value="<?php echo $frm->enrol_db_remoterolefield ?>" />
    </td>
    <td>
    <?php  print_string("remoterolefield","enrol_database") ?>
    </td>
</tr>

<tr>
   <th colspan="2" scope="col">
        <?php print_string('roles', 'role') ?>
   </th>
</tr>
<tr>
    <td align="right">enrol_db_defaultcourseroleid:</td>
    <td>
    <?php
        $sitecontext = get_context_instance(CONTEXT_SYSTEM);
        $assignableroles = get_assignable_roles($sitecontext);
        $assignableroles = array('' => get_string('default')) + $assignableroles;
    
        choose_from_menu($assignableroles, 'enrol_db_defaultcourseroleid', $frm->enrol_db_defaultcourseroleid, '');
        if (isset($err['enrol_db_defaultcourseroleid'])) formerr($err['enrol_db_defaultcourseroleid']); 
    ?>
    </td>
    <td>
    <?php  print_string("defaultcourseroleid","enrol_database") ?>
    </td>
</tr>

<tr>
   <th colspan="2" scope="col">
        <?php print_string("enrol_database_autocreation_settings", "enrol_database") ?>
   </th>
</tr>
<tr>
    <td align="right">enrol_db_autocreate:</td>
    <td>
    <?php
       choose_from_menu($yesno, "enrol_db_autocreate", $frm->enrol_db_autocreate, "");
           if (isset($err["enrol_db_autocreate"])) formerr($err["enrol_db_autocreate"]); 
    ?>
    </td>
    <td>
    <?php  print_string("autocreate","enrol_database") ?>
    </td>
</tr>

<tr>
        <td align="right">enrol_db_category:</td>
        <td>
    <?php
           $displaylist = array();
           $parentlist = array();
           make_categories_list($displaylist, $parentlist);
           choose_from_menu($displaylist, "enrol_db_category", $frm->enrol_db_category, "");
           
    ?>
    <?php  if (isset($err["enrol_db_category"])) formerr($err["enrol_db_category"]); ?>
    </td><td>
    <?php  print_string("category","enrol_database") ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_db_template:</td>
        <td>
    <input name="enrol_db_template" type="text" size="30" value="<?php echo $frm->enrol_db_template?>" />
    <?php  if (isset($err["enrol_db_template"])) formerr($err["enrol_db_template"]); ?>
    </td><td>
    <?php  print_string("template","enrol_database") ?>
    </td>
</tr>

<tr>
   <th colspan="2" scope="col">
        <?php print_string("general_options", "enrol_database") ?>
   </th>
</tr>

<tr>
    <td align="right">enrol_db_ignorehiddencourse:</td>
    <td>
    <?php
        choose_from_menu($yesno, "enrol_db_ignorehiddencourse", $frm->enrol_db_ignorehiddencourse, "");
        if (isset($err['enrol_db_ignorehiddencourse'])) {
            formerr($err['enrol_db_ignorehiddencourse']);
        }
    ?>
    </td>
    <td>
        <?php print_string('ignorehiddencourse', 'enrol_database' ); ?>
    </td>
</tr>

<tr>
    <td align="right">enrol_db_disableunenrol:</td>
    <td>
    <?php
        choose_from_menu($yesno, "enrol_db_disableunenrol", $frm->enrol_db_disableunenrol, "");
        if (isset($err['enrol_db_disableunenrol'])) {
            formerr($err['enrol_db_disableunenrol']);
        }
    ?>
    </td>
    <td>
        <?php print_string('disableunenrol', 'enrol_database' ); ?>
    </td>
</tr>
</table>
