芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/mnet/service/enrol/course.php
. /** * Page to enrol our users into remote courses * * @package plugintype * @subpackage pluginname * @copyright 2010 David Mudrak
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require(__DIR__.'/../../../config.php'); require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->dirroot.'/mnet/service/enrol/locallib.php'); require_sesskey(); $hostid = required_param('host', PARAM_INT); // remote host id in our mnet_host table $courseid = required_param('course', PARAM_INT); // id of the course in our cache table $usecache = optional_param('usecache', true, PARAM_BOOL); // use cached list of enrolments admin_externalpage_setup('mnetenrol', '', array('host'=>$hostid, 'course'=>$courseid, 'usecache'=>1, 'sesskey'=>sesskey()), new moodle_url('/mnet/service/enrol/course.php')); $service = mnetservice_enrol::get_instance(); if (!$service->is_available()) { echo $OUTPUT->box(get_string('mnetdisabled','mnet'), 'noticebox'); echo $OUTPUT->footer(); die(); } // remote hosts that may publish remote enrolment service and we are subscribed to it $hosts = $service->get_remote_publishers(); if (empty($hosts[$hostid])) { print_error('wearenotsubscribedtothishost', 'mnetservice_enrol'); } $host = $hosts[$hostid]; $course = $DB->get_record('mnetservice_enrol_courses', array('id'=>$courseid, 'hostid'=>$host->id), '*', MUST_EXIST); echo $OUTPUT->header(); // course name $icon = $OUTPUT->pix_icon('i/course', get_string('category')); echo $OUTPUT->heading($icon . s($course->fullname)); // collapsible course summary if (!empty($course->summary)) { $options = new stdClass(); $options->trusted = false; $options->para = false; $options->filter = false; $options->noclean = false; $options->overflowdiv = true; print_collapsible_region_start('remotecourse summary', 'remotecourse-summary', get_string('coursesummary'), false, true); echo format_text($course->summary, $course->summaryformat, $options); 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(); } } // process incoming unenrol request if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) { $userstounassign = $currentuserselector->get_selected_users(); if (!empty($userstounassign)) { foreach($userstounassign as $removeuser) { $user = $DB->get_record('user', array('id'=>$removeuser->id)); $result = $service->req_unenrol_user($user, $course); if ($result !== true) { $error .= $service->format_error_message($result); } } $potentialuserselector->invalidate_selected_users(); $currentuserselector->invalidate_selected_users(); } } if (!empty($error)) { echo $OUTPUT->box($error, 'generalbox error'); } // print form to enrol our students ?>
display() ?>
rolename); ?>
display() ?>
id; $params['remotecourseid'] = $course->remoteid; if ($enrolments = $DB->get_records_sql($sql, $params)) { echo $OUTPUT->heading(get_string('otherenrolledusers', 'mnetservice_enrol'), 3); $table = new html_table(); $table->attributes['class'] = 'generaltable otherenrolledusers'; $table->head = array(get_string('fullnameuser'), get_string('role'), get_string('plugin')); foreach ($enrolments as $enrolleduser) { $table->data[] = array(fullname($enrolleduser), s($enrolleduser->rolename), s($enrolleduser->plugin)); } echo html_writer::table($table); } if ($usecache) { echo $OUTPUT->single_button(new moodle_url($PAGE->url, array('usecache'=>0, 'sesskey'=>sesskey())), get_string('refetch', 'mnetservice_enrol'), 'get'); } echo $OUTPUT->single_button(new moodle_url('/mnet/service/enrol/host.php', array('id'=>$host->id)), get_string('availablecourseson', 'mnetservice_enrol', s($host->hostname)), 'get'); echo $OUTPUT->footer();