<?php // initialize variables

// general
if (!isset ($frm->enrol_ldap_host_url)) {
    $frm->enrol_ldap_host_url = '';
}
if (!isset ($frm->enrol_ldap_version )) {
    $frm->enrol_ldap_version = '';
}
if (!isset ($frm->enrol_ldap_bind_dn)) {
    $frm->enrol_ldap_bind_dn = '';
}
if (!isset ($frm->enrol_ldap_bind_pw)) {
    $frm->enrol_ldap_bind_pw = '';
}
if (!isset ($frm->enrol_ldap_search_sub)) {
    $frm->enrol_ldap_search_sub = '0';
}
// student & teacher enrol
if (!isset ($frm->enrol_ldap_student_contexts)) {
     $frm->enrol_ldap_student_contexts = '';
}
if (!isset ($frm->enrol_ldap_student_memberattribute)) {
     $frm->enrol_ldap_student_memberattribute = '';
}
if (!isset ($frm->enrol_ldap_teacher_contexts)) {
     $frm->enrol_ldap_teacher_contexts = '';
}
if (!isset ($frm->enrol_ldap_teacher_memberattribute)) {
     $frm->enrol_ldap_teacher_memberattribute = '';
}
if (!isset ($frm->enrol_ldap_objectclass)) {
     $frm->enrol_ldap_objectclass = '';
}
if (!isset ($frm->enrol_ldap_course_idnumber_updatelocal)) {
     $frm->enrol_ldap_course_idnumber_updatelocal = '';
}
// fields
if (!isset ($frm->enrol_ldap_course_idnumber)) {
    $frm->enrol_ldap_course_idnumber = '';
}
if (!isset ($frm->enrol_ldap_course_idnumber_updatelocal)) {
    $frm->enrol_ldap_course_idnumber_updatelocal = false;
}
if (!isset ($frm->enrol_ldap_course_idnumber_editlock)) {
    $frm->enrol_ldap_course_idnumber_editlock = false;
}
if (!isset ($frm->enrol_ldap_course_fullname)) {
    $frm->enrol_ldap_course_fullname = '';
}
if (!isset ($frm->enrol_ldap_course_fullname_updatelocal)) {
    $frm->enrol_ldap_course_fullname_updatelocal = false;
}
if (!isset ($frm->enrol_ldap_course_fullname_editlock)) {
    $frm->enrol_ldap_course_fullname_editlock = false;
}
if (!isset ($frm->enrol_ldap_course_shortname)) {
    $frm->enrol_ldap_course_shortname = '';
     }
if (!isset ($frm->enrol_ldap_course_shortname_updatelocal)) {
    $frm->enrol_ldap_course_shortname_updatelocal = false;
}
if (!isset ($frm->enrol_ldap_course_shortname_editlock)) {
    $frm->enrol_ldap_course_shortname_editlock = false;
}
if (!isset ($frm->enrol_ldap_course_summary)) {
    $frm->enrol_ldap_course_summary = '';
}
if (!isset ($frm->enrol_ldap_course_summary_updatelocal)) {
    $frm->enrol_ldap_course_summary_updatelocal = false;
}
if (!isset ($frm->enrol_ldap_course_summary_editlock)) {
    $frm->enrol_ldap_course_summary_editlock = false;
}
// autocreate
optional_variable($frm->enrol_ldap_autocreate, false);
optional_variable($frm->enrol_ldap_category, 1);
optional_variable($frm->enrol_ldap_template, '');

?>

<table cellspacing="0" cellpadding="5" border="0" align="center">
<tr>
   <td colspan="2">
        <h4><?php print_string("enrol_ldap_server_settings", "enrol_ldap") ?> </h4>
   </td>
</tr>
<tr valign="top">
    <td align="right">enrol_ldap_host_url:</td>
    <td>
        <input name="enrol_ldap_host_url" TYPE="text" SIZE="30" value="<?php echo $frm->enrol_ldap_host_url?>">
    <?php  if (isset($err["enrol_ldap_host_url"])) formerr($err["enrol_ldap_host_url"]); ?>
    </td>
    <td>
    <?php  print_string("enrol_ldap_host_url","enrol_ldap") ?>
    </td>
