break; } echo '<br />'; } print_container_end(); echo '</td>'; break; case 'right': // The right column if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing || $PAGE->user_allowed_editing()) { echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">'; print_container_start(); if ($PAGE->user_allowed_editing()) { echo '<div style="text-align:center">' . update_course_icon($SITE->id) . '</div>'; echo '<br />'; } blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT); print_container_end(); echo '</td>'; } break; } } ?> </tr> </table> <?php print_footer('home'); // Please do not modify this line
/** * Force closing of open containers * @param boolean $return, return as string or just print it * @param int $keep number of containers to be kept open - usually theme or page containers * @return mixed string or void */ function print_container_end_all($return = false, $keep = 0) { $output = ''; while (open_containers() > $keep) { $output .= print_container_end($return); } if ($return) { return $output; } else { echo $output; } }
/** * Prints the comment deletion confirmation form * * @param page $page The page whose version will be restored * @param int $versionid The version to be restored * @param bool $confirm If false, shows a yes/no confirmation page. * If true, restores the old version and redirects the user to the 'view' tab. */ private function printconfirmdelete() { global $OUTPUT; $strdeletecheck = get_string('deletecommentcheck', 'wiki'); $strdeletecheckfull = get_string('deletecommentcheckfull', 'wiki'); //ask confirmation $optionsyes = array('confirm'=>1, 'pageid'=>$this->page->id, 'action'=>'delete', 'commentid'=>$this->commentid, 'sesskey'=>sesskey()); $deleteurl = new moodle_url('/mod/wiki/instancecomments.php', $optionsyes); $return = new moodle_url('/mod/wiki/comments.php', array('pageid'=>$this->page->id)); echo $OUTPUT->heading($strdeletecheckfull); print_container_start(false, 'wiki_deletecommentform'); echo '<form class="wiki_deletecomment_yes" action="' . $deleteurl . '" method="post" id="deletecomment">'; echo '<div><input type="submit" name="confirmdeletecomment" value="' . get_string('yes') . '" /></div>'; echo '</form>'; echo '<form class="wiki_deletecomment_no" action="' . $return . '" method="post">'; echo '<div><input type="submit" name="norestore" value="' . get_string('no') . '" /></div>'; echo '</form>'; print_container_end(); }
/** * Print footer on admin page - please use normal print_footer() instead */ function admin_externalpage_print_footer() { global $CFG, $PAGE, $SITE, $THEME; define('ADMIN_EXT_FOOTER_PRINTED', 'true'); if (!empty($SITE->fullname)) { $pageblocks = blocks_setup($PAGE); $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), BLOCK_L_MAX_WIDTH); $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), BLOCK_R_MAX_WIDTH); $lt = empty($THEME->layouttable) ? array('left', 'middle', 'right') : $THEME->layouttable; foreach ($lt as $column) { if ($column != 'middle') { array_shift($lt); } else { if ($column == 'middle') { break; } } } foreach ($lt as $column) { switch ($column) { case 'left': echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">'; print_container_start(); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); print_container_end(); echo '</td>'; break; case 'middle': print_container_end(); $THEME->open_header_containers--; // this is hacky workaround for the error()/notice() autoclosing problems on admin pages echo '</td>'; break; case 'right': if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) { echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">'; print_container_start(); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT); print_container_end(); echo '</td>'; } break; } } echo '</tr></table>'; } print_footer(); }
/** * Finish displaying the resource with the course blocks */ function display_course_blocks_end() { global $CFG; global $THEME; $PAGE = $this->PAGE; $pageblocks = blocks_setup($PAGE); $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210); $lt = empty($THEME->layouttable) ? array('left', 'middle', 'right') : $THEME->layouttable; foreach ($lt as $column) { if ($column != 'middle') { array_shift($lt); } else { if ($column == 'middle') { break; } } } foreach ($lt as $column) { switch ($column) { case 'left': if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) { echo '<td style="width: ' . $blocks_preferred_width . 'px;" id="left-column">'; print_container_start(); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); print_container_end(); echo '</td>'; } break; case 'middle': echo '</div>'; print_container_end(); echo '</td>'; break; case 'right': if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) { echo '<td style="width: ' . $blocks_preferred_width . 'px;" id="right-column">'; print_container_start(); blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT); print_container_end(); echo '</td>'; } break; } } echo '</tr></table>'; print_footer($this->course); }
function finish_page($course) { global $THEME; print_container_end(); echo '</td></tr></table>'; print_footer($course); exit; }
/** * Prints the restore version content * * @uses $CFG * * @param page $page The page whose version will be restored * @param int $versionid The version to be restored * @param bool $confirm If false, shows a yes/no confirmation page. * If true, restores the old version and redirects the user to the 'view' tab. */ private function print_restoreversion() { global $CFG, $OUTPUT; $version = wiki_get_version($this->version->id); echo $OUTPUT->heading(get_string('restoreconfirm', 'wiki', $version->version), 2); print_container_start(false, 'wiki_restoreform'); echo '<form class="wiki_restore_yes" action="' . $CFG->wwwroot . '/mod/wiki/restoreversion.php?pageid=' . $this->page->id . '&versionid=' . $version->id . '" method="post" id="restoreversion">'; echo '<div><input type="submit" name="confirm" value="' . get_string('yes') . '" /></div>'; echo '</form>'; echo '<form class="wiki_restore_no" action="' . $CFG->wwwroot . '/mod/wiki/viewversion.php?pageid=' . $this->page->id . '&versionid=' . $version->id . '" method="post">'; echo '<div><input type="submit" name="norestore" value="' . get_string('no') . '" /></div>'; echo '</form>'; print_container_end(); }
/** * Called from {@link page_print_position()} and it is * supposed to print the front page settings in the * center column for the site course and only for * the default page (EG: the landing page). * * @return boolean **/ function page_frontpage_settings() { global $CFG, $SESSION, $SITE, $PAGE, $COURSE; // Cheap check first - course ID if ($COURSE->id != SITEID) { return false; } // More expensive check - make sure we are viewing default page $default = page_get_default_page(); $current = $PAGE->get_formatpage(); if (empty($default->id) or empty($current->id) or $default->id != $current->id) { return false; } $editing = $PAGE->user_is_editing(); /// START COPY/PASTE FROM INDEX.PHP print_container_start(); /// Print Section if ($SITE->numsections > 0) { if (!($section = get_record('course_sections', 'course', $SITE->id, 'section', 1))) { delete_records('course_sections', 'course', $SITE->id, 'section', 1); // Just in case $section->course = $SITE->id; $section->section = 1; $section->summary = ''; $section->sequence = ''; $section->visible = 1; $section->id = insert_record('course_sections', $section); } if (!empty($section->sequence) or !empty($section->summary) or $editing) { print_box_start('generalbox sitetopic'); /// If currently moving a file then show the current clipboard if (ismoving($SITE->id)) { $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname))); echo '<p><font size="2">'; echo "{$stractivityclipboard} (<a href=\"course/mod.php?cancelcopy=true&sesskey={$USER->sesskey}\">" . get_string('cancel') . '</a>)'; echo '</font></p>'; } $options = NULL; $options->noclean = true; echo format_text($section->summary, FORMAT_HTML, $options); if ($editing) { $streditsummary = get_string('editsummary'); echo "<a title=\"{$streditsummary}\" " . " href=\"course/editsection.php?id={$section->id}\"><img src=\"{$CFG->pixpath}/t/edit.gif\" " . " class=\"iconsmall\" alt=\"{$streditsummary}\" /></a><br /><br />"; } get_all_mods($SITE->id, $mods, $modnames, $modnamesplural, $modnamesused); print_section($SITE, $section, $mods, $modnamesused, true); if ($editing) { print_section_add_menus($SITE, $section->section, $modnames); } print_box_end(); } } if (isloggedin() and !isguest() and isset($CFG->frontpageloggedin)) { $frontpagelayout = $CFG->frontpageloggedin; } else { $frontpagelayout = $CFG->frontpage; } foreach (explode(',', $frontpagelayout) as $v) { switch ($v) { /// Display the main part of the front page. case FRONTPAGENEWS: if ($SITE->newsitems) { // Print forums only when needed require_once $CFG->dirroot . '/mod/forum/lib.php'; if (!($newsforum = forum_get_course_forum($SITE->id, 'news'))) { error('Could not find or create a main news forum for the site'); } if (!empty($USER->id)) { $SESSION->fromdiscussion = $CFG->wwwroot; if (forum_is_subscribed($USER->id, $newsforum)) { $subtext = get_string('unsubscribe', 'forum'); } else { $subtext = get_string('subscribe', 'forum'); } print_heading_block($newsforum->name); echo '<div class="subscribelink"><a href="mod/forum/subscribe.php?id=' . $newsforum->id . '">' . $subtext . '</a></div>'; } else { print_heading_block($newsforum->name); } forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC'); } break; case FRONTPAGECOURSELIST: if (isloggedin() and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() and empty($CFG->disablemycourses)) { print_heading_block(get_string('mycourses')); print_my_moodle(); } else { if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() or count_records('course') <= FRONTPAGECOURSELIMIT) { // admin should not see list of courses when there are too many of them print_heading_block(get_string('availablecourses')); print_courses(0); } } break; case FRONTPAGECATEGORYNAMES: print_heading_block(get_string('categories')); print_box_start('generalbox categorybox'); print_whole_category_list(NULL, NULL, NULL, -1, false); print_box_end(); print_course_search('', false, 'short'); break; case FRONTPAGECATEGORYCOMBO: print_heading_block(get_string('categories')); print_box_start('generalbox categorybox'); print_whole_category_list(NULL, NULL, NULL, -1, true); print_box_end(); print_course_search('', false, 'short'); break; case FRONTPAGETOPICONLY: // Do nothing!! :-) break; } // echo '<br />'; REMOVED FOR THE FORMAT } print_container_end(); /// END COPY/PASTE FROM INDEX.PHP return true; }
/** * Print a message in a standard themed container. * * @param string $message, the content of the container * @param boolean $clearfix clear both sides * @param string $classes, space-separated class names. * @param string $idbase * @param boolean $return, return as string or just print it * @return string or void */ function print_container($message, $clearfix = false, $classes = '', $idbase = '', $return = false) { $output = print_container_start($clearfix, $classes, $idbase, true); $output .= stripslashes_safe($message); $output .= print_container_end(true); if ($return) { return $output; } else { echo $output; } }
function definition() { global $CFG; global $usr; global $cm; global $new_array; global $DB; global $values; // default star values for each type of feedback $values = array(FEED_TYPE_PRE => '1', FEED_TYPE_LAB => '1'); // we get these as parameters - that's what _customdata is for $cm = $this->_customdata['cm']; $id = $this->_customdata['id']; $f_id = $this->_customdata['f_id']; $user_id = $this->_customdata['user_id']; $course_id = $this->_customdata['courseid']; // // I guess these are standard, but I'm not using them (maybe moodle is) $mform =& $this->_form; $mform->addElement('hidden', 'action'); $mform->setType('action', PARAM_TEXT); $mform->addElement('hidden', 'id', $id); $mform->setType('id', PARAM_INT); // // includes and s... tuff $mform->addElement('html', '<script type="text/javascript" src="prototype.js"></script>'); $mform->addElement('html', '<script type="text/javascript" src="stars.js"></script>'); // $context = get_context_instance(CONTEXT_MODULE, $cm->id); // this is actually the section id $section = $cm->section; // get ALL the modules! $new_array = get_feedback_module_teacher($course_id, $section, $f_id, STUDENT_FOR_TEACHER); // I'm actually wondering if this has any use - we're not displaying \ // old feedback answers anymore $records = get_feedback_answer_records($course_id, $user_id, $section, $f_id, STUDENT_FOR_TEACHER); // basically, it updates the default values to match your old answers if (isset($records)) { foreach ($records as $record) { $values[$record->type] = $record->answer; } } // // this little guy saved me from a lot of class extensions // it clears your string caches, making sure you get up-to-date ones get_string_manager()->reset_caches(); // ah! good, old hacks! // they help making some decisions (maybe even display an error) // see below the "foreach" // nothing becomes 0 when we have actualy displayed something $nothing = 1; // something becomes 1 when new_array is NOT_NULL $something = 0; // // so far, we only have two types of modules: \ // presentation, and laboratory // if you need to add more, you may add other "elseif"s, \ // or you may go for a "switch" statement // let's take each module at a time foreach ($new_array as $data) { // oh, we found one! let's make sure we remember that we did $something = 1; // is it a presentation-type? if ($data->type == FEED_TYPE_PRE) { // can we give ratings to the teacher? if (has_capability('mod/feedbackccna:rateteacher', $context) and $data->allow == FEED_ALLOWED and !has_capability('mod/feedbackccna:feededit', $context) and (!get_user_absent($course_id, $user_id, $f_id) or !class_graded($course_id, $f_id)) and !get_user_answer_true($course_id, $user_id, FEED_TYPE_PRE, $f_id)) { // Then, you have my permission to answer! // we'll display something, so keep an eye on the hacks $nothing = 0; // display the header (basically, the box-thingy) $mform->addElement('header', 'editorheader', get_string('headerlabel_presentation', 'feedbackccna')); // so, here are the fabled stars // first of all, a container $mform->addElement('html', '<div id="star' . $data->id . '1"></div>'); // keep the value in a hidden element $mform->addElement('hidden', 'value' . $data->id . FEED_TYPE_PRE, null, array('id' => 'value' . $data->id . FEED_TYPE_PRE, 'type' => 'hidden')); // we'll create the star object here $mform->addElement('html', '<script type = "text/javascript"> var s1 = new Stars({ maxRating: 5, imagePath: "images/", value: ' . $values[FEED_TYPE_PRE] . ', container:"star' . $data->id . FEED_TYPE_PRE . '", bindField:"value' . $data->id . FEED_TYPE_PRE . '" }); </script>'); // // we only show one question at once. no flooding! break; // } // if the user is a teacher if (has_capability('mod/feedbackccna:feedallow', $context)) { // the display rule stays $nothing = 0; // if they didn't allow students to answer a question yet, \ // they may do so now if ($data->allow != FEED_ALLOWED) { // again, add the header/box/whatever $mform->addElement('header', 'editorheader', get_string('headerlabel2_presentation', 'feedbackccna')); // add a checkbox, asking to allow the answers $mform->addElement('advcheckbox', 'check' . $data->id . '1', get_string('checkbox', 'feedbackccna'), null, null, array(0, 1)); // what if they allowed them to, but changed mind? } else { // let's see how many have answered $number1 = get_user_answer_count($course_id, FEED_TYPE_PRE, $f_id); // we may also like to see how many are they in total $number_total = get_user_total($context); // header. see above $mform->addElement('header', 'editorheader', get_string('headerlabel3_presentation', 'feedbackccna')); // this would display something like \ // "1 out of over 9000 students have answered" $mform->addElement('static', 'text' . FEED_TYPE_PRE, null, $number1 . get_string('text_mid', 'feedbackccna') . $number_total . get_string('text_last', 'feedbackccna')); // help the poor teacher! // show him the names of the infidels! $mform->addHelpButton('text' . FEED_TYPE_PRE, 'student_number1', 'feedbackccna'); $mform->addElement('html', '<br/>'); // this is serious. end this madness now! $mform->addElement('advcheckbox', 'uncheck' . $data->id . FEED_TYPE_PRE, get_string('checkbox2', 'feedbackccna'), null, null, array(0, 1)); } } // then, maybe it is a laboratory that we're talking about? } elseif ($data->type == FEED_TYPE_LAB) { // is we're dealing with a student, the same conditions apply if (has_capability('mod/feedbackccna:rateteacher', $context) and $data->allow == FEED_ALLOWED and !has_capability('mod/feedbackccna:feededit', $context) and (!get_user_absent($course_id, $user_id, $f_id) or !class_graded($course_id, $f_id)) and !get_user_answer_true($course_id, $user_id, FEED_TYPE_LAB, $f_id)) { // Then, you have my permission to answer! $nothing = 0; $mform->addElement('header', 'editorheader', get_string('headerlabel_lab', 'feedbackccna')); $mform->addElement('html', '<div id="star' . $data->id . FEED_TYPE_LAB . '"></div>'); $mform->addElement('hidden', 'value' . $data->id . FEED_TYPE_LAB, null, array('id' => 'value' . $data->id . FEED_TYPE_LAB, 'type' => 'hidden')); $mform->addElement('html', '<script type = "text/javascript"> var s2 = new Stars({ maxRating: 5, imagePath: "images/", value: ' . $values[FEED_TYPE_LAB] . ', container:"star' . $data->id . FEED_TYPE_LAB . '", bindField:"value' . $data->id . FEED_TYPE_LAB . '" }); </script>'); break; } // but, if they're teachers, the same as above goes if (has_capability('mod/feedbackccna:feedallow', $context)) { $nothing = 0; if ($data->allow != FEED_ALLOWED) { $mform->addElement('header', 'editorheader', get_string('headerlabel2_lab', 'feedbackccna')); $mform->addElement('advcheckbox', 'check' . $data->id . FEED_TYPE_LAB, get_string('checkbox', 'feedbackccna'), null, null, array(0, 1)); } else { $number2 = get_user_answer_count($course_id, FEED_TYPE_LAB, $f_id); $number_total = get_user_total($context); $mform->addElement('header', 'editorheader', get_string('headerlabel3_lab', 'feedbackccna')); $mform->addElement('static', 'text' . FEED_TYPE_LAB, null, $number2 . get_string('text_mid', 'feedbackccna') . $number_total . get_string('text_last', 'feedbackccna')); $mform->addHelpButton('text' . FEED_TYPE_LAB, 'student_number2', 'feedbackccna'); $mform->addElement('html', '<br/>'); $mform->addElement('advcheckbox', 'uncheck' . $data->id . FEED_TYPE_LAB, get_string('checkbox2', 'feedbackccna'), null, null, array(0, 1)); } } } } // // let's see about those hacks :) // if we displayed nothing (shame on us) if ($nothing) { // if we had some modules, but we were somehow constrained if ($something) { // the user is a student, so tell them their teacher is bad $mform->addElement('header', 'editorheader', get_string('headerlabel_nothing', 'feedbackccna')); // and help them get to da choppa $mform->addElement('html', '<a href = "' . $CFG->wwwroot . '/course/view.php?id=' . $course_id . '" >Back to course </a>'); // if there were none, send some error (you'll hate this one >:) ) } else { print_error('Feedback category is non-existent! Please check ' . 'that your modules have been correctly inserted into the ' . 'database! Error sent from locallib.php'); // when the above error appears, it means that the "new_array" \ // variable in this file is empty. please check the return \ // output of the function populating that variable } // so, we displayed something, after all? } else { // admin left aside, show a button to all students if (has_capability('mod/feedbackccna:rateteacher', $context) or has_capability('mod/feedbackccna:feedallow', $context)) { // this block prints a submit button, so that we may \ // actually send that answer print_container_start(false, 'singlebutton'); $this->add_action_buttons(false, get_string('submitlabel', 'feedbackccna')); print_container_end(); // } } }
function print_project_details($project, $summary = FALSE, $align = "center") { global $CFG, $DB; $projectlink = $CFG->wwwroot . '/project/view.php?id=' . $project->id; if ($align == 'center') { print_container_start(false, 'projectpanel projectpanelfull ' . $align); } else { print_container_start(false, 'projectpanel ' . $align); } print_heading('<a href="' . $projectlink . '">' . $project->name . '</a>', 'left', 2, 'title'); $start = getdate($project->startdate); $end = getdate($project->enddate); $startstr = $start['mday'] . ' ' . $start['month'] . ' ' . $start['year']; $endstr = $end['mday'] . ' ' . $end['month'] . ' ' . $end['year']; print_heading($project->subtitle, 'left', 3, 'subtitle'); print_heading($startstr . ' - ' . $endstr, 'left', 3, 'subtitledate'); echo print_container_start(false, 'desccontainer'); echo '<img src="' . $CFG->wwwroot . '/file.php?file=/1/' . $project->logo . '" class="logo" />'; if ($summary) { $extra = substr($project->description, SHORTDESCLEN); $pos = strpos($project->description, " "); if ($pos != false) { echo '<p class="description">' . substr($project->description, 0, SHORTDESCLEN + $pos) . '... ' . '<a href="' . $projectlink . '" class="more">' . get_string('more', 'project') . '</a>' . '</p>'; } else { echo '<p class="description">' . $project->description . '</p>'; } } else { echo '<p class="description">' . $project->description . '</p>'; } echo print_container_end(); $manager = $DB->get_record('user', array('id' => $project->manager)); echo print_heading(get_string('projectmanager', 'project'), 'left', '4', 'label'); echo '<p class="info">' . $manager->firstname . ' ' . $manager->lastname . '</p>'; $team = $DB->get_records_sql("\n\t\tSELECT u.*, tm.role\n\t\tFROM {user} u\n\t\tINNER JOIN {project_team_members} tm\n\t\tWHERE tm.userid = u.id\n\t\tAND tm.projectid = {$project->id}\n\t\tORDER BY tm.role"); if ($team != FALSE) { echo print_heading(get_string('team', 'project'), 'left', '4', 'label'); echo '<ul>'; foreach ($team as $member) { echo '<li>' . $member->firstname . ' ' . $member->lastname . '<span class="role"> - ' . $member->role . '</span></li>'; } echo '</ul>'; } print_container_end(); }
/** * 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) { global $CFG, $THEME; if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) { $url = sid_process_url($url); } $message = clean_text($message); $encodedurl = preg_replace("/\\&(?![a-zA-Z0-9#]{1,8};)/", "&", $url); $encodedurl = preg_replace('/^.*href="([^"]*)".*$/', "\\1", clean_text('<a href="' . $encodedurl . '" />')); $url = str_replace('&', '&', $encodedurl); /// At developer debug level. Don't redirect if errors have been printed on screen. /// Currenly only works in PHP 5.2+; we do not want strict PHP5 errors $lasterror = error_get_last(); $error = defined('DEBUGGING_PRINTED') or !empty($lasterror) && $lasterror['type'] & DEBUG_DEVELOPER; $errorprinted = debugging('', DEBUG_ALL) && $CFG->debugdisplay && $error; if ($errorprinted) { $message = "<strong>Error output, so disabling automatic redirect.</strong></p><p>" . $message; } $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('" . addslashes_js($url) . "');" . "\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 :-( // IECISA *********** MODIFIED -> to put out sitename //print_header('', '', '', '', $errorprinted ? '' : ('<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />')); print_header($CFG->sitename, $CFG->sitename, '', '', $errorprinted ? '' : '<meta http-equiv="refresh" content="' . $delay . '; url=' . $encodedurl . '" />'); // ********* END $delay += 3; // double redirect prevention, it was sometimes breaking upgrades before 1.7 } else { print_container_end_all(false, $THEME->open_header_containers); } //IECISA ********** ADDED -> to have the save html aspect than the other pages /// print page content print_container_start(true, 'content-body', 'content-body'); corner_left_top(); corner_left_bottom(); corner_right_top(); corner_right_bottom(); // ********** END echo '<div id="redirect">'; echo '<div id="message">' . $message . '</div>'; echo '<div id="continue">( <a href="' . $encodedurl . '">' . get_string('continue') . '</a> )</div>'; echo '</div>'; //IECISA ********** ADDED -> to have the save html aspect than the other pages print_container_end(); // *********** END if (!$errorprinted) { ?> <script type="text/javascript"> //<![CDATA[ function redirect() { document.location.replace('<?php echo addslashes_js($url); ?> '); } setTimeout("redirect()", <?php echo $delay * 1000; ?> ); //]]> </script> <?php } $CFG->docroot = false; // to prevent the link to moodle docs from being displayed on redirect page. print_footer('none'); die; }