Beispiel #1
0
    echo format_text($course->summary, $course->summaryformat, $options, $course->id);
    print_collapsible_region_end();
}
$error = '';
$lastfetchenrolments = get_config('mnetservice_enrol', 'lastfetchenrolments');
if (!$usecache or empty($lastfetchenrolments) or time() - $lastfetchenrolments > 600) {
    // fetch fresh data from remote if we just came from the course selection screen
    // or every 10 minutes
    $usecache = false;
    $result = $service->req_course_enrolments($host->id, $course->remoteid, $usecache);
    if ($result !== true) {
        $error .= $service->format_error_message($result);
    }
}
// user selectors
$currentuserselector = new mnetservice_enrol_existing_users_selector('removeselect', array('hostid' => $host->id, 'remotecourseid' => $course->remoteid));
$potentialuserselector = new mnetservice_enrol_potential_users_selector('addselect', array('hostid' => $host->id, 'remotecourseid' => $course->remoteid));
// process incoming enrol request
if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
    $userstoassign = $potentialuserselector->get_selected_users();
    if (!empty($userstoassign)) {
        foreach ($userstoassign as $adduser) {
            $user = $DB->get_record('user', array('id' => $adduser->id));
            $result = $service->req_enrol_user($user, $course);
            if ($result !== true) {
                $error .= $service->format_error_message($result);
            }
        }
        $potentialuserselector->invalidate_selected_users();
        $currentuserselector->invalidate_selected_users();
    }