</tr>
<tr valign="top">
    <td align="right">enrol_ldap_version:</td>
    <td>
    <?php
       $versions[2] = "2";
       $versions[3] = "3";
       choose_from_menu($versions, "enrol_ldap_version", $frm->enrol_ldap_version, "");
        if (isset($err["enrol_ldap_version"])) formerr($err["enrol_ldap_version"]); 
    ?>
    </td>
    <td>
    <?php  print_string("enrol_ldap_version","enrol_ldap") ?>
    </td>
</tr>

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

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

<tr valign="top">
    <td align="right">ldap_search_sub:</td>
    <td>
<?php
    $choices = array();
    $choices["0"] = get_string("no");
    $choices["1"] = get_string("yes");
    choose_from_menu ($choices, "enrol_ldap_search_sub", $frm->enrol_ldap_search_sub, "");
?>
    <?php  if (isset($err["enrol_ldap_search_sub"])) formerr($err["enrol_ldap_search_sub"]); ?>
    </td><td>
    <?php  print_string("enrol_ldap_search_sub","enrol_ldap") ?>
    </td>
</tr>

<tr>
   <td colspan="2">
        <h4><?php print_string("enrol_ldap_student_settings", "enrol_ldap") ?> </h4>
   </td>
</tr>
<tr valign="top">
    <td align="right">enrol_ldap_student_contexts:</td>
    <td>
    <input name="enrol_ldap_student_contexts" TYPE="text" SIZE="30 "value="<?php echo $frm->enrol_ldap_student_contexts?>">
    <?php  if (isset($err["enrol_ldap_student_contexts"])) formerr($err["enrol_ldap_student_contexts"]); ?>
    </td>
    <td>
    <?php  print_string("enrol_ldap_student_contexts","enrol_ldap") ?>
    </td>
</tr>
<tr valign="top">
        <td align="right">enrol_ldap_student_memberattribute:</td>
        <td>
    <input name="enrol_ldap_student_memberattribute" type="text" size="30" value="<?php echo $frm->enrol_ldap_student_memberattribute?>">
    <?php  if (isset($err["enrol_ldap_student_memberattribute"])) formerr($err["enrol_ldap_student_memberattribute"]); ?>
    </td><td>
    <?php  print_string("enrol_ldap_student_memberattribute","enrol_ldap") ?>
    </td>
</tr>

<tr>
   <td colspan="2">
        <h4><?php print_string("enrol_ldap_teacher_settings", "enrol_ldap") ?> </h4>
   </td>
</tr>
<tr valign="top">
    <td align="right">enrol_ldap_teacher_contexts:</td>
    <td>
    <input name="enrol_ldap_teacher_contexts" TYPE="text" SIZE="30 "value="<?php echo $frm->enrol_ldap_teacher_contexts?>">
    <?php  if (isset($err["enrol_ldap_teacher_contexts"])) formerr($err["enrol_ldap_teacher_contexts"]); ?>
    </td>
    <td>
    <?php  print_string("enrol_ldap_teacher_contexts","enrol_ldap") ?>
    </td>
</tr>
<tr valign="top">
        <td align="right">enrol_ldap_teacher_memberattribute:</td>
        <td>
    <input name="enrol_ldap_teacher_memberattribute" type="text" size="30" value="<?php echo $frm->enrol_ldap_teacher_memberattribute?>">
    <?php  if (isset($err["enrol_ldap_teacher_memberattribute"])) formerr($err["enrol_ldap_teacher_memberattribute"]); ?>
    </td><td>
    <?php  print_string("enrol_ldap_teacher_memberattribute","enrol_ldap") ?>
    </td>
</tr>

<tr>
   <td colspan="2">
        <h4><?php print_string("enrol_ldap_course_settings", "enrol_ldap") ?> </h4>
   </td>
