本文整理汇总了PHP中get_my_remotecourses函数的典型用法代码示例。如果您正苦于以下问题:PHP get_my_remotecourses函数的具体用法?PHP get_my_remotecourses怎么用?PHP get_my_remotecourses使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_my_remotecourses函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: block_mystats_mycourses
function block_mystats_mycourses()
{
global $USER;
$mycourses = array();
$count = 0;
$enrolledcourses = enrol_get_users_courses($USER->id);
foreach ($enrolledcourses as $course) {
if (isset($USER->lastcourseaccess[$course->id])) {
$course->lastaccess = $USER->lastcourseaccess[$course->id];
} else {
$course->lastaccess = 0;
}
$mycourses[$course->id] = $course;
$count++;
}
if (is_enabled_auth('mnet')) {
$remotecourses = get_my_remotecourses();
foreach ($remotecourses as $course) {
$mycourses[$course->id] = $course;
$count++;
}
}
return $mycourses;
}
示例2: get_remote_courses
function get_remote_courses()
{
global $CFG, $USER, $OUTPUT;
if (!is_enabled_auth('mnet')) {
// no need to query anything remote related
return;
}
$icon = '<img src="' . $OUTPUT->pix_url('i/mnethost') . '" class="icon" alt="" />';
// shortcut - the rest is only for logged in users!
if (!isloggedin() || isguestuser()) {
return false;
}
if ($courses = get_my_remotecourses()) {
$this->content->items[] = get_string('remotecourses', 'mnet');
$this->content->icons[] = '';
foreach ($courses as $course) {
$coursecontext = context_course::instance($course->id);
$this->content->items[] = "<a title=\"" . format_string($course->shortname, true, array('context' => $coursecontext)) . "\" " . "href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$course->hostid}&wantsurl=/course/view.php?id={$course->remoteid}\">" . $icon . format_string(get_course_display_name_for_list($course)) . "</a>";
}
// if we listed courses, we are done
return true;
}
if ($hosts = get_my_remotehosts()) {
$this->content->items[] = get_string('remotehosts', 'mnet');
$this->content->icons[] = '';
foreach ($USER->mnet_foreign_host_array as $somehost) {
$this->content->items[] = $somehost['count'] . get_string('courseson', 'mnet') . '<a title="' . $somehost['name'] . '" href="' . $somehost['url'] . '">' . $icon . $somehost['name'] . '</a>';
}
// if we listed hosts, done
return true;
}
return false;
}
示例3: print_my_moodle
/**
* Prints custom user information on the home page.
* Over time this can include all sorts of information
*/
function print_my_moodle()
{
global $USER, $CFG, $DB, $OUTPUT;
if (!isloggedin() or isguestuser()) {
print_error('nopermissions', '', '', 'See My Moodle');
}
$courses = enrol_get_my_courses('summary', 'visible DESC,sortorder ASC');
$rhosts = array();
$rcourses = array();
if (!empty($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode === 'strict') {
$rcourses = get_my_remotecourses($USER->id);
$rhosts = get_my_remotehosts();
}
if (!empty($courses) || !empty($rcourses) || !empty($rhosts)) {
if (!empty($courses)) {
echo '<ul class="unlist">';
foreach ($courses as $course) {
if ($course->id == SITEID) {
continue;
}
echo '<li>';
print_course($course);
echo "</li>\n";
}
echo "</ul>\n";
}
// MNET
if (!empty($rcourses)) {
// at the IDP, we know of all the remote courses
foreach ($rcourses as $course) {
print_remote_course($course, "100%");
}
} elseif (!empty($rhosts)) {
// non-IDP, we know of all the remote servers, but not courses
foreach ($rhosts as $host) {
print_remote_host($host, "100%");
}
}
unset($course);
unset($host);
if ($DB->count_records("course") > count($courses) + 1) {
// Some courses not being displayed
echo "<table width=\"100%\"><tr><td align=\"center\">";
print_course_search("", false, "short");
echo "</td><td align=\"center\">";
echo $OUTPUT->single_button("{$CFG->wwwroot}/course/index.php", get_string("fulllistofcourses"), "get");
echo "</td></tr></table>\n";
}
} else {
if ($DB->count_records("course_categories") > 1) {
echo $OUTPUT->box_start("categorybox");
print_whole_category_list();
echo $OUTPUT->box_end();
} else {
print_courses(0);
}
}
}
示例4: frontpage_my_courses
/**
* Returns HTML to print list of courses user is enrolled to for the frontpage
*
* Also lists remote courses or remote hosts if MNET authorisation is used
*
* @return string
*/
public function frontpage_my_courses()
{
global $USER, $CFG, $DB;
if (!isloggedin() or isguestuser()) {
return '';
}
$output = '';
if (!empty($CFG->navsortmycoursessort)) {
// sort courses the same as in navigation menu
$sortorder = 'visible DESC,' . $CFG->navsortmycoursessort . ' ASC';
} else {
$sortorder = 'visible DESC,sortorder ASC';
}
$courses = enrol_get_my_courses('summary, summaryformat', $sortorder);
$rhosts = array();
$rcourses = array();
if (!empty($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode === 'strict') {
$rcourses = get_my_remotecourses($USER->id);
$rhosts = get_my_remotehosts();
}
if (!empty($courses) || !empty($rcourses) || !empty($rhosts)) {
$chelper = new coursecat_helper();
if (count($courses) > $CFG->frontpagecourselimit) {
// There are more enrolled courses than we can display, display link to 'My courses'.
$totalcount = count($courses);
$courses = array_slice($courses, 0, $CFG->frontpagecourselimit, true);
$chelper->set_courses_display_options(array('viewmoreurl' => new moodle_url('/my/'), 'viewmoretext' => new lang_string('mycourses')));
} else {
// All enrolled courses are displayed, display link to 'All courses' if there are more courses in system.
$chelper->set_courses_display_options(array('viewmoreurl' => new moodle_url('/course/index.php'), 'viewmoretext' => new lang_string('fulllistofcourses')));
$totalcount = $DB->count_records('course') - 1;
}
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_attributes(array('class' => 'frontpage-course-list-enrolled'));
$output .= $this->coursecat_courses($chelper, $courses, $totalcount);
// MNET
if (!empty($rcourses)) {
// at the IDP, we know of all the remote courses
$output .= html_writer::start_tag('div', array('class' => 'courses'));
foreach ($rcourses as $course) {
$output .= $this->frontpage_remote_course($course);
}
$output .= html_writer::end_tag('div');
// .courses
} elseif (!empty($rhosts)) {
// non-IDP, we know of all the remote servers, but not courses
$output .= html_writer::start_tag('div', array('class' => 'courses'));
foreach ($rhosts as $host) {
$output .= $this->frontpage_remote_host($host);
}
$output .= html_writer::end_tag('div');
// .courses
}
}
return $output;
}
示例5: print_my_moodle
function print_my_moodle()
{
/// Prints custom user information on the home page.
/// Over time this can include all sorts of information
global $USER, $CFG;
if (empty($USER->id)) {
error("It shouldn't be possible to see My Moodle without being logged in.");
}
$courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', array('summary'));
$rhosts = array();
$rcourses = array();
if (!empty($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode === 'strict') {
$rcourses = get_my_remotecourses($USER->id);
$rhosts = get_my_remotehosts();
}
if (!empty($courses) || !empty($rcourses) || !empty($rhosts)) {
if (!empty($courses)) {
echo '<ul class="unlist">';
foreach ($courses as $course) {
if ($course->id == SITEID) {
continue;
}
echo '<li>';
print_course($course);
echo "</li>\n";
}
echo "</ul>\n";
}
// MNET
if (!empty($rcourses)) {
// at the IDP, we know of all the remote courses
foreach ($rcourses as $course) {
print_remote_course($course, "100%");
}
} elseif (!empty($rhosts)) {
// non-IDP, we know of all the remote servers, but not courses
foreach ($rhosts as $host) {
print_remote_host($host, "100%");
}
}
unset($course);
unset($host);
if (count_records("course") > count($courses) + 1) {
// Some courses not being displayed
echo "<table width=\"100%\"><tr><td align=\"center\">";
print_course_search("", false, "short");
echo "</td><td align=\"center\">";
print_single_button("{$CFG->wwwroot}/course/index.php", NULL, get_string("fulllistofcourses"), "get");
echo "</td></tr></table>\n";
}
} else {
if (count_records("course_categories") > 1) {
print_simple_box_start("center", "100%", "#FFFFFF", 5, "categorybox");
print_whole_category_list();
print_simple_box_end();
} else {
print_courses(0);
}
}
}
示例6: block_course_overview_get_sorted_courses
/**
* Return sorted list of user courses
*
* @return array list of sorted courses and count of courses.
*/
function block_course_overview_get_sorted_courses()
{
global $USER;
$limit = block_course_overview_get_max_user_courses();
$courses = enrol_get_my_courses('id, shortname, fullname, modinfo, sectioncache');
$site = get_site();
if (array_key_exists($site->id, $courses)) {
unset($courses[$site->id]);
}
foreach ($courses as $c) {
if (isset($USER->lastcourseaccess[$c->id])) {
$courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
} else {
$courses[$c->id]->lastaccess = 0;
}
}
// Get remote courses.
$remotecourses = array();
if (is_enabled_auth('mnet')) {
$remotecourses = get_my_remotecourses();
}
// Remote courses will have -ve remoteid as key, so it can be differentiated from normal courses
foreach ($remotecourses as $id => $val) {
$remoteid = $val->remoteid * -1;
$val->id = $remoteid;
$courses[$remoteid] = $val;
}
$order = array();
if (!is_null($usersortorder = get_user_preferences('course_overview_course_order'))) {
$order = unserialize($usersortorder);
}
$sortedcourses = array();
$counter = 0;
// Get courses in sort order into list.
foreach ($order as $key => $cid) {
if ($counter >= $limit && $limit != 0) {
break;
}
// Make sure user is still enroled.
if (isset($courses[$cid])) {
$sortedcourses[$cid] = $courses[$cid];
$counter++;
}
}
// Append unsorted courses if limit allows
foreach ($courses as $c) {
if ($limit != 0 && $counter >= $limit) {
break;
}
if (!in_array($c->id, $order)) {
$sortedcourses[$c->id] = $c;
$counter++;
}
}
// From list extract site courses for overview
$sitecourses = array();
foreach ($sortedcourses as $key => $course) {
if ($course->id > 0) {
$sitecourses[$key] = $course;
}
}
return array($sortedcourses, $sitecourses, count($courses));
}
示例7: get_content
/**
* block contents
*
* @return object
*/
public function get_content()
{
global $USER, $CFG;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
$content = array();
// limits the number of courses showing up
$courses_limit = 21;
// FIXME: this should be a block setting, rather than a global setting
if (isset($CFG->mycoursesperpage)) {
$courses_limit = $CFG->mycoursesperpage;
}
$morecourses = false;
if ($courses_limit > 0) {
$courses_limit = $courses_limit + 1;
}
$courses = enrol_get_my_courses('id, shortname', 'visible DESC,sortorder ASC', $courses_limit);
$site = get_site();
$course = $site;
//just in case we need the old global $course hack
if (is_enabled_auth('mnet')) {
$remote_courses = get_my_remotecourses();
}
if (empty($remote_courses)) {
$remote_courses = array();
}
if ($courses_limit > 0 && count($courses) + count($remote_courses) >= $courses_limit) {
// get rid of any remote courses that are above the limit
$remote_courses = array_slice($remote_courses, 0, $courses_limit - count($courses), true);
if (count($courses) >= $courses_limit) {
//remove the 'marker' course that we retrieve just to see if we have more than $courses_limit
array_pop($courses);
}
$morecourses = true;
}
if (array_key_exists($site->id, $courses)) {
unset($courses[$site->id]);
}
foreach ($courses as $c) {
if (isset($USER->lastcourseaccess[$c->id])) {
$courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
} else {
$courses[$c->id]->lastaccess = 0;
}
}
if (empty($courses) && empty($remote_courses)) {
$content[] = get_string('nocourses', 'my');
} else {
ob_start();
require_once $CFG->dirroot . "/course/lib.php";
print_overview($courses, $remote_courses);
$content[] = ob_get_contents();
ob_end_clean();
}
// if more than 20 courses
if ($morecourses) {
$content[] = '<br />...';
}
$this->content->text = implode($content);
return $this->content;
}
示例8: inspector_ajax
/**
* Serves requests to /theme/essential/inspector.ajax.php
*
* @param string $term search term.
* @return array of results.
* @throws coding_exception
*/
public function inspector_ajax($term)
{
global $USER;
$data = array();
$courses = enrol_get_my_courses();
$site = get_site();
if (array_key_exists($site->id, $courses)) {
unset($courses[$site->id]);
}
foreach ($courses as $c) {
if (isset($USER->lastcourseaccess[$c->id])) {
$courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
} else {
$courses[$c->id]->lastaccess = 0;
}
}
// Get remote courses.
$remotecourses = array();
if (is_enabled_auth('mnet')) {
$remotecourses = get_my_remotecourses();
}
// Remote courses will have -ve remoteid as key, so it can be differentiated from normal courses.
foreach ($remotecourses as $id => $val) {
$remoteid = $val->remoteid * -1;
$val->id = $remoteid;
$courses[$remoteid] = $val;
}
foreach ($courses as $course) {
$modinfo = get_fast_modinfo($course);
$courseformat = course_get_format($course->id);
$course = $courseformat->get_course();
$courseformatsettings = $courseformat->get_format_options();
$sesskey = sesskey();
foreach ($modinfo->get_section_info_all() as $section => $thissection) {
if (!$thissection->uservisible) {
continue;
}
if (is_object($thissection)) {
$thissection = $modinfo->get_section_info($thissection->section);
} else {
$thissection = $modinfo->get_section_info($thissection);
}
if ((string) $thissection->name !== '') {
$sectionname = format_string($thissection->name, true, array('context' => context_course::instance($course->id)));
} else {
$sectionname = $courseformat->get_section_name($thissection->section);
}
if ($thissection->section <= $course->numsections) {
// Do not link 'orphaned' sections.
$courseurl = new moodle_url('/course/view.php');
$courseurl->param('id', $course->id);
$courseurl->param('sesskey', $sesskey);
if (!empty($courseformatsettings['coursedisplay']) && $courseformatsettings['coursedisplay'] == COURSE_DISPLAY_MULTIPAGE) {
$courseurl->param('section', $thissection->section);
$coursehref = $courseurl->out(false);
} else {
$coursehref = $courseurl->out(false) . '#section-' . $thissection->section;
}
$label = $course->fullname . ' - ' . $sectionname;
if (stristr($label, $term)) {
$data[] = array('id' => $coursehref, 'label' => $label, 'value' => $label);
}
}
if (!empty($modinfo->sections[$thissection->section])) {
foreach ($modinfo->sections[$thissection->section] as $modnumber) {
$mod = $modinfo->cms[$modnumber];
if (!empty($mod->url)) {
$instancename = $mod->get_formatted_name();
$label = $course->fullname . ' - ' . $sectionname . ' - ' . $instancename;
if (stristr($label, $term)) {
$data[] = array('id' => $mod->url->out(false), 'label' => $label, 'value' => $label);
}
}
}
}
}
}
return $data;
}