<?php 

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

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

      <p align="center"><?php if (! empty($this->errormsg)) {formerr($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 
        print_box_end();
    }


    if (isguestuser()) {
        print_box_start('centerpara');
        if (empty($CFG->loginhttps)) {
            $loginurl = $CFG->wwwroot .'/login/index.php';
        } else {
            $wwwroot = str_replace('http:','https:', $CFG->wwwroot);
            $loginurl = $wwwroot .'/login/index.php';
        }
        print_single_button($loginurl, null, get_string('login'));
        print_box_end();
    }
?>
