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
+5 -5
View File
@@ -6,7 +6,7 @@ class enrol_authorize_form extends moodleform
{
function definition()
{
global $course;
global $COURSE;
global $CFG, $USER;
$paymentmethodsenabled = get_list_of_payment_methods();
@@ -22,7 +22,7 @@ class enrol_authorize_form extends moodleform
$mform->addElement('static', '', '<div align="right">' . $othermethodstr . '&nbsp;&nbsp;</div>', '');
}
$mform->addElement('hidden', 'id', $course->id);
$mform->addElement('hidden', 'id', $COURSE->id);
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'paymentmethod', $paymentmethod);
@@ -220,16 +220,16 @@ class enrol_authorize_form extends moodleform
function other_method($currentmethod)
{
global $course;
global $COURSE;
if ($currentmethod == AN_METHOD_CC) {
$otheravailable = in_array(AN_METHOD_ECHECK, get_list_of_payment_methods());
$url = 'enrol.php?id='.$course->id.'&amp;paymentmethod='.AN_METHOD_ECHECK;
$url = 'enrol.php?id='.$COURSE->id.'&amp;paymentmethod='.AN_METHOD_ECHECK;
$stringtofetch = 'usingecheckmethod';
}
else {
$otheravailable = in_array(AN_METHOD_CC, get_list_of_payment_methods());
$url = 'enrol.php?id='.$course->id.'&amp;paymentmethod='.AN_METHOD_CC;
$url = 'enrol.php?id='.$COURSE->id.'&amp;paymentmethod='.AN_METHOD_CC;
$stringtofetch = 'usingccmethod';
}
if ($otheravailable) {
+2 -1
View File
@@ -155,8 +155,9 @@ function grade_get_users_by_group($course, $group) {
function grade_get_formatted_grades() {
global $CFG;
global $course;
global $COURSE;
global $preferences;
$course = $COURSE;
$i = 2; // index to differentiate activities with the same name MDL-6876
$grades = grade_get_grades();
if (isset($grades)) {
+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')) {
+3 -6
View File
@@ -12,13 +12,10 @@
}
//Get the course theme
$course = get_record('course','id',$chatuser->course,'','','','','id,theme');
//Set the global course if necessary
if (!empty($course->theme)) {
global $course;
}
$COURSE = get_record('course','id',$chatuser->course);
//Get the user theme
$USER = get_record('user','id',$chatuser->userid,'','','','','id, theme');
$USER = get_record('user','id',$chatuser->userid);
//Adjust the prefered theme (main, course, user)
theme_setup();
+6 -7
View File
@@ -123,13 +123,12 @@ class qformat_blackboard_6 extends qformat_default {
}
function copy_file_to_course($filename) {
global $CFG;
global $course;
global $CFG, $COURSE;
$filename = str_replace('\\','/',$filename);
$fullpath = $this->temp_dir.'/res00001/'.$filename;
$basename = basename($filename);
$copy_to = $CFG->dataroot.'/'.$course->id.'/bb_import';
$copy_to = $CFG->dataroot.'/'.$COURSE->id.'/bb_import';
if ($this->check_dir_exists($copy_to,true)) {
if(is_readable($fullpath)) {
@@ -347,7 +346,7 @@ function create_raw_question($quest) {
}
function process_block($cur_block, &$block) {
global $course, $CFG;
global $COURSE, $CFG;
$cur_type = $cur_block['@']['class'];
switch($cur_type) {
@@ -363,7 +362,7 @@ function process_block($cur_block, &$block) {
if ($block->file != '') {
// if we have a file copy it to the course dir and adjust its name to be visible over the web.
$block->file = $this->copy_file_to_course($block->file);
$block->file = $CFG->wwwroot.'/file.php/'.$course->id.'/bb_import/'.basename($block->file);
$block->file = $CFG->wwwroot.'/file.php/'.$COURSE->id.'/bb_import/'.basename($block->file);
}
break;
case 'Block':
@@ -845,7 +844,7 @@ function process_matching($quest, &$questions) {
$questions[] = $question;
}
else {
global $course, $CFG;
global $COURSE, $CFG;
print '<table class="boxaligncenter" border="1">';
print '<tr><td colspan="2" style="background-color:#FF8888;">This matching question is malformed. Please ensure there are no blank answers, no two questions have the same answer, and/or there are correct answers for each question. There must be at least as many subanswers as subquestions, and at least one subquestion.</td></tr>';
@@ -853,7 +852,7 @@ function process_matching($quest, &$questions) {
if (isset($quest->QUESTION_BLOCK->file)) {
print '<br/><font color="red">There is a subfile contained in the zipfile that has been copied to course files: bb_import/'.basename($quest->QUESTION_BLOCK->file).'</font>';
if (preg_match('/(gif|jpg|jpeg|png)$/i', $quest->QUESTION_BLOCK->file)) {
print '<img src="'.$CFG->wwwroot.'/file.php/'.$course->id.'/bb_import/'.basename($quest->QUESTION_BLOCK->file).'" />';
print '<img src="'.$CFG->wwwroot.'/file.php/'.$COURSE->id.'/bb_import/'.basename($quest->QUESTION_BLOCK->file).'" />';
}
}
print "</td></tr>";
+2 -2
View File
@@ -124,8 +124,8 @@ class qformat_hotpot extends qformat_default {
if ($moodle_14) {
$question->answers = array();
} else {
global $course; // set in mod/quiz/import.php
$question->course = $course->id;
global $COURSE; // initialized in questions/import.php
$question->course = $COURSE->id;
$question->options = new stdClass();
$question->options->questions = array(); // one for each gap
}