function html_footer() { global $course, $choose, $adminroot; echo '</td></tr></table>'; if ($course->id == SITEID) { admin_externalpage_print_footer($adminroot); } else { print_footer($course); } }
$CFG->htmleditor = ''; } $msgform = new user_message_form('user_bulk_message.php'); if ($msgform->is_cancelled()) { redirect($return); } else { if ($formdata = $msgform->get_data()) { $options = new object(); $options->para = false; $options->newlines = true; $options->smiley = false; $msg = format_text($formdata->messagebody, $formdata->format, $options); $in = implode(',', $SESSION->bulk_users); $userlist = $DB->get_records_select_menu('user', "id IN ({$in})", null, 'fullname', 'id,' . $DB->sql_fullname() . ' AS fullname'); $usernames = implode(', ', $userlist); $optionsyes = array(); $optionsyes['confirm'] = 1; $optionsyes['sesskey'] = sesskey(); $optionsyes['msg'] = $msg; admin_externalpage_print_header(); print_heading(get_string('confirmation', 'admin')); print_box($msg, 'boxwidthnarrow boxaligncenter generalbox', 'preview'); notice_yesno(get_string('confirmmessage', 'bulkusers', $usernames), 'user_bulk_message.php', 'user_bulk.php', $optionsyes, NULL, 'post', 'get'); admin_externalpage_print_footer(); die; } } admin_externalpage_print_header(); $msgform->display(); admin_externalpage_print_footer();
} exit; case 'downloadasexcel': if (!print_log_xls($course, $user, $date, 'l.time DESC', $modname, $modid, $modaction, $group)) { notify("No logs found!"); print_footer($course); } exit; } } else { if ($hostid != $CFG->mnet_localhost_id || $hostid == $CFG->mnet_localhost_id && $course->id == SITEID) { $adminroot = admin_get_root(); admin_externalpage_setup('reportlog', $adminroot); admin_externalpage_print_header($adminroot); } else { print_header($course->shortname . ': ' . $strlogs, $course->fullname, "<a href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}\">{$course->shortname}</a> -> \n <a href=\"{$CFG->wwwroot}/course/report.php?id={$course->id}\">{$strreports}</a> ->\n {$strlogs}", ''); } print_heading(get_string('chooselogs') . ':'); print_log_selector_form($course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat); echo '<br />'; print_heading(get_string('chooselivelogs') . ':'); echo '<center><h3>'; link_to_popup_window('/course/report/log/live.php?id=' . $course->id, 'livelog', get_string('livelogs'), 500, 800); echo '</h3></center>'; } if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) { admin_externalpage_print_footer($adminroot); } else { print_footer($course); } exit;
/** * Can provide a course object to make the footer contain a link to * to the course home page, otherwise the link will go to the site home * @uses $USER * @param mixed $course course object, used for course link button or * 'none' means no user link, only docs link * 'empty' means nothing printed in footer * 'home' special frontpage footer * @param object $usercourse course used in user link * @param boolean $return output as string * @return mixed string or void */ function print_footer($course = NULL, $usercourse = NULL, $return = false) { global $USER, $CFG, $THEME, $COURSE, $SITE, $PAGE; if (defined('ADMIN_EXT_HEADER_PRINTED') and !defined('ADMIN_EXT_FOOTER_PRINTED')) { admin_externalpage_print_footer(); return; } $PAGE->set_state(moodle_page::STATE_PRINTING_FOOTER); /// Course links or special footer if ($course) { if ($course === 'empty') { // special hack - sometimes we do not want even the docs link in footer $output = ''; if (!empty($THEME->open_header_containers)) { for ($i = 0; $i < $THEME->open_header_containers; $i++) { $output .= print_container_end_all(); // containers opened from header } } else { //1.8 theme compatibility $output .= "\n</div>"; // content div } $output .= "\n</div>\n</body>\n</html>"; // close page div started in header if ($return) { return $output; } else { echo $output; return; } } else { if ($course === 'none') { // Don't print any links etc $homelink = ''; $loggedinas = ''; $home = false; } else { if ($course === 'home') { // special case for site home page - please do not remove $course = $SITE; $homelink = '<div class="sitelink">' . '<a title="Moodle ' . $CFG->release . '" href="http://moodle.org/">' . '<img style="width:100px;height:30px" src="' . $CFG->wwwroot . '/pix/moodlelogo.gif" alt="moodlelogo" /></a></div>'; $home = true; } else { if ($course === 'upgrade') { $home = false; $loggedinas = ''; $homelink = '<div class="sitelink">' . '<a title="Moodle ' . $CFG->target_release . '" href="http://docs.moodle.org/en/Administrator_documentation" onclick="this.target=\'_blank\'">' . '<img style="width:100px;height:30px" src="' . $CFG->wwwroot . '/pix/moodlelogo.gif" alt="moodlelogo" /></a></div>'; } else { $homelink = '<div class="homelink"><a ' . $CFG->frametarget . ' href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' . format_string($course->shortname) . '</a></div>'; $home = false; } } } } } else { $course = $SITE; // Set course as site course by default $homelink = '<div class="homelink"><a ' . $CFG->frametarget . ' href="' . $CFG->wwwroot . '/">' . get_string('home') . '</a></div>'; $home = false; } /// Set up some other navigation links (passed from print_header by ugly hack) $menu = isset($THEME->menu) ? str_replace('navmenu', 'navmenufooter', $THEME->menu) : ''; $title = isset($THEME->title) ? $THEME->title : ''; $button = isset($THEME->button) ? $THEME->button : ''; $heading = isset($THEME->heading) ? $THEME->heading : ''; $navigation = isset($THEME->navigation) ? $THEME->navigation : ''; $navmenulist = isset($THEME->navmenulist) ? $THEME->navmenulist : ''; /// Set the user link if necessary if (!$usercourse and is_object($course)) { $usercourse = $course; } if (!isset($loggedinas)) { $loggedinas = user_login_string($usercourse, $USER); } if ($loggedinas == $menu) { $menu = ''; } /// there should be exactly the same number of open containers as after the header if ($THEME->open_header_containers != open_containers()) { debugging('Unexpected number of open containers: ' . open_containers() . ', expecting ' . $THEME->open_header_containers, DEBUG_DEVELOPER); } /// Provide some performance info if required $performanceinfo = ''; if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) { $perf = get_performance_info(); if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) { error_log("PERF: " . $perf['txt']); } if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) { $performanceinfo = $perf['html']; } } /// Include the actual footer file ob_start(); include $CFG->footer; $output = ob_get_contents(); ob_end_clean(); $PAGE->set_state(moodle_page::STATE_DONE); if ($return) { return $output; } else { echo $output; } }
function profile_edit_field($id, $datatype, $redirect) { global $CFG; if (!($field = get_record('user_info_field', 'id', $id))) { $field = new object(); $field->datatype = $datatype; } require_once 'index_field_form.php'; $fieldform = new field_form(null, $field->datatype); $fieldform->set_data($field); if ($fieldform->is_cancelled()) { redirect($redirect); } else { if ($data = $fieldform->get_data()) { require_once $CFG->dirroot . '/user/profile/field/' . $datatype . '/define.class.php'; $newfield = 'profile_define_' . $datatype; $formfield = new $newfield(); $formfield->define_save($data); profile_reorder_fields(); profile_reorder_categories(); redirect($redirect); } $datatypes = profile_list_datatypes(); if (empty($id)) { $strheading = get_string('profilecreatenewfield', 'admin', $datatypes[$datatype]); } else { $strheading = get_string('profileeditfield', 'admin', $field->name); } /// Print the page admin_externalpage_print_header(); print_heading($strheading); $fieldform->display(); admin_externalpage_print_footer(); die; } }
/** * Can provide a course object to make the footer contain a link to * to the course home page, otherwise the link will go to the site home * @uses $USER * @param mixed $course course object, used for course link button or * 'none' means no user link, only docs link * 'empty' means nothing printed in footer * 'home' special frontpage footer * @param object $usercourse course used in user link * @param boolean $return output as string * @return mixed string or void */ function print_footer($course = NULL, $usercourse = NULL, $return = false) { global $USER, $CFG, $THEME, $COURSE; if (defined('ADMIN_EXT_HEADER_PRINTED') and !defined('ADMIN_EXT_FOOTER_PRINTED')) { admin_externalpage_print_footer(); return; } /// Course links or special footer if ($course) { if ($course === 'empty') { // special hack - sometimes we do not want even the docs link in footer $output = ''; if (!empty($THEME->open_header_containers)) { for ($i = 0; $i < $THEME->open_header_containers; $i++) { $output .= print_container_end_all(); // containers opened from header } } else { //1.8 theme compatibility $output .= "\n</div>"; // content div } $output .= "\n</div>\n</body>\n</html>"; // close page div started in header if ($return) { return $output; } else { echo $output; return; } } else { if ($course === 'none') { // Don't print any links etc $homelink = ''; $loggedinas = ''; $home = false; } else { if ($course === 'home') { // special case for site home page - please do not remove $course = get_site(); $homelink = '<div class="sitelink">' . '<a title="Moodle ' . $CFG->release . '" href="http://moodle.org/">' . '<img style="width:100px;height:30px" src="pix/moodlelogo.gif" alt="moodlelogo" /></a></div>'; $home = true; } else { $homelink = '<div class="homelink"><a ' . $CFG->frametarget . ' href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' . format_string($course->shortname) . '</a></div>'; $home = false; } } } } else { $course = get_site(); // Set course as site course by default $homelink = '<div class="homelink"><a ' . $CFG->frametarget . ' href="' . $CFG->wwwroot . '/">' . get_string('home') . '</a></div>'; $home = false; } /// Set up some other navigation links (passed from print_header by ugly hack) $menu = isset($THEME->menu) ? str_replace('navmenu', 'navmenufooter', $THEME->menu) : ''; $title = isset($THEME->title) ? $THEME->title : ''; $button = isset($THEME->button) ? $THEME->button : ''; $heading = isset($THEME->heading) ? $THEME->heading : ''; $navigation = isset($THEME->navigation) ? $THEME->navigation : ''; $navmenulist = isset($THEME->navmenulist) ? $THEME->navmenulist : ''; /// Set the user link if necessary if (!$usercourse and is_object($course)) { $usercourse = $course; } if (!isset($loggedinas)) { $loggedinas = user_login_string($usercourse, $USER); } if ($loggedinas == $menu) { $menu = ''; } /// there should be exactly the same number of open containers as after the header if ($THEME->open_header_containers != open_containers()) { debugging('Unexpected number of open containers: ' . open_containers() . ', expecting ' . $THEME->open_header_containers, DEBUG_DEVELOPER); } /// Provide some performance info if required $performanceinfo = ''; if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) { $perf = get_performance_info(); if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) { error_log("PERF: " . $perf['txt']); } if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) { $performanceinfo = $perf['html']; } } /// Include the actual footer file ob_start(); include $CFG->footer; $output = ob_get_contents(); ob_end_clean(); /* $analytics = "<script type='text/javascript'> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-21025813-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>"; */ if ($return) { return $analytics . $output; } else { echo $analytics . $output; } }
/** * Redirects the user to another page, after printing a notice * * @param string $url The url to take the user to * @param string $message The text message to display to the user about the redirect, if any * @param string $delay How long before refreshing to the new page at $url? * @todo '&' needs to be encoded into '&' for XHTML compliance, * however, this is not true for javascript. Therefore we * first decode all entities in $url (since we cannot rely on) * the correct input) and then encode for where it's needed * echo "<script type='text/javascript'>alert('Redirect $url');</script>"; */ function redirect($url, $message = '', $delay = -1, $adminroot = '') { global $CFG; if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) { $url = sid_process_url($url); } $message = clean_text($message); $url = html_entity_decode($url); $url = str_replace(array("\n", "\r"), '', $url); // some more cleaning $encodedurl = htmlentities($url); $tmpstr = clean_text('<a href="' . $encodedurl . '" />'); //clean encoded URL $encodedurl = substr($tmpstr, 9, strlen($tmpstr) - 13); $url = html_entity_decode($encodedurl); $surl = addslashes($url); $performanceinfo = ''; if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) { if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) { $perf = get_performance_info(); error_log("PERF: " . $perf['txt']); } } /// when no message and header printed yet, try to redirect if (empty($message) and !defined('HEADER_PRINTED')) { // Technically, HTTP/1.1 requires Location: header to contain // the absolute path. (In practice browsers accept relative // paths - but still, might as well do it properly.) // This code turns relative into absolute. if (!preg_match('|^[a-z]+:|', $url)) { // Get host name http://www.wherever.com $hostpart = preg_replace('|^(.*?[^:/])/.*$|', '$1', $CFG->wwwroot); if (preg_match('|^/|', $url)) { // URLs beginning with / are relative to web server root so we just add them in $url = $hostpart . $url; } else { // URLs not beginning with / are relative to path of current script, so add that on. $url = $hostpart . preg_replace('|\\?.*$|', '', me()) . '/../' . $url; } // Replace all ..s while (true) { $newurl = preg_replace('|/(?!\\.\\.)[^/]*/\\.\\./|', '/', $url); if ($newurl == $url) { break; } $url = $newurl; } } $delay = 0; //try header redirection first @header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other'); //302 might not work for POST requests, 303 is ignored by obsolete clients @header('Location: ' . $url); //another way for older browsers and already sent headers (eg trailing whitespace in config.php) echo '<meta http-equiv="refresh" content="' . $delay . '; url=' . $encodedurl . '" />'; echo '<script type="text/javascript">' . "\n" . '//<![CDATA[' . "\n" . "location.replace('{$surl}');" . "\n" . '//]]>' . "\n" . '</script>'; // To cope with Mozilla bug die; } if ($delay == -1) { $delay = 3; // if no delay specified wait 3 seconds } if (!defined('HEADER_PRINTED')) { // this type of redirect might not be working in some browsers - such as lynx :-( print_header('', '', '', '', '<meta http-equiv="refresh" content="' . $delay . '; url=' . $encodedurl . '" />'); $delay += 3; // double redirect prevention, it was sometimes breaking upgrades before 1.7 } echo '<div style="text-align:center">'; echo '<div>' . $message . '</div>'; echo '<div>( <a href="' . $encodedurl . '">' . get_string('continue') . '</a> )</div>'; echo '</div>'; // it might be better not to set timeout the same for both types of redirect, so that we can be sure which one wins ?> <script type="text/javascript"> //<![CDATA[ function redirect() { document.location.replace('<?php echo $surl; ?> '); } setTimeout("redirect()", <?php echo $delay * 1000; ?> ); //]]> </script> <?php $CFG->docroot = false; // to prevent the link to moodle docs from being displayed on redirect page. // fix for MDL-8517, admin pages redirections causes bad xhtml if ($adminroot) { admin_externalpage_print_footer($adminroot); } else { print_footer('none'); } die; }
/** * Can provide a course object to make the footer contain a link to * to the course home page, otherwise the link will go to the site home * * @uses $CFG * @uses $USER * @param course $course {@link $COURSE} object containing course information * @param ? $usercourse ? * @todo Finish documenting this function */ function print_footer($course = NULL, $usercourse = NULL, $return = false) { global $USER, $CFG, $THEME, $COURSE; if (defined('ADMIN_EXT_HEADER_PRINTED') and !defined('ADMIN_EXT_FOOTER_PRINTED')) { admin_externalpage_print_footer(); return; } /// Course links if ($course) { if (is_string($course) && $course == 'none') { // Don't print any links etc $homelink = ''; $loggedinas = ''; $home = false; } else { if (is_string($course) && $course == 'home') { // special case for site home page - please do not remove $course = get_site(); $homelink = '<div class="sitelink">' . '<a title="moodle ' . $CFG->release . ' (' . $CFG->version . ')" href="http://moodle.org/">' . '<img style="width:100px;height:30px" src="pix/moodlelogo.gif" alt="moodlelogo" /></a></div>'; $home = true; } else { $homelink = '<div class="homelink"><a ' . $CFG->frametarget . ' href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' . format_string($course->shortname) . '</a></div>'; $home = false; } } } else { $course = get_site(); // Set course as site course by default $homelink = '<div class="homelink"><a ' . $CFG->frametarget . ' href="' . $CFG->wwwroot . '/">' . get_string('home') . '</a></div>'; $home = false; } /// Set up some other navigation links (passed from print_header by ugly hack) $menu = isset($THEME->menu) ? str_replace('navmenu', 'navmenufooter', $THEME->menu) : ''; $title = isset($THEME->title) ? $THEME->title : ''; $button = isset($THEME->button) ? $THEME->button : ''; $heading = isset($THEME->heading) ? $THEME->heading : ''; $navigation = isset($THEME->navigation) ? $THEME->navigation : ''; $navmenulist = isset($THEME->navmenulist) ? $THEME->navmenulist : ''; /// Set the user link if necessary if (!$usercourse and is_object($course)) { $usercourse = $course; } if (!isset($loggedinas)) { $loggedinas = user_login_string($usercourse, $USER); } if ($loggedinas == $menu) { $menu = ''; } /// Provide some performance info if required $performanceinfo = ''; if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) { $perf = get_performance_info(); if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) { error_log("PERF: " . $perf['txt']); } if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) { $performanceinfo = $perf['html']; } } /// Close eventually open custom_corner divs if (!empty($THEME->customcorners) && $THEME->customcornersopen > 1) { require_once $CFG->dirroot . '/lib/custom_corners_lib.php'; while ($THEME->customcornersopen > 1) { print_custom_corners_end(); } } /// Include the actual footer file ob_start(); include $CFG->footer; $output = ob_get_contents(); ob_end_clean(); if ($return) { return $output; } else { echo $output; } }
/** * Given an object containing all the necessary data, * (defined by the form in mod_form.php) this function * will create a new instance and return the id number * of the new instance. * * @param object $mumiemodule - An object from the form in mod.html * @return int - The id of the newly inserted newmodule record **/ function mumiemodule_add_instance($mumiemodule, $checkfirst = true, $perhand = false) { global $CFG; global $COURSE; global $USER; //check if this is not the firs mumiemodule within this course: $morethanone = record_exists('mumiemodule', 'course', $mumiemodule->course); $mumiemodule->timemodified = time(); //this is just for later-versions: if (!$morethanone) { $thebigone = create_the_big_one($mumiemodule); //to create the big object containing all data insert_all_for_mumie($thebigone); } else { //so there are more than one MUMIE-courses related to that class //we dont want to have more than one mumiemodule - perhaps later //TODO: //del errormessage when adding another mumiemodule-instance //rebuild sending of mumie-courses } //insert the new activity into Moodle-DB: $insertedid = insert_record("mumiemodule", $mumiemodule); //and the students $context = get_context_instance(CONTEXT_COURSE, $COURSE->id); $users = get_users_by_capability($context, 'mod/mumiemodule:participate'); if ($mumie_groups = groups_get_all_groups($COURSE->id)) { foreach ($mumie_groups as $mumie_group) { foreach ($users as $user) { if (groups_is_member($mumie_group->id, $user->id)) { $ins = new object(); $ins->mumiemodule = $insertedid; $ins->userid = $user->id; $ins->groupid = (int) $mumie_group->id; $ins->timemodified = $mumiemodule->timemodified; $newid = insert_record("mumiemodule_students", $ins); } } } } if (!$perhand) { return $insertedid; } else { echo '<h1 align="center">Done!</h1>'; print_continue($CFG->wwwroot); admin_externalpage_print_footer(); exit; } }