MDL-8223 - last global $course hacks removed

This commit is contained in:
skodak
2007-01-19 10:29:03 +00:00
parent 627c9eae47
commit 60f9e36ee8
8 changed files with 32 additions and 59 deletions
+4 -9
View File
@@ -248,7 +248,7 @@ function get_mimetype_description($mimetype,$capitalise=false) {
* @param string $mimetype Include to specify the MIME type; leave blank to have it guess the type from $filename
*/
function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='') {
global $CFG;
global $CFG, $COURSE;
// Use given MIME type if specified, otherwise guess it using mimeinfo.
// IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
@@ -369,18 +369,12 @@ function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=
readfile_chunked($path);
}
} else { // Try to put the file through filters
global $course; // HACK!
if (!empty($course->id)) {
$courseid = $course->id;
} else {
$courseid = SITEID;
}
if ($mimetype == 'text/html') {
$options = new object();
$options->noclean = true;
$options->nocache = true; // temporary workaround for MDL-5136
$text = $pathisstring ? $path : implode('', file($path));
$output = format_text($text, FORMAT_HTML, $options, $courseid);
$output = format_text($text, FORMAT_HTML, $options, $COURSE->id);
if (!empty($CFG->usesid) && empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) {
//cookieless mode - rewrite links
$output = sid_ob_rewrite($output);
@@ -392,10 +386,11 @@ function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=
echo $output;
// only filter text if filter all files is selected
} else if (($mimetype == 'text/plain') and ($filter == 1)) {
$options = new object();
$options->newlines = false;
$options->noclean = true;
$text = htmlentities($pathisstring ? $path : implode('', file($path)));
$output = '<pre>'. format_text($text, FORMAT_MOODLE, $options, $courseid) .'</pre>';
$output = '<pre>'. format_text($text, FORMAT_MOODLE, $options, $COURSE->id) .'</pre>';
if (!empty($CFG->usesid) && empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) {
//cookieless mode - rewrite links
$output = sid_ob_rewrite($output);
+7 -10
View File
@@ -1583,7 +1583,7 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null) {
} else if (is_object($courseorid)) {
$COURSE = clone($courseorid);
} else {
global $course; // We use the global hack once here so it doesn't need to be used again
global $course; // used here only to prevent repeated fetching from DB
if ($course->id == $courseorid) {
$COURSE = clone($course);
} else {
@@ -3202,14 +3202,13 @@ function moodle_process_email($modargs,$body) {
*/
function email_to_user($user, $from, $subject, $messagetext, $messagehtml='', $attachment='', $attachname='', $usetrueaddress=true, $replyto='', $replytoname='') {
global $CFG, $FULLME;
global $CFG, $FULLME, $COURSE;
global $course; // This is a bit of an ugly hack to be gotten rid of later
if (!empty($course->lang)) { // Course language is defined
$CFG->courselang = $course->lang;
if (!empty($COURSE->lang)) { // Course language is defined
$CFG->courselang = $COURSE->lang;
}
if (!empty($course->theme)) { // Course theme is defined
$CFG->coursetheme = $course->theme;
if (!empty($COURSE->theme)) { // Course theme is defined
$CFG->coursetheme = $COURSE->theme;
}
include_once($CFG->libdir .'/phpmailer/class.phpmailer.php');
@@ -4127,12 +4126,10 @@ function get_string($identifier, $module='', $a=NULL, $extralocations=NULL) {
global $CFG;
global $course, $COURSE;
global $COURSE;
if (empty($CFG->courselang)) {
if (!empty($COURSE->lang)) {
$CFG->courselang = $COURSE->lang;
} else if (!empty($course->lang)) { // ugly backwards compatibility hack
$CFG->courselang = $course->lang;
}
}
+3 -19
View File
@@ -2030,24 +2030,16 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
define('HEADER_PRINTED', 'true');
global $course, $COURSE;
global $COURSE;
if (!empty($COURSE->lang)) {
$CFG->courselang = $COURSE->lang;
moodle_setlocale();
} else if (!empty($course->lang)) { // ugly backwards compatibility hack
$CFG->courselang = $course->lang;
moodle_setlocale();
}
if (!empty($COURSE->theme)) {
if (!empty($CFG->allowcoursethemes)) {
$CFG->coursetheme = $COURSE->theme;
theme_setup();
}
} else if (!empty($course->theme)) { // ugly backwards compatibility hack
if (!empty($CFG->allowcoursethemes)) {
$CFG->coursetheme = $course->theme;
theme_setup();
}
}
/// We have to change some URLs in styles if we are in a $HTTPSPAGEREQUIRED page
@@ -2093,11 +2085,7 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
} else {
$wwwroot = str_replace('http:','https:',$CFG->wwwroot);
}
if (isset($course->id)) {
$menu = user_login_string($course);
} else {
$menu = user_login_string($SITE);
}
$menu = user_login_string($COURSE);
}
if (isset($SESSION->justloggedin)) {
@@ -2193,11 +2181,7 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
page_id_and_class($pageid, $pageclass);
if (isset($course->id)) {
$pageclass .= ' course-'.$course->id;
} else {
$pageclass .= ' course-'.SITEID;
}
$pageclass .= ' course-'.$COURSE->id;
if (($pageid != 'site-index') && ($pageid != 'course-view') &&
($pageid != 'admin-settings')) {