</tr>
<tr valign="top">
    <td align="right">enrol_ldap_objectclass:</td>
    <td>
    <input name=enrol_ldap_objectclass type="text" size="30" value="<?php echo $frm->enrol_ldap_objectclass?>">
    <?php  if (isset($err["enrol_ldap_objectclass"])) formerr($err["enrol_ldap_objectclass"]); ?>
    </td>
    <td>
    <?php  print_string("enrol_ldap_objectclass","enrol_ldap") ?>
    </td>
</tr>
<tr valign="top">
        <td align="right">enrol_ldap_course_idnumber:</td>
        <td>
    <input name="enrol_ldap_course_idnumber" type="text" size="30" value="<?php echo $frm->enrol_ldap_course_idnumber?>">
    <?php  if (isset($err["enrol_ldap_course_idnumber"])) formerr($err["enrol_ldap_course_idnumber"]); ?>
    <div align="right">
    <?php  print_string("enrol_ldap_updatelocal", "enrol_ldap") ?>
    <select name="enrol_ldap_course_idnumber_updatelocal">
        <option value="0" <?php echo ($frm->enrol_ldap_course_idnumber_updatelocal ? '' : 'selected="yes"') ?> >
            <?php  print_string("no")  ?></option>
        <option value="1" <?php echo ($frm->enrol_ldap_course_idnumber_updatelocal ? 'selected="yes"' : '') ?> >
            <?php  print_string("yes") ?></option>
    </select><BR>
    <?php  print_string("enrol_ldap_editlock", "enrol_ldap") ?>
    <select name="enrol_ldap_course_idnumber_editlock">
        <option value="0" <?php echo ($frm->enrol_ldap_course_idnumber_editlock ? '' : 'selected="yes"') ?> >
            <?php  print_string("no")  ?></option>
        <option value="1" <?php echo ($frm->enrol_ldap_course_idnumber_editlock ? 'selected="yes"' : '') ?> >
            <?php  print_string("yes") ?></option>
    </select></div>  
    </td><td>
    <?php  print_string("enrol_ldap_course_idnumber","enrol_ldap") ?>
    </td>
</tr>
<tr valign="top">
        <td align="right">enrol_ldap_course_shortname:</td>
        <td>
    <input name="enrol_ldap_course_shortname" type="text" size="30" value="<?php echo $frm->enrol_ldap_course_shortname?>">
    <?php  if (isset($err["enrol_ldap_course_shortname"])) formerr($err["enrol_ldap_course_shortname"]); ?>
    <div align="right">
    <?php  print_string("enrol_ldap_updatelocal", "enrol_ldap") ?>
    <select name="enrol_ldap_course_shortname_updatelocal">
        <option value="0" <?php echo ($frm->enrol_ldap_course_shortname_updatelocal ? '' : 'selected="yes"') ?> >
            <?php  print_string("no")  ?></option>
        <option value="1" <?php echo ($frm->enrol_ldap_course_shortname_updatelocal ? 'selected="yes"' : '') ?> >
            <?php  print_string("yes") ?></option>
    </select><BR>
    <?php  print_string("enrol_ldap_editlock", "enrol_ldap") ?>
    <select name="enrol_ldap_course_shortname_editlock">
        <option value="0" <?php echo ($frm->enrol_ldap_course_shortname_editlock ? '' : 'selected="yes"') ?> >
            <?php  print_string("no")  ?></option>
        <option value="1" <?php echo ($frm->enrol_ldap_course_shortname_editlock ? 'selected="yes"' : '') ?> >
            <?php  print_string("yes") ?></option>
    </select></div>
    </td><td>
    <?php  print_string("enrol_ldap_course_shortname","enrol_ldap") ?>
    </td>
</tr>

