<?php

// set to defaults if undefined
if (!isset($config->host)) {
    $config->host = '127.0.0.1';
}
if (!isset($config->type)) {
    $config->type = 'pop3notls';
}
if (!isset($config->port)) {
    $config->port = '110';
}
if (!isset($config->mailbox)) {
    $config->mailbox = 'INBOX';
}
if (!isset($config->changepasswordurl)) {
    $config->changepasswordurl = '';
}

?>
<table cellspacing="0" cellpadding="5" border="0">

<tr valign="top" class="required">
    <td align="right"><label for="host"><?php print_string('auth_pop3host_key', 'auth_pop3') ?>: </label></td>
    <td>
        <input name="host" id="host" type="text" size="30" value="<?php echo $config->host ?>" />
        <?php

        if (isset($err['host'])) {
            echo $OUTPUT->error_text($err['host']);
        }

        ?>
    </td>
    <td>
        <?php

        print_string('auth_pop3host', 'auth_pop3');
        print_string('auth_multiplehosts', 'auth');

        ?>
    </td>
</tr>

<tr valign="top" class="required">
    <td align="right"><?php echo html_writer::label(get_string('auth_pop3type_key', 'auth_pop3'), 'menutype'); ?>: </td>
    <td>
        <?php

        $pop3types = array('pop3', 'pop3cert', 'pop3notls');
        foreach ($pop3types as $pop3type) {
            $pop3options[$pop3type] = $pop3type;
        }
        echo html_writer::select($pop3options, 'type', $config->type, false);

        ?>
    </td>
    <td><?php print_string('auth_pop3type', 'auth_pop3') ?></td>
</tr>

<tr valign="top" class="required">
    <td align="right"><label for="port"><?php print_string('auth_pop3port_key', 'auth_pop3') ?>: </label></td>
    <td>
        <input name="port" id="port" type="text" size="6" value="<?php echo $config->port ?>" />
        <?php

        if (isset($err['port'])) {
            echo $OUTPUT->error_text($err['port']);
        }

        ?>
    </td>
    <td><?php print_string('auth_pop3port', 'auth_pop3') ?></td>
</tr>

<tr valign="top" class="required">
    <td align="right"><label for="mailbox"><?php print_string('auth_pop3mailbox_key', 'auth_pop3') ?>: </label></td>
    <td>
        <input name="mailbox" id="mailbox" type="text" size="6" value="<?php echo $config->mailbox ?>" />
        <?php

        if (isset($err['mailbox'])) {
            echo $OUTPUT->error_text($err['mailbox']);
        }

        ?>
    </td>
    <td><?php print_string('auth_pop3mailbox', 'auth_pop3') ?></td>
</tr>

<tr valign="top">
    <td align="right"><label for="changepasswordurl"><?php print_string('auth_pop3changepasswordurl_key', 'auth_pop3') ?>: </label></td>
    <td>
        <input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
        <?php

        if (isset($err['changepasswordurl'])) {
            echo $OUTPUT->error_text($err['changepasswordurl']);
        }

        ?>
    </td>
    <td><?php print_string('changepasswordhelp', 'auth') ?></td>
</tr>

<?php

print_auth_lock_options($this->authtype, $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false);

?>
</table>
