<?php

    if ($course->password != '' and !(isguestuser() and !empty($USER->enrolkey[$course->id]))) {   // password
        echo $OUTPUT->box_start('generalbox centerpara');
        echo '<p align="center">';

        $this->print_enrolmentkeyfrom( $course );
 ?>
      </p>

      <p align="center"><?php if (! empty($this->errormsg)) {echo $OUTPUT->error_text($this->errormsg);} ?></p>


      <form method="post" action="enrol.php">
        <table align="center" width="100%">
          <tr>
            <td align="right"><?php print_string("enrolmentkey") ?>:</td>
            <td>
              <input type="password" name="password" size="20" value="<?php p($password) ?>"  />
              <input type="hidden" name="id" value="<?php p($course->id) ?>"  />
              <input type="hidden" name="enrol" value="manual" />
              <input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
              <input type="submit" value="<?php print_string("enrolme") ?>" />
            </td>
          </tr>
        </table>
      </form>
      <br />

      <div align="center">
      <form action="<?php p($CFG->wwwroot)?>/index.php" method="post">
      <input type="submit" value="<?php print_string("cancel") ?>" />
      </form>
      </div>

<?php
        echo $OUTPUT->box_end();
    }


    if (isguestuser()) {
        echo $OUTPUT->box_start('centerpara');
        $loginurl = get_login_url();
        echo $OUTPUT->single_button($loginurl, get_string('login'));
        echo $OUTPUT->box_end();
    }
?>