<tr valign="top">
        <td align="right">enrol_ldap_course_fullname:</td>
        <td>
    <input name="enrol_ldap_course_fullname" type="text" size="30" value="<?php echo $frm->enrol_ldap_course_fullname ?>">
    <?php  if (isset($err["enrol_ldap_course_fullname"])) formerr($err["enrol_ldap_course_fullname"]); ?>
    <div align="right">
    <?php  print_string("enrol_ldap_updatelocal", "enrol_ldap") ?>
    <select name="enrol_ldap_course_fullname_updatelocal">
        <option value="0" <?php echo ($frm->enrol_ldap_course_fullname_updatelocal ? '' : 'selected="yes"') ?> >
            <?php  print_string("no")  ?></option>
        <option value="1" <?php echo ($frm->enrol_ldap_course_fullname_updatelocal ? 'selected="yes"' : '') ?> >
            <?php  print_string("yes") ?></option>
    </select><BR>
    <?php  print_string("enrol_ldap_editlock", "enrol_ldap") ?>
    <select name="enrol_ldap_course_idnumber_editlock">
        <option value="0" <?php echo ($frm->enrol_ldap_course_fullname_editlock ? '' : 'selected="yes"') ?> >
            <?php  print_string("no")  ?></option>
        <option value="1" <?php echo ($frm->enrol_ldap_course_fullname_editlock ? 'selected="yes"' : '') ?> >
            <?php  print_string("yes") ?></option>
    </select></div>
    </td><td>
    <?php  print_string("enrol_ldap_course_fullname","enrol_ldap") ?>
    </td>
</tr>

<tr valign="top">
        <td align="right">enrol_ldap_course_summary:</td>
        <td>
    <input name="enrol_ldap_course_summary" type="text" size="30" value="<?php echo $frm->enrol_ldap_course_summary?>">    
    <?php  if (isset($err["enrol_ldap_course_summary"])) formerr($err["enrol_ldap_course_summary"]); ?>
    <div align="right">
    <?php  print_string("enrol_ldap_updatelocal", "enrol_ldap") ?>
    <select name="enrol_ldap_course_summary_updatelocal">
        <option value="0" <?php echo ($frm->enrol_ldap_course_summary_updatelocal ? '' : 'selected="yes"') ?> >
            <?php  print_string("no")  ?></option>
        <option value="1" <?php echo ($frm->enrol_ldap_course_summary_updatelocal ? 'selected="yes"' : '') ?> >
            <?php  print_string("yes") ?></option>
    </select><BR>
    <?php  print_string("enrol_ldap_editlock", "enrol_ldap") ?>
    <select name="enrol_ldap_course_summary_editlock">
        <option value="0" <?php echo ($frm->enrol_ldap_course_summary_editlock ? '' : 'selected="yes"') ?> >
            <?php  print_string("no")  ?></option>
        <option value="1" <?php echo ($frm->enrol_ldap_course_summary_editlock ? 'selected="yes"' : '') ?> >
            <?php  print_string("yes") ?></option>
    </select></div>
    </td><td>
    <?php  print_string("enrol_ldap_course_summary","enrol_ldap") ?>
    </td>
</tr>

<tr>
   <td colspan="2">
        <h4><?php print_string("enrol_ldap_autocreation_settings", "enrol_ldap") ?> </h4>
   </td>
</tr>
<tr valign="top">
    <td align="right">enrol_ldap_autocreate:</td>
    <td>
    <?php
       choose_from_menu(array('0'=>'no','1'=>'yes'), "enrol_ldap_autocreate", $frm->enrol_ldap_autocreate, "");
           if (isset($err["enrol_ldap_autocreate"])) formerr($err["enrol_ldap_autocreate"]); 
    ?>
    </td>
    <td>
    <?php  print_string("enrol_ldap_autocreate","enrol_ldap") ?>
    </td>
</tr>
<tr valign="top">
        <td align="right">enrol_ldap_category:</td>
        <td>
    <?php
           $displaylist = array();
           $parentlist = array();
           make_categories_list($displaylist, $parentlist);
           choose_from_menu($displaylist, "enrol_ldap_category", $frm->enrol_ldap_category, "");
           
    ?>
    <?php  if (isset($err["enrol_ldap_category"])) formerr($err["enrol_ldap_category"]); ?>
    </td><td>
    <?php  print_string("enrol_ldap_category","enrol_ldap") ?>
    </td>
</tr>

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

<tr>
   <td colspan="2">
        <h4><?php print_string("enrol_ldap_general_options", "enrol_ldap") ?> </h4>
   </td>
</tr>

</table>
