if (!isset($roles[$roleid])) {
    // Weird - security always first!
    $roleid = 0;
}
if (!($enrol_manual = enrol_get_plugin('manual'))) {
    throw new coding_exception('Can not instantiate enrol_manual');
}
$instancename = $enrol_manual->get_instance_name($instance);
$PAGE->set_url('/enrol/manual/manage.php', array('enrolid' => $instance->id));
$PAGE->set_pagelayout('admin');
$PAGE->set_title($enrol_manual->get_instance_name($instance));
$PAGE->set_heading($course->fullname);
navigation_node::override_active_url(new moodle_url('/enrol/users.php', array('id' => $course->id)));
// Create the user selector objects.
$options = array('enrolid' => $enrolid, 'accesscontext' => $context);
$potentialuserselector = new enrol_manual_potential_participant('addselect', $options);
$currentuserselector = new enrol_manual_current_participant('removeselect', $options);
// Build the list of options for the enrolment period dropdown.
$unlimitedperiod = get_string('unlimited');
$periodmenu = array();
for ($i = 1; $i <= 365; $i++) {
    $seconds = $i * 86400;
    $periodmenu[$seconds] = get_string('numdays', '', $i);
}
// Work out the apropriate default setting.
if ($extendperiod) {
    $defaultperiod = $extendperiod;
} else {
    $defaultperiod = $instance->enrolperiod;
}
// Build the list of options for the starting from dropdown.