function print_entry($course) { global $CFG, $USER; $strloginto = get_string("loginto", "", $course->shortname); $strcourses = get_string("courses"); $teacher = get_teacher($course->id); if ((double) $course->cost < 0) { $cost = (double) $CFG->enrol_cost; } else { $cost = (double) $course->cost; } if (abs($cost) < 0.01) { // no cost, default to base class entry to course $manual = enrolment_factory::factory('manual'); $manual->print_entry($course); } else { $navlinks = array(); $navlinks[] = array('name' => $strcourses, 'link' => "{$CFG->wwwroot}/course", 'type' => 'misc'); $navlinks[] = array('name' => $strloginto, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header($strloginto, $course->fullname, $navigation); print_course($course, "80%"); if ($course->password) { // Presenting two options print_heading(get_string('costorkey', 'enrol_paypal'), 'center'); } print_simple_box_start("center"); if ($USER->username == 'guest') { // force login only for guest user, not real users with guest role if (empty($CFG->loginhttps)) { $wwwroot = $CFG->wwwroot; } else { // This actually is not so secure ;-), 'cause we're // in unencrypted connection... $wwwroot = str_replace("http://", "https://", $CFG->wwwroot); } echo '<div align="center"><p>' . get_string('paymentrequired') . '</p>'; echo '<p><b>' . get_string('cost') . ": {$CFG->enrol_currency} {$cost}" . '</b></p>'; echo '<p><a href="' . $wwwroot . '/login/">' . get_string('loginsite') . '</a></p>'; echo '</div>'; } else { //Sanitise some fields before building the PayPal form $coursefullname = $course->fullname; $courseshortname = $course->shortname; $userfullname = fullname($USER); $userfirstname = $USER->firstname; $userlastname = $USER->lastname; $useraddress = $USER->address; $usercity = $USER->city; include $CFG->dirroot . '/enrol/paypal/enrol.html'; } print_simple_box_end(); if ($course->password) { // Second option $password = ''; include $CFG->dirroot . '/enrol/manual/enrol.html'; } print_footer(); } }
/** * Prints the entry form/page for this enrolment * * This is only called from course/enrol.php * Most plugins will probably override this to print payment * forms etc, or even just a notice to say that manual enrolment * is disabled * * @param course current course object */ function print_entry($course) { global $CFG, $USER, $SESSION, $THEME; $strloginto = get_string('loginto', '', $course->shortname); $strcourses = get_string('courses'); /// Automatically enrol into courses without password $context = get_context_instance(CONTEXT_SYSTEM); $navlinks = array(); $navlinks[] = array('name' => $strcourses, 'link' => ".", 'type' => 'misc'); $navlinks[] = array('name' => $strloginto, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); if ($course->password == '') { // no password, so enrol if (has_capability('moodle/legacy:guest', $context, $USER->id, false)) { add_to_log($course->id, 'course', 'guest', 'view.php?id=' . $course->id, getremoteaddr()); } else { if (empty($_GET['confirm']) && empty($_GET['cancel'])) { print_header($strloginto, $course->fullname, $navigation); echo '<br />'; notice_yesno(get_string('enrolmentconfirmation'), "enrol.php?id={$course->id}&confirm=1", "enrol.php?id={$course->id}&cancel=1"); print_footer(); exit; } else { if (!empty($_GET['confirm'])) { if (!enrol_into_course($course, $USER, 'manual')) { print_error('couldnotassignrole'); } // force a refresh of mycourses unset($USER->mycourses); if (!empty($SESSION->wantsurl)) { $destination = $SESSION->wantsurl; unset($SESSION->wantsurl); } else { $destination = "{$CFG->wwwroot}/course/view.php?id={$course->id}"; } redirect($destination); } else { if (!empty($_GET['cancel'])) { unset($SESSION->wantsurl); if (!empty($SESSION->enrolcancel)) { $destination = $SESSION->enrolcancel; unset($SESSION->enrolcancel); } else { $destination = $CFG->wwwroot; } redirect($destination); } } } } } // if we get here we are going to display the form asking for the enrolment key // and (hopefully) provide information about who to ask for it. if (!isset($password)) { $password = ''; } print_header($strloginto, $course->fullname, $navigation, "form.password"); print_course($course, "80%"); include "{$CFG->dirroot}/enrol/manual/enrol.html"; print_footer(); }
/** * Presents registration forms. * * @param object $course Course info * @access public */ function print_entry($course) { global $CFG, $USER, $form; $zerocost = zero_cost($course); if ($zerocost) { $manual = enrolment_factory::factory('manual'); if (!empty($this->errormsg)) { $manual->errormsg = $this->errormsg; } $manual->print_entry($course); return; } prevent_double_paid($course); httpsrequired(); if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 443) { // MDL-9836 if (empty($CFG->loginhttps)) { print_error('httpsrequired', 'enrol_authorize'); } else { $wwwsroot = str_replace('http:', 'https:', $CFG->wwwroot); redirect("{$wwwsroot}/course/enrol.php?id={$course->id}"); exit; } } $strcourses = get_string('courses'); $strloginto = get_string('loginto', '', $course->shortname); $navlinks = array(); $navlinks[] = array('name' => $strcourses, 'link' => "{$CFG->wwwroot}/course/", 'type' => 'misc'); $navlinks[] = array('name' => $strloginto, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header($strloginto, $course->fullname, $navigation); print_course($course, '80%'); if ($course->password) { print_heading(get_string('choosemethod', 'enrol_authorize'), 'center'); } print_simple_box_start('center', '80%'); if ($USER->username == 'guest') { // only real guest user, not for users with guest role $curcost = get_course_cost($course); echo '<div class="mdl-align">'; echo '<p>' . get_string('paymentrequired') . '</p>'; echo '<p><b>' . get_string('cost') . ": {$curcost['currency']} {$curcost['cost']}" . '</b></p>'; echo '<p><a href="' . $CFG->httpswwwroot . '/login/">' . get_string('loginsite') . '</a></p>'; echo '</div>'; } else { require_once $CFG->dirroot . '/enrol/authorize/enrol_form.php'; $frmenrol = new enrol_authorize_form('enrol.php', compact('course')); if ($frmenrol->get_data()) { $authorizeerror = ''; switch ($form->paymentmethod) { case AN_METHOD_CC: $authorizeerror = $this->cc_submit($form, $course); break; case AN_METHOD_ECHECK: $authorizeerror = $this->echeck_submit($form, $course); break; } if (!empty($authorizeerror)) { error($authorizeerror); } } $frmenrol->display(); } print_simple_box_end(); if ($course->password) { $password = ''; include $CFG->dirroot . '/enrol/manual/enrol.html'; } print_footer(); }
/** * 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); } } }
$modulelink = "&blocklist=" . $blocklist . "&sesskey=" . sesskey(); } } print_navigation_bar($totalcount, $page, $perpage, $encodedsearch, $modulelink); // Show list of courses if (!$adminediting) { //Not editing mode foreach ($courses as $course) { // front page don't belong to any category and block can exist. if ($course->category > 0) { $course->summary .= "<br /><p class=\"category\">"; $course->summary .= "{$strcategory}: <a href=\"category.php?id={$course->category}\">"; $course->summary .= $displaylist[$course->category]; $course->summary .= "</a></p>"; } print_course($course, $search); echo $OUTPUT->spacer(array('height' => 5, 'width' => 5, 'br' => true)); // should be done with CSS instead } } else { // Editing mode echo "<form id=\"movecourses\" action=\"search.php\" method=\"post\">\n"; echo "<div><input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . "\" />\n"; echo "<input type=\"hidden\" name=\"search\" value=\"" . s($search) . "\" />\n"; echo "<input type=\"hidden\" name=\"page\" value=\"{$page}\" />\n"; echo "<input type=\"hidden\" name=\"perpage\" value=\"{$perpage}\" /></div>\n"; if (!empty($modulelist) and confirm_sesskey()) { echo "<input type=\"hidden\" name=\"modulelist\" value=\"{$modulelist}\" /></div>\n"; } else { if (!empty($blocklist) and confirm_sesskey()) { echo "<input type=\"hidden\" name=\"blocklist\" value=\"{$blocklist}\" /></div>\n";
// If only one anchor is present, no <a href /> is needed if ($countanchors == 0) { echo '<div class="relatedpages"><p>' . get_string('noresultsfor', 'tag', $tagname) . '</p></div>'; } elseif ($countanchors > 1) { echo '<div class="relatedpages"><p>' . $relatedpageslink . '</p></div>'; } // Display courses tagged with the tag if (!empty($courses)) { $totalcount = count($courses); echo $OUTPUT->box_start('generalbox', 'tag-blogs'); //could use an id separate from tag-blogs, but would have to copy the css style to make it look the same $heading = get_string('courses') . ' ' . get_string('taggedwith', 'tag', $tagname) . ': ' . $totalcount; echo "<a name='course'></a>"; echo $OUTPUT->heading($heading, 3); foreach ($courses as $course) { print_course($course); } echo $OUTPUT->box_end(); } // Print up to 10 previous blogs entries if (!empty($blogs)) { echo $OUTPUT->box_start('generalbox', 'tag-blogs'); $heading = get_string('relatedblogs', 'tag', $tagname) . ' ' . get_string('taggedwith', 'tag', $tagname); echo "<a name='blog'></a>"; echo $OUTPUT->heading($heading, 3); echo '<ul id="tagblogentries">'; foreach ($blogs as $blog) { if ($blog->publishstate == 'draft') { $class = 'class="dimmed"'; } else { $class = '';
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); } } }
/** * Function used by the site index page to display category specific information. */ function fn_display_category_content($course, $catid) { global $USER, $CFG; $totcount = 99; $isteacher = isteacher($course->id); $isediting = isediting($course->id); $ismoving = ismoving($course->id); if (!($category = get_record('course_categories', 'id', $catid))) { error('Invalid category requested.'); } $courses = get_courses_page($catid, 'c.sortorder ASC', 'c.id,c.sortorder,c.shortname,c.fullname,c.summary,c.visible,c.teacher,c.guest,c.password', $totcount); /// Store a course section per category id. Code it by using the 'catid' plus 10 as the section number. $sectnum = $catid + 10; if (!($section = get_record('course_sections', 'course', $course->id, 'section', $sectnum))) { $section = new stdClass(); $section->course = $course->id; $section->section = $sectnum; $section->summary = $category->name; $section->sequence = ''; $section->visible = 1; if (!($section->id = insert_record('course_sections', $section))) { error('Could not create section for category ' . $category->name); } } if (!empty($section) || $isediting) { get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); } $groupbuttons = $course->groupmode; $groupbuttonslink = !$course->groupmodeforce; if ($ismoving) { $strmovehere = get_string('movehere'); $strmovefull = strip_tags(get_string('movefull', '', "'{$USER->activitycopyname}'")); $strcancel = get_string('cancel'); $stractivityclipboard = $USER->activitycopyname; } $modinfo = unserialize($course->modinfo); $editbuttons = ''; print_simple_box_start("center", "100%", '', 5, "coursebox"); echo '<table class="topics" width="100%">'; echo '<tr id="section-' . $section . '" class="section main">'; echo '<td class="content">'; print_heading_block('<div align="center">' . $category->name . '</div>'); echo '<table class="section" width="100%">'; if (!empty($section) && !empty($section->sequence)) { $sectionmods = explode(',', $section->sequence); foreach ($sectionmods as $modnumber) { if (empty($mods[$modnumber])) { continue; } $mod = $mods[$modnumber]; if ($isediting && !$ismoving) { if ($groupbuttons) { if (!($mod->groupmodelink = $groupbuttonslink)) { $mod->groupmode = $course->groupmode; } } else { $mod->groupmode = false; } $editbuttons = '<br />' . make_editing_buttons($mod, true, true); } else { $editbuttons = ''; } if ($mod->visible || $isteacher) { echo '<tr><td class="activity ' . $mod->modname . '">'; if ($ismoving) { if ($mod->id == $USER->activitycopy) { continue; } echo '<a title="' . $strmovefull . '" href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&sesskey=' . $USER->sesskey . '">' . '<img height="16" width="80" src="' . $CFG->pixpath . '/movehere.gif" alt="' . $strmovehere . '" border="0" /></a>'; } $instancename = urldecode($modinfo[$modnumber]->name); $instancename = format_string($instancename, true, $course->id); $linkcss = $mod->visible ? '' : ' class="dimmed" '; if (!empty($modinfo[$modnumber]->extra)) { $extra = urldecode($modinfo[$modnumber]->extra); } else { $extra = ''; } if (!empty($modinfo[$modnumber]->icon)) { $icon = $CFG->pixpath . '/' . urldecode($modinfo[$modnumber]->icon); } else { $icon = $CFG->modpixpath . '/' . $mod->modname . '/icon.gif'; } if ($mod->modname == 'label') { echo format_text($extra, FORMAT_HTML) . $editbuttons; } else { echo '<img src="' . $icon . '" height="16" width="16" alt="' . $mod->modfullname . '" /> ' . '<a title="' . $mod->modfullname . '" ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . $instancename . '</a>' . $editbuttons; } echo "</td>"; echo "</tr>"; } } } else { echo "<tr><td></td></tr>"; // needed for XHTML compatibility } if ($ismoving) { echo '<tr><td><a title="' . $strmovefull . '" href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&sesskey=' . $USER->sesskey . '">' . '<img height="16" width="80" src="' . $CFG->pixpath . '/movehere.gif" alt="' . $strmovehere . '" border="0" /></a></td></tr>'; } if ($isediting && $modnames) { echo '<tr><td>'; print_section_add_menus($course, $section->section, $modnames, true); echo '</td></tr>'; } echo "</table>\n\n"; echo '</td></tr></table>'; print_simple_box_end(); if (empty($courses)) { print_heading(FN_translate_course_string(get_string("nocoursesyet"))); } else { foreach ($courses as $course) { print_course($course); } } }
function confirmed_request($course, $message) { global $CFG, $USER, $SESSION, $THEME; $strloginto = get_string('loginto', '', $course->shortname); $strcourses = get_string('courses'); $navlinks = array(); $navlinks[] = array('name' => $strcourses, 'link' => ".", 'type' => 'misc'); $navlinks[] = array('name' => $strloginto, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header($strloginto, $course->fullname, $navigation, "form.password"); print_course($course, "80%"); //include("$CFG->dirroot/enrol/manual/enrol.html"); echo $message; print_footer(); }
} } if (!$course->enrollable || $course->enrollable == 2 && $course->enrolstartdate > 0 && $course->enrolstartdate > time() || $course->enrollable == 2 && $course->enrolenddate > 0 && $course->enrolenddate <= time()) { print_header($course->shortname, $course->fullname, build_navigation(array(array('name' => $course->shortname, 'link' => '', 'type' => 'misc')))); notice(get_string('notenrollable'), "{$CFG->wwwroot}/index.php"); } /// Check the submitted enrolment information if there is any (eg could be enrolment key) // 2008/01/31 - kowy - in enrol_type property should by a type of enrol method - check entries based on chosen enrol method if ($form = data_submitted()) { if (is_scalar($form['enrol_type']) && method_exists($enrols[$form['enrol_type']], 'check_entry')) { $enrols[$form['enrol_type']]->check_entry($form, $course); // Should terminate/redirect in here if it's all OK } } /// Otherwise, we print the entry form. // 2008/02/04 - kowy - print header of the page $strloginto = get_string('loginto', '', $course->shortname); $strcourses = get_string('courses'); $navlinks = array(); $navlinks[] = array('name' => $strcourses, 'link' => ".", 'type' => 'misc'); $navlinks[] = array('name' => $strloginto, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header($strloginto, $course->fullname, $navigation); print_course($course, "80%"); // 2008/01/31 - kowy - print all enrolment possibilities foreach ($enrols as $enrol) { $enrol->print_entry($course); } // 2008/02/04 - kowy - print footer print_footer(); /// Easy!