]> git.mjollnir.org Git - moodle.git/commitdiff
Conversion of double quoted string to single quoted literals. Also added some extra...
authordhawes <dhawes>
Wed, 22 Sep 2004 14:39:15 +0000 (14:39 +0000)
committerdhawes <dhawes>
Wed, 22 Sep 2004 14:39:15 +0000 (14:39 +0000)
lib/moodlelib.php
lib/weblib.php

index 2bdbbf757fa05737dd3a289dac9bf290bbcf3ebf..fab0d74e78906e7fea6bcd2ac8ac7e615a940e52 100644 (file)
@@ -46,7 +46,7 @@ define('VISIBLEGROUPS', 2);
 function require_variable($var) {
 /// Variable must be present
     if (! isset($var)) {
-        error("A required parameter was missing");
+        error('A required parameter was missing');
     }
 }
 
@@ -65,12 +65,12 @@ function set_config($name, $value) {
 
     $CFG->$name = $value;  // So it's defined for this invocation at least
 
-    if (get_field("config", "name", "name", $name)) {
-        return set_field("config", "value", $value, "name", $name);
+    if (get_field('config', 'name', 'name', $name)) {
+        return set_field('config', 'value', $value, 'name', $name);
     } else {
         $config->name = $name;
         $config->value = $value;
-        return insert_record("config", $config);
+        return insert_record('config', $config);
     }
 }
 
@@ -107,7 +107,7 @@ function set_user_preference($name, $value, $user=NULL) {
     }
 
     if ($preference = get_record('user_preferences', 'userid', $user->id, 'name', $name)) {
-        if (set_field("user_preferences", "value", $value, "id", $preference->id)) {
+        if (set_field('user_preferences', 'value', $value, 'id', $preference->id)) {
             $user->preference[$name] = $value;
             return true;
         } else {
@@ -188,14 +188,14 @@ function format_time($totalsecs, $str=NULL) {
     $totalsecs = abs($totalsecs);
 
     if (!$str) {  // Create the str structure the slow way
-        $str->day   = get_string("day");
-        $str->days  = get_string("days");
-        $str->hour  = get_string("hour");
-        $str->hours = get_string("hours");
-        $str->min   = get_string("min");
-        $str->mins  = get_string("mins");
-        $str->sec   = get_string("sec");
-        $str->secs  = get_string("secs");
+        $str->day   = get_string('day');
+        $str->days  = get_string('days');
+        $str->hour  = get_string('hour');
+        $str->hours = get_string('hours');
+        $str->min   = get_string('min');
+        $str->mins  = get_string('mins');
+        $str->sec   = get_string('sec');
+        $str->secs  = get_string('secs');
     }
 
     $days      = floor($totalsecs/86400);
@@ -210,24 +210,24 @@ function format_time($totalsecs, $str=NULL) {
     $sh = ($hours == 1) ? $str->hour : $str->hours;
     $sd = ($days == 1)  ? $str->day  : $str->days;
 
-    $odays = "";
-    $ohours = "";
-    $omins = "";
-    $osecs = "";
+    $odays = '';
+    $ohours = '';
+    $omins = '';
+    $osecs = '';
 
-    if ($days)  $odays  = "$days $sd";
-    if ($hours) $ohours = "$hours $sh";
-    if ($mins)  $omins  = "$mins $sm";
-    if ($secs)  $osecs  = "$secs $ss";
+    if ($days)  $odays  = $days .' '. $sd;
+    if ($hours) $ohours = $hours .' '. $sh;
+    if ($mins)  $omins  = $mins .' '. $sm;
+    if ($secs)  $osecs  = $secs .' '. $ss;
 
-    if ($days)  return "$odays $ohours";
-    if ($hours) return "$ohours $omins";
-    if ($mins)  return "$omins $osecs";
-    if ($secs)  return "$osecs";
-    return get_string("now");
+    if ($days)  return $odays .' '. $ohours;
+    if ($hours) return $ohours .' '. $omins;
+    if ($mins)  return $omins .' '. $osecs;
+    if ($secs)  return $osecs;
+    return get_string('now');
 }
 
-function userdate($date, $format="", $timezone=99, $fixday = true) {
+function userdate($date, $format='', $timezone=99, $fixday = true) {
 /// Returns a formatted string that represents a date in user time
 /// WARNING: note that the format is for strftime(), not date().
 /// Because of a bug in most Windows time libraries, we can't use
@@ -238,11 +238,11 @@ function userdate($date, $format="", $timezone=99, $fixday = true) {
 /// If parammeter fixday = true (default), then take off leading
 /// zero from %d, else mantain it.
 
-    if ($format == "") {
-        $format = get_string("strftimedaydatetime");
+    if ($format == '') {
+        $format = get_string('strftimedaydatetime');
     }
 
-    $formatnoday = str_replace("%d", "DD", $format);
+    $formatnoday = str_replace('%d', 'DD', $format);
     if ($fixday) {
         $fixday = ($formatnoday != $format);
     }
@@ -252,8 +252,8 @@ function userdate($date, $format="", $timezone=99, $fixday = true) {
     if (abs($timezone) > 13) {
         if ($fixday) {
             $datestring = strftime($formatnoday, $date);
-            $daystring  = str_replace(" 0", "", strftime(" %d", $date));
-            $datestring = str_replace("DD", $daystring, $datestring);
+            $daystring  = str_replace(' 0', '', strftime(" %d", $date));
+            $datestring = str_replace('DD', $daystring, $datestring);
         } else {
             $datestring = strftime($format, $date);
         }
@@ -261,8 +261,8 @@ function userdate($date, $format="", $timezone=99, $fixday = true) {
         $date = $date + (int)($timezone * 3600);
         if ($fixday) {
             $datestring = gmstrftime($formatnoday, $date);
-            $daystring  = str_replace(" 0", "", gmstrftime(" %d", $date));
-            $datestring = str_replace("DD", $daystring, $datestring);
+            $daystring  = str_replace(' 0', '', gmstrftime(" %d", $date));
+            $datestring = str_replace('DD', $daystring, $datestring);
         } else {
             $datestring = gmstrftime($format, $date);
         }
@@ -282,16 +282,16 @@ function usergetdate($date, $timezone=99) {
     }
     //There is no gmgetdate so I have to fake it...
     $date = $date + (int)($timezone * 3600);
-    $getdate["seconds"] = gmstrftime("%S", $date);
-    $getdate["minutes"] = gmstrftime("%M", $date);
-    $getdate["hours"]   = gmstrftime("%H", $date);
-    $getdate["mday"]    = gmstrftime("%d", $date);
-    $getdate["wday"]    = gmstrftime("%u", $date);
-    $getdate["mon"]     = gmstrftime("%m", $date);
-    $getdate["year"]    = gmstrftime("%Y", $date);
-    $getdate["yday"]    = gmstrftime("%j", $date);
-    $getdate["weekday"] = gmstrftime("%A", $date);
-    $getdate["month"]   = gmstrftime("%B", $date);
+    $getdate['seconds'] = gmstrftime("%S", $date);
+    $getdate['minutes'] = gmstrftime("%M", $date);
+    $getdate['hours']   = gmstrftime("%H", $date);
+    $getdate['mday']    = gmstrftime("%d", $date);
+    $getdate['wday']    = gmstrftime("%u", $date);
+    $getdate['mon']     = gmstrftime("%m", $date);
+    $getdate['year']    = gmstrftime("%Y", $date);
+    $getdate['yday']    = gmstrftime("%j", $date);
+    $getdate['weekday'] = gmstrftime("%A", $date);
+    $getdate['month']   = gmstrftime("%B", $date);
     return $getdate;
 }
 
@@ -314,10 +314,10 @@ function usergetmidnight($date, $timezone=99) {
     $userdate = usergetdate($date, $timezone);
 
     if (abs($timezone) > 13) {
-        return mktime(0, 0, 0, $userdate["mon"], $userdate["mday"], $userdate["year"]);
+        return mktime(0, 0, 0, $userdate['mon'], $userdate['mday'], $userdate['year']);
     }
 
-    $timemidnight = gmmktime (0, 0, 0, $userdate["mon"], $userdate["mday"], $userdate["year"]);
+    $timemidnight = gmmktime (0, 0, 0, $userdate['mon'], $userdate['mday'], $userdate['year']);
     return usertime($timemidnight, $timezone); // Time of midnight of this user's day, in GMT
 
 }
@@ -328,15 +328,15 @@ function usertimezone($timezone=99) {
     $timezone = get_user_timezone($timezone);
 
     if (abs($timezone) > 13) {
-        return "server time";
+        return 'server time';
     }
     if (abs($timezone) < 0.5) {
-        return "GMT";
+        return 'GMT';
     }
     if ($timezone > 0) {
-        return "GMT+$timezone";
+        return 'GMT+'. $timezone;
     } else {
-        return "GMT$timezone";
+        return 'GMT'. $timezone;
     }
 }
 
@@ -371,8 +371,8 @@ function require_login($courseid=0, $autologinguest=true) {
     // First check that the user is logged in to the site.
     if (! (isset($USER->loggedin) and $USER->confirmed and ($USER->site == $CFG->wwwroot)) ) { // They're not
         $SESSION->wantsurl = $FULLME;
-        if (!empty($_SERVER["HTTP_REFERER"])) {
-            $SESSION->fromurl  = $_SERVER["HTTP_REFERER"];
+        if (!empty($_SERVER['HTTP_REFERER'])) {
+            $SESSION->fromurl  = $_SERVER['HTTP_REFERER'];
         }
         $USER = NULL;
         if ($autologinguest and $CFG->autologinguests and $courseid and get_field('course','guest','id',$courseid)) {
@@ -381,10 +381,10 @@ function require_login($courseid=0, $autologinguest=true) {
             $loginguest = '';
         }
         if (empty($CFG->loginhttps)) {
-            redirect("$CFG->wwwroot/login/index.php$loginguest");
+            redirect($CFG->wwwroot .'/login/index.php'. $loginguest);
         } else {
-            $wwwroot = str_replace('http','https',$CFG->wwwroot);
-            redirect("$wwwroot/login/index.php$loginguest");
+            $wwwroot = str_replace('http','https', $CFG->wwwroot);
+            redirect($wwwroot .'/login/index.php'. $loginguest);
         }
         die;
     }
@@ -393,19 +393,19 @@ function require_login($courseid=0, $autologinguest=true) {
     reload_user_preferences();
     if (isset($USER->preference['auth_forcepasswordchange'])){
         if (is_internal_auth() || $CFG->{'auth_'.$USER->auth.'_stdchangepassword'}){
-            redirect("$CFG->wwwroot/login/change_password.php");
+            redirect($CFG->wwwroot .'/login/change_password.php');
         } elseif($CFG->changepassword) {
             redirect($CFG->changepassword);
         } else {
-            error("You cannot proceed without changing your password. 
+            error('You cannot proceed without changing your password. 
                    However there is no available page for changing it.
-                   Please contact your Moodle Administrator.");
+                   Please contact your Moodle Administrator.');
         }
     }
 
     // Check that the user account is properly set up
     if (user_not_fully_set_up($USER)) {
-        redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&amp;course=".SITEID);
+        redirect($CFG->wwwroot .'/user/edit.php?id='. $USER->id .'&amp;course='. SITEID);
         die;
     }
 
@@ -415,23 +415,23 @@ function require_login($courseid=0, $autologinguest=true) {
             if (isset($USER->realuser)) {   // Make sure the REAL person can also access this course
                 if (!isteacher($courseid, $USER->realuser)) {
                     print_header();
-                    notice(get_string("studentnotallowed", "", fullname($USER, true)), "$CFG->wwwroot/");
+                    notice(get_string('studentnotallowed', '', fullname($USER, true)), $CFG->wwwroot .'/');
                 }
             }
             return;   // user is a member of this course.
         }
-        if (! $course = get_record("course", "id", $courseid)) {
-            error("That course doesn't exist");
+        if (! $course = get_record('course', 'id', $courseid)) {
+            error('That course doesn\'t exist');
         }
         if (!$course->visible) {
             print_header();
-            notice(get_string("studentnotallowed", "", fullname($USER, true)), "$CFG->wwwroot/");
+            notice(get_string('studentnotallowed', '', fullname($USER, true)), $CFG->wwwroot .'/');
         }
-        if ($USER->username == "guest") {
+        if ($USER->username == 'guest') {
             switch ($course->guest) {
                 case 0: // Guests not allowed
                     print_header();
-                    notice(get_string("guestsnotallowed", "", $course->fullname));
+                    notice(get_string('guestsnotallowed', '', $course->fullname));
                     break;
                 case 1: // Guests allowed
                     return;
@@ -442,7 +442,7 @@ function require_login($courseid=0, $autologinguest=true) {
 
         // Currently not enrolled in the course, so see if they want to enrol
         $SESSION->wantsurl = $FULLME;
-        redirect("$CFG->wwwroot/course/enrol.php?id=$courseid");
+        redirect($CFG->wwwroot .'/course/enrol.php?id='. $courseid);
         die;
     }
 }
@@ -468,11 +468,11 @@ function update_user_login_times() {
 
     $user->id = $USER->id;
 
-    return update_record("user", $user);
+    return update_record('user', $user);
 }
 
 function user_not_fully_set_up($user) {
-    return ($user->username != "guest" and (empty($user->firstname) or empty($user->lastname) or empty($user->email)));
+    return ($user->username != 'guest' and (empty($user->firstname) or empty($user->lastname) or empty($user->email)));
 }
 
 function update_login_count() {
@@ -490,7 +490,7 @@ function update_login_count() {
 
     if ($SESSION->logincount > $max_logins) {
         unset($SESSION->wantsurl);
-        error(get_string("errortoomanylogins"));
+        error(get_string('errortoomanylogins'));
     }
 }
 
@@ -501,7 +501,7 @@ function reset_login_count() {
     $SESSION->logincount = 0;
 }
 
-function check_for_restricted_user($username=NULL, $redirect="") {
+function check_for_restricted_user($username=NULL, $redirect='') {
     global $CFG, $USER;
 
     if (!$username) {
@@ -515,7 +515,7 @@ function check_for_restricted_user($username=NULL, $redirect="") {
     if (!empty($CFG->restrictusers)) {
         $names = explode(',', $CFG->restrictusers);
         if (in_array($username, $names)) {
-            error(get_string("restricteduser", "error", fullname($USER)), $redirect);
+            error(get_string('restricteduser', 'error', fullname($USER)), $redirect);
         }
     }
 }
@@ -537,7 +537,7 @@ function isadmin($userid=0) {
         return true;
     } else if (in_array($userid, $nonadmins)) {
         return false;
-    } else if (record_exists("user_admins", "userid", $userid)){
+    } else if (record_exists('user_admins', 'userid', $userid)){
         $admins[] = $userid;
         return true;
     } else {
@@ -565,10 +565,10 @@ function isteacher($courseid=0, $userid=0, $includeadmin=true) {
     }
 
     if (!$courseid) {
-        return record_exists("user_teachers","userid",$userid);
+        return record_exists('user_teachers', 'userid', $userid);
     }
 
-    return record_exists("user_teachers", "userid", $userid, "course", $courseid);
+    return record_exists('user_teachers', 'userid', $userid, 'course', $courseid);
 }
 
 function isteacheredit($courseid, $userid=0) {
@@ -583,7 +583,7 @@ function isteacheredit($courseid, $userid=0) {
         return !empty($USER->teacheredit[$courseid]);
     }
 
-    return get_field("user_teachers", "editall", "userid", $userid, "course", $courseid);
+    return get_field('user_teachers', 'editall', 'userid', $userid, 'course', $courseid);
 }
 
 function iscreator ($userid=0) {
@@ -596,10 +596,10 @@ function iscreator ($userid=0) {
         return true;
     }
     if (empty($userid)) {
-        return record_exists("user_coursecreators", "userid", $USER->id);
+        return record_exists('user_coursecreators', 'userid', $USER->id);
     }
 
-    return record_exists("user_coursecreators", "userid", $userid);
+    return record_exists('user_coursecreators', 'userid', $userid);
 }
 
 function isstudent($courseid, $userid=0) {
@@ -636,7 +636,7 @@ function isstudent($courseid, $userid=0) {
 
   //  $timenow = time();   // todo:  add time check below
 
-    return record_exists("user_students", "userid", $userid, "course", $courseid);
+    return record_exists('user_students', 'userid', $userid, 'course', $courseid);
 }
 
 function isguest($userid=0) {
@@ -647,10 +647,10 @@ function isguest($userid=0) {
         if (empty($USER->username)) {
             return false;
         }
-        return ($USER->username == "guest");
+        return ($USER->username == 'guest');
     }
 
-    return record_exists("user", "id", $userid, "username", "guest");
+    return record_exists('user', 'id', $userid, 'username', 'guest');
 }
 
 
@@ -695,10 +695,10 @@ function fullname($user, $override=false) {
     }
 
     if ($CFG->fullnamedisplay == 'firstname lastname') {
-        return "$user->firstname $user->lastname";
+        return $user->firstname .' '. $user->lastname;
 
     } else if ($CFG->fullnamedisplay == 'lastname firstname') {
-        return "$user->lastname $user->firstname";
+        return $user->lastname .' '. $user->firstname;
 
     } else if ($CFG->fullnamedisplay == 'firstname') {
         if ($override) {
@@ -721,8 +721,8 @@ function set_moodle_cookie($thing) {
     $days = 60;
     $seconds = 60*60*24*$days;
 
-    setCookie($cookiename, "", time() - 3600, "/");
-    setCookie($cookiename, rc4encrypt($thing), time()+$seconds, "/");
+    setCookie($cookiename, '', time() - 3600, '/');
+    setCookie($cookiename, rc4encrypt($thing), time()+$seconds, '/');
 }
 
 
@@ -733,7 +733,7 @@ function get_moodle_cookie() {
     $cookiename = 'MOODLEID_'.$CFG->sessioncookie;
 
     if (empty($_COOKIE[$cookiename])) {
-        return "";
+        return '';
     } else {
         return rc4decrypt($_COOKIE[$cookiename]);
     }
@@ -751,7 +751,7 @@ function is_internal_auth($auth='') {
         $method = $auth;
     }
 
-    return ($method == "email" || $method == "none" || $method == "manual");
+    return ($method == 'email' || $method == 'none' || $method == 'manual');
 }
 
 function create_user_record($username, $password, $auth='') {
@@ -783,8 +783,8 @@ function create_user_record($username, $password, $auth='') {
     $newuser->lastIP = getremoteaddr();
     $newuser->timemodified = time();
 
-    if (insert_record("user", $newuser)) {
-         $user = get_user_info_from_db("username", $newuser->username);
+    if (insert_record('user', $newuser)) {
+         $user = get_user_info_from_db('username', $newuser->username);
          if($CFG->{'auth_'.$newuser->auth.'_forcechangepassword'}){
              set_user_preference('auth_forcepasswordchange', 1, $user);
          }
@@ -809,13 +809,13 @@ function update_user_record($username) {
             }
         }
     }
-    return get_user_info_from_db("username", $username);
+    return get_user_info_from_db('username', $username);
 }
 
 function guest_user() {
     global $CFG;
 
-    if ($newuser = get_record("user", "username", "guest")) {
+    if ($newuser = get_record('user', 'username', 'guest')) {
         $newuser->loggedin = true;
         $newuser->confirmed = 1;
         $newuser->site = $CFG->wwwroot;
@@ -839,12 +839,12 @@ function authenticate_user_login($username, $password) {
 
     // First try to find the user in the database
 
-    $user = get_user_info_from_db("username", $username);
+    $user = get_user_info_from_db('username', $username);
 
     // Sort out the authentication method we are using.
 
     if (empty($CFG->auth)) {
-        $CFG->auth = "manual";     // Default authentication module
+        $CFG->auth = 'manual';     // Default authentication module
     }
 
     if (empty($user->auth)) {      // For some reason it isn't set yet
@@ -861,11 +861,11 @@ function authenticate_user_login($username, $password) {
         $auth = $user->auth;
     }
 
-    if (!file_exists("$CFG->dirroot/auth/$auth/lib.php")) {
-        $auth = "manual";    // Can't find auth module, default to internal
+    if (!file_exists($CFG->dirroot .'/auth/'. $auth .'/lib.php')) {
+        $auth = 'manual';    // Can't find auth module, default to internal
     }
 
-    require_once("$CFG->dirroot/auth/$auth/lib.php");
+    require_once($CFG->dirroot .'/auth/'. $auth .'/lib.php');
 
     if (auth_user_login($username, $password)) {  // Successful authentication
         if ($user) {                              // User already exists in database
@@ -885,16 +885,16 @@ function authenticate_user_login($username, $password) {
 
         if (function_exists('auth_iscreator')) {    // Check if the user is a creator
             if (auth_iscreator($username)) {
-                if (! record_exists("user_coursecreators", "userid", $user->id)) {
+                if (! record_exists('user_coursecreators', 'userid', $user->id)) {
                     $cdata->userid = $user->id;
-                    if (! insert_record("user_coursecreators", $cdata)) {
-                        error("Cannot add user to course creators.");
+                    if (! insert_record('user_coursecreators', $cdata)) {
+                        error('Cannot add user to course creators.');
                     }
                 }
             } else {
-                if ( record_exists("user_coursecreators", "userid", $user->id)) {
-                    if (! delete_records("user_coursecreators", "userid", $user->id)) {
-                        error("Cannot remove user from course creators.");
+                if ( record_exists('user_coursecreators', 'userid', $user->id)) {
+                    if (! delete_records('user_coursecreators', 'userid', $user->id)) {
+                        error('Cannot remove user from course creators.');
                     }
                 }
             }
@@ -902,9 +902,9 @@ function authenticate_user_login($username, $password) {
         return $user;
 
     } else {
-        add_to_log(0, "login", "error", $_SERVER['HTTP_REFERER'], $username);
+        add_to_log(0, 'login', 'error', $_SERVER['HTTP_REFERER'], $username);
         $date = date('Y-m-d H:i:s');
-        error_log("$date\tfailed login\t".getremoteaddr()."\t".$_SERVER['HTTP_USER_AGENT']."\t$username");
+        error_log($date ."\tfailed login\t". getremoteaddr() ."\t". $_SERVER['HTTP_USER_AGENT'] ."\t". $username);
         return false;
     }
 }
@@ -912,17 +912,17 @@ function authenticate_user_login($username, $password) {
 function enrol_student($userid, $courseid, $timestart=0, $timeend=0) {
 /// Enrols (or re-enrols) a student in a given course
 
-    if (!$course = get_record("course", "id", $courseid)) {  // Check course
+    if (!$course = get_record('course', 'id', $courseid)) {  // Check course
         return false;
     }
-    if (!$user = get_record("user", "id", $userid)) {        // Check user
+    if (!$user = get_record('user', 'id', $userid)) {        // Check user
         return false;
     }
-    if ($student = get_record("user_students", "userid", $userid, "course", $courseid)) {
+    if ($student = get_record('user_students', 'userid', $userid, 'course', $courseid)) {
         $student->timestart = $timestart;
         $student->timeend = $timeend;
         $student->time = time();
-        return update_record("user_students", $student);
+        return update_record('user_students', $student);
 
     } else {
         $student->userid = $userid;
@@ -930,7 +930,7 @@ function enrol_student($userid, $courseid, $timestart=0, $timeend=0) {
         $student->timestart = $timestart;
         $student->timeend = $timeend;
         $student->time = time();
-        return insert_record("user_students", $student);
+        return insert_record('user_students', $student);
     }
 }
 
@@ -939,26 +939,26 @@ function unenrol_student($userid, $courseid=0) {
 
     if ($courseid) {
         /// First delete any crucial stuff that might still send mail
-        if ($forums = get_records("forum", "course", $courseid)) {
+        if ($forums = get_records('forum', 'course', $courseid)) {
             foreach ($forums as $forum) {
-                delete_records("forum_subscriptions", "forum", $forum->id, "userid", $userid);
+                delete_records('forum_subscriptions', 'forum', $forum->id, 'userid', $userid);
             }
         }
         if ($groups = get_groups($courseid, $userid)) {
             foreach ($groups as $group) {
-                delete_records("groups_members", "groupid", $group->id, "userid", $userid);
+                delete_records('groups_members', 'groupid', $group->id, 'userid', $userid);
             }
         }
-        return delete_records("user_students", "userid", $userid, "course", $courseid);
+        return delete_records('user_students', 'userid', $userid, 'course', $courseid);
 
     } else {
-        delete_records("forum_subscriptions", "userid", $userid);
-        delete_records("groups_members", "userid", $userid);
-        return delete_records("user_students", "userid", $userid);
+        delete_records('forum_subscriptions', 'userid', $userid);
+        delete_records('groups_members', 'userid', $userid);
+        return delete_records('user_students', 'userid', $userid);
     }
 }
 
-function add_teacher($userid, $courseid, $editall=1, $role="", $timestart=0, $timeend=0) {
+function add_teacher($userid, $courseid, $editall=1, $role='', $timestart=0, $timeend=0) {
 /// Add a teacher to a given course
     global $CFG;
 
@@ -978,11 +978,11 @@ function add_teacher($userid, $courseid, $editall=1, $role="", $timestart=0, $ti
         return update_record('user_teachers', $newteacher);
     }
 
-    if (!record_exists("user", "id", $userid)) {
+    if (!record_exists('user', 'id', $userid)) {
         return false;   // no such user
     }
 
-    if (!record_exists("course", "id", $courseid)) {
+    if (!record_exists('course', 'id', $courseid)) {
         return false;   // no such course
     }
 
@@ -994,24 +994,24 @@ function add_teacher($userid, $courseid, $editall=1, $role="", $timestart=0, $ti
     $teacher->timemodified = time();
     $newteacher->timestart = $timestart;
     $newteacher->timeend = $timeend;
-    if ($student = get_record("user_students", "userid", $userid, "course", $courseid)) {
+    if ($student = get_record('user_students', 'userid', $userid, 'course', $courseid)) {
         $teacher->timestart = $student->timestart;
         $teacher->timeend = $student->timeend;
         $teacher->timeaccess = $student->timeaccess;
     }
 
-    if (record_exists("user_teachers", "course", $courseid)) {
+    if (record_exists('user_teachers', 'course', $courseid)) {
         $teacher->authority = 2;
     } else {
         $teacher->authority = 1;
     }
-    delete_records("user_students", "userid", $userid, "course", $courseid); // Unenrol as student
+    delete_records('user_students', 'userid', $userid, 'course', $courseid); // Unenrol as student
 
     /// Add forum subscriptions for new users
     require_once('../mod/forum/lib.php');
     forum_add_user($userid, $courseid);
 
-    return insert_record("user_teachers", $teacher);
+    return insert_record('user_teachers', $teacher);
 
 }
 
@@ -1020,9 +1020,9 @@ function remove_teacher($userid, $courseid=0) {
 /// Does not delete the user account
     if ($courseid) {
         /// First delete any crucial stuff that might still send mail
-        if ($forums = get_records("forum", "course", $courseid)) {
+        if ($forums = get_records('forum', 'course', $courseid)) {
             foreach ($forums as $forum) {
-                delete_records("forum_subscriptions", "forum", $forum->id, "userid", $userid);
+                delete_records('forum_subscriptions', 'forum', $forum->id, 'userid', $userid);
             }
         }
 
@@ -1031,15 +1031,15 @@ function remove_teacher($userid, $courseid=0) {
         if (!isstudent($courseid, $userid)) {
             if ($groups = get_groups($courseid, $userid)) {
                 foreach ($groups as $group) {
-                    delete_records("groups_members", "groupid", $group->id, "userid", $userid);
+                    delete_records('groups_members', 'groupid', $group->id, 'userid', $userid);
                 }
             }
         }
 
-        return delete_records("user_teachers", "userid", $userid, "course", $courseid);
+        return delete_records('user_teachers', 'userid', $userid, 'course', $courseid);
     } else {
-        delete_records("forum_subscriptions", "userid", $userid);
-        return delete_records("user_teachers", "userid", $userid);
+        delete_records('forum_subscriptions', 'userid', $userid);
+        return delete_records('user_teachers', 'userid', $userid);
     }
 }
 
@@ -1047,10 +1047,10 @@ function remove_teacher($userid, $courseid=0) {
 function add_creator($userid) {
 /// Add a creator to the site
 
-    if (!record_exists("user_admins", "userid", $userid)) {
-        if (record_exists("user", "id", $userid)) {
+    if (!record_exists('user_admins', 'userid', $userid)) {
+        if (record_exists('user', 'id', $userid)) {
             $creator->userid = $userid;
-            return insert_record("user_coursecreators", $creator);
+            return insert_record('user_coursecreators', $creator);
         }
         return false;
     }
@@ -1061,14 +1061,14 @@ function remove_creator($userid) {
 /// Removes a creator from a site
     global $db;
 
-    return delete_records("user_coursecreators", "userid", $userid);
+    return delete_records('user_coursecreators', 'userid', $userid);
 }
 
 function add_admin($userid) {
 /// Add an admin to the site
 
-    if (!record_exists("user_admins", "userid", $userid)) {
-        if (record_exists("user", "id", $userid)) {
+    if (!record_exists('user_admins', 'userid', $userid)) {
+        if (record_exists('user', 'id', $userid)) {
             $admin->userid = $userid;
 
             // any admin is also a teacher on the site course
@@ -1078,7 +1078,7 @@ function add_admin($userid) {
                 }
             }
 
-            return insert_record("user_admins", $admin);
+            return insert_record('user_admins', $admin);
         }
         return false;
     }
@@ -1092,7 +1092,7 @@ function remove_admin($userid) {
     // remove also from the list of site teachers
     remove_teacher($userid, SITEID);
 
-    return delete_records("user_admins", "userid", $userid);
+    return delete_records('user_admins', 'userid', $userid);
 }
 
 
@@ -1104,36 +1104,36 @@ function remove_course_contents($courseid, $showfeedback=true) {
 
     $result = true;
 
-    if (! $course = get_record("course", "id", $courseid)) {
-        error("Course ID was incorrect (can't find it)");
+    if (! $course = get_record('course', 'id', $courseid)) {
+        error('Course ID was incorrect (can\'t find it)');
     }
 
-    $strdeleted = get_string("deleted");
+    $strdeleted = get_string('deleted');
 
     // First delete every instance of every module
 
-    if ($allmods = get_records("modules") ) {
+    if ($allmods = get_records('modules') ) {
         foreach ($allmods as $mod) {
             $modname = $mod->name;
-            $modfile = "$CFG->dirroot/mod/$modname/lib.php";
-            $moddelete = $modname."_delete_instance";       // Delete everything connected to an instance
-            $moddeletecourse = $modname."_delete_course";   // Delete other stray stuff (uncommon)
+            $modfile = $CFG->dirroot .'/mod/'. $modname .'/lib.php';
+            $moddelete = $modname .'_delete_instance';       // Delete everything connected to an instance
+            $moddeletecourse = $modname .'_delete_course';   // Delete other stray stuff (uncommon)
             $count=0;
             if (file_exists($modfile)) {
                 include_once($modfile);
                 if (function_exists($moddelete)) {
-                    if ($instances = get_records($modname, "course", $course->id)) {
+                    if ($instances = get_records($modname, 'course', $course->id)) {
                         foreach ($instances as $instance) {
                             if ($moddelete($instance->id)) {
                                 $count++;
                             } else {
-                                notify("Could not delete $modname instance $instance->id ($instance->name)");
+                                notify('Could not delete '. $modname .' instance '. $instance->id .' ('. $instance->name .')');
                                 $result = false;
                             }
                         }
                     }
                 } else {
-                    notify("Function $moddelete() doesn't exist!");
+                    notify('Function '. $moddelete() .'doesn\'t exist!');
                     $result = false;
                 }
 
@@ -1142,26 +1142,26 @@ function remove_course_contents($courseid, $showfeedback=true) {
                 }
             }
             if ($showfeedback) {
-                notify("$strdeleted $count x $modname");
+                notify($strdeleted .' '. $count .' x '. $modname);
             }
         }
     } else {
-        error("No modules are installed!");
+        error('No modules are installed!');
     }
 
     // Delete any user stuff
 
-    if (delete_records("user_students", "course", $course->id)) {
+    if (delete_records('user_students', 'course', $course->id)) {
         if ($showfeedback) {
-            notify("$strdeleted user_students");
+            notify($strdeleted .' user_students');
         }
     } else {
         $result = false;
     }
 
-    if (delete_records("user_teachers", "course", $course->id)) {
+    if (delete_records('user_teachers', 'course', $course->id)) {
         if ($showfeedback) {
-            notify("$strdeleted user_teachers");
+            notify($strdeleted .' user_teachers');
         }
     } else {
         $result = false;
@@ -1169,18 +1169,18 @@ function remove_course_contents($courseid, $showfeedback=true) {
 
     // Delete any groups
 
-    if ($groups = get_records("groups", "courseid", $course->id)) {
+    if ($groups = get_records('groups', 'courseid', $course->id)) {
         foreach ($groups as $group) {
-            if (delete_records("groups_members", "groupid", $group->id)) {
+            if (delete_records('groups_members', 'groupid', $group->id)) {
                 if ($showfeedback) {
-                    notify("$strdeleted groups_members");
+                    notify($strdeleted .' groups_members');
                 }
             } else {
                 $result = false;
             }
-            if (delete_records("groups", "id", $group->id)) {
+            if (delete_records('groups', 'id', $group->id)) {
                 if ($showfeedback) {
-                    notify("$strdeleted groups");
+                    notify($strdeleted .' groups');
                 }
             } else {
                 $result = false;
@@ -1190,9 +1190,9 @@ function remove_course_contents($courseid, $showfeedback=true) {
 
     // Delete events
 
-    if (delete_records("event", "courseid", $course->id)) {
+    if (delete_records('event', 'courseid', $course->id)) {
         if ($showfeedback) {
-            notify("$strdeleted event");
+            notify($strdeleted .' event');
         }
     } else {
         $result = false;
@@ -1200,9 +1200,9 @@ function remove_course_contents($courseid, $showfeedback=true) {
 
     // Delete logs
 
-    if (delete_records("log", "course", $course->id)) {
+    if (delete_records('log', 'course', $course->id)) {
         if ($showfeedback) {
-            notify("$strdeleted log");
+            notify($strdeleted .' log');
         }
     } else {
         $result = false;
@@ -1210,17 +1210,17 @@ function remove_course_contents($courseid, $showfeedback=true) {
 
     // Delete any course stuff
 
-    if (delete_records("course_sections", "course", $course->id)) {
+    if (delete_records('course_sections', 'course', $course->id)) {
         if ($showfeedback) {
-            notify("$strdeleted course_sections");
+            notify($strdeleted .' course_sections');
         }
     } else {
         $result = false;
     }
 
-    if (delete_records("course_modules", "course", $course->id)) {
+    if (delete_records('course_modules', 'course', $course->id)) {
         if ($showfeedback) {
-            notify("$strdeleted course_modules");
+            notify($strdeleted .' course_modules');
         }
     } else {
         $result = false;
@@ -1241,19 +1241,19 @@ function remove_course_userdata($courseid, $showfeedback=true,
 
     $result = true;
 
-    if (! $course = get_record("course", "id", $courseid)) {
-        error("Course ID was incorrect (can't find it)");
+    if (! $course = get_record('course', 'id', $courseid)) {
+        error('Course ID was incorrect (can\'t find it)');
     }
 
-    $strdeleted = get_string("deleted");
+    $strdeleted = get_string('deleted');
 
     // Look in every instance of every module for data to delete
 
-    if ($allmods = get_records("modules") ) {
+    if ($allmods = get_records('modules') ) {
         foreach ($allmods as $mod) {
             $modname = $mod->name;
-            $modfile = "$CFG->dirroot/mod/$modname/lib.php";
-            $moddeleteuserdata = $modname."_delete_userdata";   // Function to delete user data
+            $modfile = $CFG->dirroot .'/mod/'. $modname .'/lib.php';
+            $moddeleteuserdata = $modname .'_delete_userdata';   // Function to delete user data
             $count=0;
             if (file_exists($modfile)) {
                 @include_once($modfile);
@@ -1263,26 +1263,26 @@ function remove_course_userdata($courseid, $showfeedback=true,
             }
         }
     } else {
-        error("No modules are installed!");
+        error('No modules are installed!');
     }
 
     // Delete other stuff
 
     if ($removestudents) {
         /// Delete student enrolments
-        if (delete_records("user_students", "course", $course->id)) {
+        if (delete_records('user_students', 'course', $course->id)) {
             if ($showfeedback) {
-                notify("$strdeleted user_students");
+                notify($strdeleted .' user_students');
             }
         } else {
             $result = false;
         }
         /// Delete group members (but keep the groups)
-        if ($groups = get_records("groups", "courseid", $course->id)) {
+        if ($groups = get_records('groups', 'courseid', $course->id)) {
             foreach ($groups as $group) {
-                if (delete_records("groups_members", "groupid", $group->id)) {
+                if (delete_records('groups_members', 'groupid', $group->id)) {
                     if ($showfeedback) {
-                        notify("$strdeleted groups_members");
+                        notify($strdeleted .' groups_members');
                     }
                 } else {
                     $result = false;
@@ -1292,9 +1292,9 @@ function remove_course_userdata($courseid, $showfeedback=true,
     }
 
     if ($removeteachers) {
-        if (delete_records("user_teachers", "course", $course->id)) {
+        if (delete_records('user_teachers', 'course', $course->id)) {
             if ($showfeedback) {
-                notify("$strdeleted user_teachers");
+                notify($strdeleted .' user_teachers');
             }
         } else {
             $result = false;
@@ -1302,11 +1302,11 @@ function remove_course_userdata($courseid, $showfeedback=true,
     }
 
     if ($removegroups) {
-        if ($groups = get_records("groups", "courseid", $course->id)) {
+        if ($groups = get_records('groups', 'courseid', $course->id)) {
             foreach ($groups as $group) {
-                if (delete_records("groups", "id", $group->id)) {
+                if (delete_records('groups', 'id', $group->id)) {
                     if ($showfeedback) {
-                        notify("$strdeleted groups");
+                        notify($strdeleted .' groups');
                     }
                 } else {
                     $result = false;
@@ -1316,9 +1316,9 @@ function remove_course_userdata($courseid, $showfeedback=true,
     }
 
     if ($removeevents) {
-        if (delete_records("event", "courseid", $course->id)) {
+        if (delete_records('event', 'courseid', $course->id)) {
             if ($showfeedback) {
-                notify("$strdeleted event");
+                notify($strdeleted .' event');
             }
         } else {
             $result = false;
@@ -1326,9 +1326,9 @@ function remove_course_userdata($courseid, $showfeedback=true,
     }
 
     if ($removelogs) {
-        if (delete_records("log", "course", $course->id)) {
+        if (delete_records('log', 'course', $course->id)) {
             if ($showfeedback) {
-                notify("$strdeleted log");
+                notify($strdeleted .' log');
             }
         } else {
             $result = false;
@@ -1368,7 +1368,7 @@ function ismember($groupid, $userid=0) {
         return false;
     }
 
-    return record_exists("groups_members", "groupid", $groupid, "userid", $userid);
+    return record_exists('groups_members', 'groupid', $groupid, 'userid', $userid);
 }
 
 /**
@@ -1511,7 +1511,7 @@ function setup_and_print_groups($course, $groupmode, $urlroot) {
     }
 
     if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) {
-        if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
+        if ($groups = get_records_menu('groups', 'courseid', $course->id, 'name ASC', 'id,name')) {
             echo '<div align="center">';
             print_group_menu($groups, $groupmode, $currentgroup, $urlroot);
             echo '</div>';
@@ -1525,7 +1525,7 @@ function setup_and_print_groups($course, $groupmode, $urlroot) {
 
 /// CORRESPONDENCE  ////////////////////////////////////////////////
 
-function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $attachment="", $attachname="", $usetrueaddress=true) {
+function email_to_user($user, $from, $subject, $messagetext, $messagehtml='', $attachment='', $attachname='', $usetrueaddress=true) {
 ///  user        - a user record as an object
 ///  from        - a user record as an object
 ///  subject     - plain text subject line of the email
@@ -1546,7 +1546,7 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a
         $CFG->courselang = $course->lang;
     }
 
-    include_once("$CFG->libdir/phpmailer/class.phpmailer.php");
+    include_once($CFG->libdir .'/phpmailer/class.phpmailer.php');
 
     if (empty($user)) {
         return false;
@@ -1558,15 +1558,15 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a
 
     $mail = new phpmailer;
 
-    $mail->Version = "Moodle $CFG->version";           // mailer version
-    $mail->PluginDir = "$CFG->libdir/phpmailer/";      // plugin directory (eg smtp plugin)
+    $mail->Version = 'Moodle '. $CFG->version;           // mailer version
+    $mail->PluginDir = $CFG->libdir .'/phpmailer/';      // plugin directory (eg smtp plugin)
 
 
-    if (current_language() != "en") {
-        $mail->CharSet = get_string("thischarset");
+    if (current_language() != 'en') {
+        $mail->CharSet = get_string('thischarset');
     }
 
-    if ($CFG->smtphosts == "qmail") {
+    if ($CFG->smtphosts == 'qmail') {
         $mail->IsQmail();                              // use Qmail system
 
     } else if (empty($CFG->smtphosts)) {
@@ -1575,10 +1575,10 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a
     } else {
         $mail->IsSMTP();                               // use SMTP directly
         if ($CFG->debug > 7) {
-            echo "<pre>\n";
+            echo '<pre>' . "\n";
             $mail->SMTPDebug = true;
         }
-        $mail->Host = "$CFG->smtphosts";               // specify main and backup servers
+        $mail->Host = $CFG->smtphosts;               // specify main and backup servers
 
         if ($CFG->smtpuser) {                          // Use SMTP authentication
             $mail->SMTPAuth = true;
@@ -1589,21 +1589,21 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a
 
     $adminuser = get_admin();
 
-    $mail->Sender   = "$adminuser->email";
+    $mail->Sender   = $adminuser->email;
 
     if (is_string($from)) { // So we can pass whatever we want if there is need
         $mail->From     = $CFG->noreplyaddress;
         $mail->FromName = $from;
     } else if ($usetrueaddress and $from->maildisplay) {
-        $mail->From     = "$from->email";
+        $mail->From     = $from->email;
         $mail->FromName = fullname($from);
     } else {
-        $mail->From     = "$CFG->noreplyaddress";
+        $mail->From     = $CFG->noreplyaddress;
         $mail->FromName = fullname($from);
     }
     $mail->Subject  =  stripslashes($subject);
 
-    $mail->AddAddress("$user->email", fullname($user) );
+    $mail->AddAddress($user->email, fullname($user) );
 
     $mail->WordWrap = 79;                               // set word wrap
 
@@ -1619,7 +1619,7 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a
 
     if ($messagehtml) {
         $mail->IsHTML(true);
-        $mail->Encoding = "quoted-printable";           // Encoding to use
+        $mail->Encoding = 'quoted-printable';           // Encoding to use
         $mail->Body    =  $messagehtml;
         $mail->AltBody =  "\n$messagetext\n";
     } else {
@@ -1629,20 +1629,20 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a
 
     if ($attachment && $attachname) {
         if (ereg( "\\.\\." ,$attachment )) {    // Security check for ".." in dir path
-            $mail->AddAddress("$adminuser->email", fullname($adminuser) );
-            $mail->AddStringAttachment("Error in attachment.  User attempted to attach a filename with a unsafe name.", "error.txt", "8bit", "text/plain");
+            $mail->AddAddress($adminuser->email, fullname($adminuser) );
+            $mail->AddStringAttachment('Error in attachment.  User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
         } else {
-            include_once("$CFG->dirroot/files/mimetypes.php");
-            $mimetype = mimeinfo("type", $attachname);
-            $mail->AddAttachment("$CFG->dataroot/$attachment", "$attachname", "base64", "$mimetype");
+            include_once($CFG->dirroot .'/files/mimetypes.php');
+            $mimetype = mimeinfo('type', $attachname);
+            $mail->AddAttachment($CFG->dataroot .'/'. $attachment, $attachname, 'base64', $mimetype);
         }
     }
 
     if ($mail->Send()) {
         return true;
     } else {
-        mtrace("ERROR: $mail->ErrorInfo");
-        add_to_log(SITEID, "library", "mailer", $_SERVER["REQUEST_URI"], "ERROR: $mail->ErrorInfo");
+        mtrace('ERROR: '. $mail->ErrorInfo);
+        add_to_log(SITEID, 'library', 'mailer', $_SERVER['REQUEST_URI'], 'ERROR: '. $mail->ErrorInfo);
         return false;
     }
 }
@@ -1656,20 +1656,20 @@ function reset_password_and_mail($user) {
 
     $newpassword = generate_password();
 
-    if (! set_field("user", "password", md5($newpassword), "id", $user->id) ) {
-        error("Could not set user password!");
+    if (! set_field('user', 'password', md5($newpassword), 'id', $user->id) ) {
+        error('Could not set user password!');
     }
 
     $a->firstname = $user->firstname;
     $a->sitename = $site->fullname;
     $a->username = $user->username;
     $a->newpassword = $newpassword;
-    $a->link = "$CFG->wwwroot/login/change_password.php";
-    $a->signoff = fullname($from, true)." ($from->email)";
+    $a->link = $CFG->wwwroot .'/login/change_password.php';
+    $a->signoff = fullname($from, true).' ('. $from->email .')';
 
-    $message = get_string("newpasswordtext", "", $a);
+    $message = get_string('newpasswordtext', '', $a);
 
-    $subject  = "$site->fullname: ".get_string("changedpassword");
+    $subject  = $site->fullname .': '. get_string('changedpassword');
 
     return email_to_user($user, $from, $subject, $message);
 
@@ -1684,11 +1684,11 @@ function send_confirmation_email($user) {
 
     $data->firstname = $user->firstname;
     $data->sitename = $site->fullname;
-    $data->link = "$CFG->wwwroot/login/confirm.php?p=$user->secret&amp;s=$user->username";
-    $data->admin = fullname($from)." ($from->email)";
+    $data->link = $CFG->wwwroot .'/login/confirm.php?p='. $user->secret .'&amp;s='. $user->username;
+    $data->admin = fullname($from) .' ('. $from->email .')';
 
-    $message = get_string("emailconfirmation", "", $data);
-    $subject = get_string("emailconfirmationsubject", "", $site->fullname);
+    $message = get_string('emailconfirmation', '', $data);
+    $subject = get_string('emailconfirmationsubject', '', $site->fullname);
 
     $messagehtml = text_to_html($message, false, false, true);
 
@@ -1705,11 +1705,11 @@ function send_password_change_confirmation_email($user) {
 
     $data->firstname = $user->firstname;
     $data->sitename = $site->fullname;
-    $data->link = "$CFG->wwwroot/login/forgot_password.php?p=$user->secret&amp;s=$user->username";
-    $data->admin = fullname($from)." ($from->email)";
+    $data->link = $CFG->wwwroot .'/login/forgot_password.php?p='. $user->secret .'&amp;s='. $user->username;
+    $data->admin = fullname($from).' ('. $from->email .')';
 
-    $message = get_string("emailpasswordconfirmation", "", $data);
-    $subject = get_string("emailpasswordconfirmationsubject", "", $site->fullname);
+    $message = get_string('emailpasswordconfirmation', '', $data);
+    $subject = get_string('emailpasswordconfirmationsubject', '', $site->fullname);
 
     return email_to_user($user, $from, $subject, $message);
 
@@ -1733,7 +1733,7 @@ function email_is_not_allowed($email) {
                 return false;
             }
         }
-        return get_string("emailonlyallowed", '', $CFG->allowemailaddresses);
+        return get_string('emailonlyallowed', '', $CFG->allowemailaddresses);
 
     } else if (!empty($CFG->denyemailaddresses)) {
         $denied = explode(' ', $CFG->denyemailaddresses);
@@ -1743,7 +1743,7 @@ function email_is_not_allowed($email) {
                 continue;
             }
             if (strpos($email, $deniedpattern) !== false) {   // Match!
-                return get_string("emailnotallowed", '', $CFG->denyemailaddresses);
+                return get_string('emailnotallowed', '', $CFG->denyemailaddresses);
             }
         }
     }
@@ -1769,20 +1769,20 @@ function make_upload_directory($directory, $shownotices=true) {
     if (!file_exists($currdir)) {
         if (! mkdir($currdir, $CFG->directorypermissions)) {
             if ($shownotices) {
-                notify("ERROR: You need to create the directory $currdir with web server write access");
+                notify('ERROR: You need to create the directory '. $currdir .' with web server write access');
             }
             return false;
         }
     }
 
-    $dirarray = explode("/", $directory);
+    $dirarray = explode('/', $directory);
 
     foreach ($dirarray as $dir) {
-        $currdir = "$currdir/$dir";
+        $currdir = $currdir .'/'. $dir;
         if (! file_exists($currdir)) {
             if (! mkdir($currdir, $CFG->directorypermissions)) {
                 if ($shownotices) {
-                    notify("ERROR: Could not find or create a directory ($currdir)");
+                    notify('ERROR: Could not find or create a directory ('. $currdir .')');
                 }
                 return false;
             }
@@ -1798,16 +1798,16 @@ function make_mod_upload_directory($courseid) {
 /// Makes an upload directory for a particular module
     global $CFG;
 
-    if (! $moddata = make_upload_directory("$courseid/$CFG->moddata")) {
+    if (! $moddata = make_upload_directory($courseid .'/'. $CFG->moddata)) {
         return false;
     }
 
-    $strreadme = get_string("readme");
+    $strreadme = get_string('readme');
 
-    if (file_exists("$CFG->dirroot/lang/$CFG->lang/docs/module_files.txt")) {
-        copy("$CFG->dirroot/lang/$CFG->lang/docs/module_files.txt", "$moddata/$strreadme.txt");
+    if (file_exists($CFG->dirroot .'/lang/'. $CFG->lang .'/docs/module_files.txt')) {
+        copy($CFG->dirroot .'/lang/'. $CFG->lang .'/docs/module_files.txt', $moddata .'/'. $strreadme .'.txt');
     } else {
-        copy("$CFG->dirroot/lang/en/docs/module_files.txt", "$moddata/$strreadme.txt");
+        copy($CFG->dirroot .'/lang/en/docs/module_files.txt', $moddata .'/'. $strreadme .'.txt');
     }
     return $moddata;
 }
@@ -1816,12 +1816,12 @@ function make_mod_upload_directory($courseid) {
 function valid_uploaded_file($newfile) {
 /// Returns current name of file on disk if true
     if (empty($newfile)) {
-        return "";
+        return '';
     }
     if (is_uploaded_file($newfile['tmp_name']) and $newfile['size'] > 0) {
         return $newfile['tmp_name'];
     } else {
-        return "";
+        return '';
     }
 }
 
@@ -1841,12 +1841,12 @@ function get_max_upload_file_size($sitebytes=0, $coursebytes=0, $modulebytes=0)
 /// Anything defined as 0 is ignored.
 /// The smallest of all the non-zero numbers is returned.
 
-    if (! $filesize = ini_get("upload_max_filesize")) {
-        $filesize = "5M";
+    if (! $filesize = ini_get('upload_max_filesize')) {
+        $filesize = '5M';
     }
     $minimumsize = get_real_size($filesize);
 
-    if ($postsize = ini_get("post_max_size")) {
+    if ($postsize = ini_get('post_max_size')) {
         $postsize = get_real_size($postsize);
         if ($postsize < $minimumsize) {
             $minimumsize = $postsize;
@@ -1950,10 +1950,7 @@ function print_file_upload_error($filearray = '', $returnerror = false) {
 }
 
 
-
-
-
-function get_directory_list($rootdir, $excludefile="", $descend=true, $getdirs=false, $getfiles=true) {
+function get_directory_list($rootdir, $excludefile='', $descend=true, $getdirs=false, $getfiles=true) {
 /// Returns an array with all the filenames in
 /// all subdirectories, relative to the given rootdir.
 /// If excludefile is defined, then that file/directory is ignored
@@ -1977,18 +1974,18 @@ function get_directory_list($rootdir, $excludefile="", $descend=true, $getdirs=f
 
     while (false !== ($file = readdir($dir))) {
         $firstchar = substr($file, 0, 1);
-        if ($firstchar == "." or $file == "CVS" or $file == $excludefile) {
+        if ($firstchar == '.' or $file == 'CVS' or $file == $excludefile) {
             continue;
         }
-        $fullfile = "$rootdir/$file";
-        if (filetype($fullfile) == "dir") {
+        $fullfile = $rootdir .'/'. $file;
+        if (filetype($fullfile) == 'dir') {
             if ($getdirs) {
                 $dirs[] = $file;
             }
             if ($descend) {
                 $subdirs = get_directory_list($fullfile, $excludefile, $descend, $getdirs, $getfiles);
                 foreach ($subdirs as $subdir) {
-                    $dirs[] = "$file/$subdir";
+                    $dirs[] = $file .'/'. $subdir;
                 }
             }
         } else if ($getfiles) {
@@ -2002,7 +1999,7 @@ function get_directory_list($rootdir, $excludefile="", $descend=true, $getdirs=f
     return $dirs;
 }
 
-function get_directory_size($rootdir, $excludefile="") {
+function get_directory_size($rootdir, $excludefile='') {
 /// Adds up all the files in a directory and works out the size
 
     $size = 0;
@@ -2017,11 +2014,11 @@ function get_directory_size($rootdir, $excludefile="") {
 
     while (false !== ($file = readdir($dir))) {
         $firstchar = substr($file, 0, 1);
-        if ($firstchar == "." or $file == "CVS" or $file == $excludefile) {
+        if ($firstchar == '.' or $file == 'CVS' or $file == $excludefile) {
             continue;
         }
-        $fullfile = "$rootdir/$file";
-        if (filetype($fullfile) == "dir") {
+        $fullfile = $rootdir .'/'. $file;
+        if (filetype($fullfile) == 'dir') {
             $size += get_directory_size($fullfile, $excludefile);
         } else {
             $size += filesize($fullfile);
@@ -2074,7 +2071,7 @@ function display_size($size) {
     } else if ($size >= 1024) {
         $size = round($size / 1024 * 10) / 10 . $kb;
     } else {
-        $size = $size ." $b";
+        $size = $size .' '. $b;
     }
     return $size;
 }
@@ -2084,9 +2081,9 @@ function clean_filename($string) {
 /// Only these are allowed:
 ///    alphanumeric _ - .
 
-    $string = eregi_replace("\.\.+", "", $string);
+    $string = eregi_replace("\.\.+", '', $string);
     $string = preg_replace('/[^\.a-zA-Z\d\_-]/','_', $string ); // only allowed chars
-    $string = eregi_replace("_+", "_", $string);
+    $string = eregi_replace("_+", '_', $string);
     return    $string;
 }
 
@@ -2111,12 +2108,12 @@ function current_language() {
     }
 }
 
-function print_string($identifier, $module="", $a=NULL) {
+function print_string($identifier, $module='', $a=NULL) {
 /// Given a string to translate - prints it out.
     echo get_string($identifier, $module, $a);
 }
 
-function get_string($identifier, $module="", $a=NULL) {
+function get_string($identifier, $module='', $a=NULL) {
 /// Return the translated string specified by $identifier as
 /// for $module.  Uses the same format files as STphp.
 /// $a is an object, string or number that can be used
@@ -2136,12 +2133,12 @@ function get_string($identifier, $module="", $a=NULL) {
 
     $lang = current_language();
 
-    if ($module == "") {
-        $module = "moodle";
+    if ($module == '') {
+        $module = 'moodle';
     }
 
-    $langpath = "$CFG->dirroot/lang";
-    $langfile = "$langpath/$lang/$module.php";
+    $langpath = $CFG->dirroot .'/lang';
+    $langfile = $langpath .'/'. $lang .'/'. $module .'.php'.;
 
     // Look for the string - if found then return it
 
@@ -2154,9 +2151,9 @@ function get_string($identifier, $module="", $a=NULL) {
 
     // If it's a module, then look within the module pack itself mod/xxxx/lang/en/module.php
 
-    if ($module != "moodle") {
-        $modlangpath = "$CFG->dirroot/mod/$module/lang";
-        $langfile = "$modlangpath/$lang/$module.php";
+    if ($module != 'moodle') {
+        $modlangpath = $CFG->dirroot .'/mod/'. $module .'/lang';
+        $langfile = $modlangpath .'/'. $lang .'/'. $module .'.php';
         if (file_exists($langfile)) {
             if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
                 eval($result);
@@ -2166,16 +2163,16 @@ function get_string($identifier, $module="", $a=NULL) {
     }
 
     // If the preferred language was English we can abort now
-    if ($lang == "en") {
-        return "[[$identifier]]";
+    if ($lang == 'en') {
+        return '[['. $identifier .']]';
     }
 
     // Is a parent language defined?  If so, try it.
 
-    if ($result = get_string_from_file("parentlanguage", "$langpath/$lang/moodle.php", "\$parentlang")) {
+    if ($result = get_string_from_file('parentlanguage', $langpath .'/'. $lang .'/moodle.php', "\$parentlang")) {
         eval($result);
         if (!empty($parentlang)) {
-            $langfile = "$langpath/$parentlang/$module.php";
+            $langfile = $langpath .'/'. $parentlang .'/'. $module .'.php';
             if (file_exists($langfile)) {
                 if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
                     eval($result);
@@ -2187,9 +2184,9 @@ function get_string($identifier, $module="", $a=NULL) {
 
     // Our only remaining option is to try English
 
-    $langfile = "$langpath/en/$module.php";
+    $langfile = $langpath .'/en/'. $module .'.php';
     if (!file_exists($langfile)) {
-        return "ERROR: No lang file ($langpath/en/$module.php)!";
+        return 'ERROR: No lang file ('. $langpath .'/en/'. $module .'.php)!';
     }
     if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
         eval($result);
@@ -2198,8 +2195,8 @@ function get_string($identifier, $module="", $a=NULL) {
 
     // If it's a module, then look within the module pack itself mod/xxxx/lang/en/module.php
 
-    if ($module != "moodle") {
-        $langfile = "$modlangpath/en/$module.php";
+    if ($module != 'moodle') {
+        $langfile = $modlangpath .'/en/'. $module .'.php';
         if (file_exists($langfile)) {
             if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
                 eval($result);
@@ -2208,7 +2205,7 @@ function get_string($identifier, $module="", $a=NULL) {
         }
     }
 
-    return "[[$identifier]]";  // Last resort
+    return '[['. $identifier .']]';  // Last resort
 }
 
 
@@ -2229,7 +2226,7 @@ function get_string_from_file($identifier, $langfile, $destination) {
         return false;
     }
 
-    return "$destination = sprintf(\"".$string[$identifier]."\");";
+    return $destination .'= sprintf("'. $string[$identifier] .'");';
 }
 
 function get_strings($array, $module='') {
@@ -2251,19 +2248,19 @@ function get_list_of_languages() {
     if (!empty($CFG->langlist)) {       // use admin's list of languages
         $langlist = explode(',', $CFG->langlist);
         foreach ($langlist as $lang) {
-            if (file_exists("$CFG->dirroot/lang/$lang/moodle.php")) {
-                include("$CFG->dirroot/lang/$lang/moodle.php");
-                $languages[$lang] = $string["thislanguage"]." ($lang)";
+            if (file_exists($CFG->dirroot .'/lang/'. $lang .'/moodle.php')) {
+                include($CFG->dirroot .'/lang/'. $lang .'/moodle.php');
+                $languages[$lang] = $string['thislanguage'].' ('. $lang .')';
                 unset($string);
             }
         }
     } else {
-        if (!$langdirs = get_list_of_plugins("lang")) {
+        if (!$langdirs = get_list_of_plugins('lang')) {
             return false;
         }
         foreach ($langdirs as $lang) {
-            include("$CFG->dirroot/lang/$lang/moodle.php");
-            $languages[$lang] = $string["thislanguage"]." ($lang)";
+            include($CFG->dirroot .'/lang/'. $lang .'/moodle.php');
+            $languages[$lang] = $string['thislanguage'] .' ('. $lang .')';
             unset($string);
         }
     }
@@ -2277,19 +2274,19 @@ function get_list_of_countries() {
 
     $lang = current_language();
 
-    if (!file_exists("$CFG->dirroot/lang/$lang/countries.php")) {
-        if ($parentlang = get_string("parentlanguage")) {
-            if (file_exists("$CFG->dirroot/lang/$parentlang/countries.php")) {
+    if (!file_exists($CFG->dirroot .'/lang/'. $lang .'/countries.php')) {
+        if ($parentlang = get_string('parentlanguage')) {
+            if (file_exists($CFG->dirroot .'/lang/'. $parentlang .'/countries.php')) {
                 $lang = $parentlang;
             } else {
-                $lang = "en";  // countries.php must exist in this pack
+                $lang = 'en';  // countries.php must exist in this pack
             }
         } else {
-            $lang = "en";  // countries.php must exist in this pack
+            $lang = 'en';  // countries.php must exist in this pack
         }
     }
 
-    include("$CFG->dirroot/lang/$lang/countries.php");
+    include($CFG->dirroot .'/lang/'. $lang .'/countries.php');
 
     if (!empty($string)) {
         asort($string);
@@ -2304,19 +2301,19 @@ function get_list_of_pixnames() {
 
     $lang = current_language();
 
-    if (!file_exists("$CFG->dirroot/lang/$lang/pix.php")) {
-        if ($parentlang = get_string("parentlanguage")) {
-            if (file_exists("$CFG->dirroot/lang/$parentlang/pix.php")) {
+    if (!file_exists($CFG->dirroot .'/lang/'. $lang .'/pix.php')) {
+        if ($parentlang = get_string('parentlanguage')) {
+            if (file_exists($CFG->dirroot .'/lang/'. $parentlang .'/pix.php')) {
                 $lang = $parentlang;
             } else {
-                $lang = "en";  // countries.php must exist in this pack
+                $lang = 'en';  // countries.php must exist in this pack
             }
         } else {
-            $lang = "en";  // countries.php must exist in this pack
+            $lang = 'en';  // countries.php must exist in this pack
         }
     }
 
-    include_once("$CFG->dirroot/lang/$lang/pix.php");
+    include_once($CFG->dirroot .'/lang/'. $lang .'/pix.php');
 
     return $string;
 }
@@ -2333,11 +2330,11 @@ function document_file($file, $include=true) {
         return false;
     }
 
-    $langs = array(current_language(), get_string("parentlanguage"), "en");
+    $langs = array(current_language(), get_string('parentlanguage'), 'en');
 
     foreach ($langs as $lang) {
-        $info->filepath = "$CFG->dirroot/lang/$lang/docs/$file";
-        $info->urlpath  = "$CFG->wwwroot/lang/$lang/docs/$file";
+        $info->filepath = $CFG->dirroot .'/lang/'. $lang .'/docs/'. $file;
+        $info->urlpath  = $CFG->wwwroot .'/lang/'. $lang .'/docs/'. $file;
 
         if (file_exists($info->filepath)) {
             if ($include) {
@@ -2354,13 +2351,13 @@ function document_file($file, $include=true) {
 /// ENCRYPTION  ////////////////////////////////////////////////
 
 function rc4encrypt($data) {
-    $password = "nfgjeingjk";
-    return endecrypt($password, $data, "");
+    $password = 'nfgjeingjk';
+    return endecrypt($password, $data, '');
 }
 
 function rc4decrypt($data) {
-    $password = "nfgjeingjk";
-    return endecrypt($password, $data, "de");
+    $password = 'nfgjeingjk';
+    return endecrypt($password, $data, 'de');
 }
 
 function endecrypt ($pwd, $data, $case) {
@@ -2370,9 +2367,9 @@ function endecrypt ($pwd, $data, $case) {
         $data = urldecode($data);
     }
 
-    $key[] = "";
-    $box[] = "";
-    $temp_swap = "";
+    $key[] = '';
+    $box[] = '';
+    $temp_swap = '';
     $pwd_length = 0;
 
     $pwd_length = strlen($pwd);
@@ -2391,11 +2388,11 @@ function endecrypt ($pwd, $data, $case) {
         $box[$x] = $temp_swap;
     }
 
-    $temp = "";
-    $k = "";
+    $temp = '';
+    $k = '';
 
-    $cipherby = "";
-    $cipher = "";
+    $cipherby = '';
+    $cipher = '';
 
     $a = 0;
     $j = 0;
@@ -2445,13 +2442,13 @@ function add_event($event) {
 
     $event->timemodified = time();
 
-    if (!$event->id = insert_record("event", $event)) {
+    if (!$event->id = insert_record('event', $event)) {
         return false;
     }
 
     if (!empty($CFG->calendar)) { // call the add_event function of the selected calendar
-        if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
-            include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+        if (file_exists($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php')) {
+            include_once($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php');
             $calendar_add_event = $CFG->calendar.'_add_event';
             if (function_exists($calendar_add_event)) {
                 $calendar_add_event($event);
@@ -2472,15 +2469,15 @@ function update_event($event) {
     $event->timemodified = time();
 
     if (!empty($CFG->calendar)) { // call the update_event function of the selected calendar
-        if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
-            include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+        if (file_exists($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php')) {
+            include_once($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php');
             $calendar_update_event = $CFG->calendar.'_update_event';
             if (function_exists($calendar_update_event)) {
                 $calendar_update_event($event);
             }
         }
     }
-    return update_record("event", $event);
+    return update_record('event', $event);
 }
 
 
@@ -2490,15 +2487,15 @@ function delete_event($id) {
     global $CFG;
 
     if (!empty($CFG->calendar)) { // call the delete_event function of the selected calendar
-        if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
-            include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+        if (file_exists($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php')) {
+            include_once($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php');
             $calendar_delete_event = $CFG->calendar.'_delete_event';
             if (function_exists($calendar_delete_event)) {
                 $calendar_delete_event($id);
             }
         }
     }
-    return delete_records("event", 'id', $id);
+    return delete_records('event', 'id', $id);
 }
 
 
@@ -2509,8 +2506,8 @@ function hide_event($event) {
     global $CFG;
 
     if (!empty($CFG->calendar)) { // call the update_event function of the selected calendar
-        if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
-            include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+        if (file_exists($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php')) {
+            include_once($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php');
             $calendar_hide_event = $CFG->calendar.'_hide_event';
             if (function_exists($calendar_hide_event)) {
                 $calendar_hide_event($event);
@@ -2528,8 +2525,8 @@ function show_event($event) {
     global $CFG;
 
     if (!empty($CFG->calendar)) { // call the update_event function of the selected calendar
-        if (file_exists("$CFG->dirroot/calendar/$CFG->calendar/lib.php")) {
-            include_once("$CFG->dirroot/calendar/$CFG->calendar/lib.php");
+        if (file_exists($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php')) {
+            include_once($CFG->dirroot .'/calendar/'. $CFG->calendar .'/lib.php');
             $calendar_show_event = $CFG->calendar.'_show_event';
             if (function_exists($calendar_show_event)) {
                 $calendar_show_event($event);
@@ -2542,18 +2539,18 @@ function show_event($event) {
 
 /// ENVIRONMENT CHECKING  ////////////////////////////////////////////////////////////
 
-function get_list_of_plugins($plugin="mod", $exclude="") {
+function get_list_of_plugins($plugin='mod', $exclude='') {
 /// Lists plugin directories within some directory
 
     global $CFG;
 
-    $basedir = opendir("$CFG->dirroot/$plugin");
+    $basedir = opendir($CFG->dirroot .'/'. $plugin);
     while ($dir = readdir($basedir)) {
         $firstchar = substr($dir, 0, 1);
-        if ($firstchar == "." or $dir == "CVS" or $dir == "_vti_cnf" or $dir == $exclude) {
+        if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf' or $dir == $exclude) {
             continue;
         }
-        if (filetype("$CFG->dirroot/$plugin/$dir") != "dir") {
+        if (filetype($CFG->dirroot .'/'. $plugin .'/'. $dir) != 'dir') {
             continue;
         }
         $plugins[] = $dir;
@@ -2564,18 +2561,18 @@ function get_list_of_plugins($plugin="mod", $exclude="") {
     return $plugins;
 }
 
-function check_php_version($version="4.1.0") {
+function check_php_version($version='4.1.0') {
 /// Returns true is the current version of PHP is greater that the specified one
-    $minversion = intval(str_replace(".", "", $version));
-    $curversion = intval(str_replace(".", "", phpversion()));
+    $minversion = intval(str_replace('.', '', $version));
+    $curversion = intval(str_replace('.', '', phpversion()));
     return ($curversion >= $minversion);
 }
 
-function check_browser_version($brand="MSIE", $version=5.5) {
+function check_browser_version($brand='MSIE', $version=5.5) {
 /// Checks to see if is a browser matches the specified
 /// brand and is equal or better version.
 
-    $agent = $_SERVER["HTTP_USER_AGENT"];
+    $agent = $_SERVER['HTTP_USER_AGENT'];
 
     if (empty($agent)) {
         return false;
@@ -2583,9 +2580,9 @@ function check_browser_version($brand="MSIE", $version=5.5) {
 
     switch ($brand) {
 
-      case "Gecko":   /// Gecko based browsers
+      case 'Gecko':   /// Gecko based browsers
 
-          if (substr_count($agent, "Camino")) {     // MacOS X Camino not supported.
+          if (substr_count($agent, 'Camino')) {     // MacOS X Camino not supported.
               return false;
           }
 
@@ -2600,16 +2597,16 @@ function check_browser_version($brand="MSIE", $version=5.5) {
           break;
 
 
-      case "MSIE":   /// Internet Explorer
+      case 'MSIE':   /// Internet Explorer
 
           if (strpos($agent, 'Opera')) {     // Reject Opera
               return false;
           }
-          $string = explode(";", $agent);
+          $string = explode(';', $agent);
           if (!isset($string[1])) {
               return false;
           }
-          $string = explode(" ", trim($string[1]));
+          $string = explode(' ', trim($string[1]));
           if (!isset($string[0]) and !isset($string[1])) {
               return false;
           }
@@ -2632,7 +2629,7 @@ function ini_get_bool($ini_get_arg) {
 
     $temp = ini_get($ini_get_arg);
 
-    if ($temp == "1" or strtolower($temp) == "on") {
+    if ($temp == '1' or strtolower($temp) == 'on') {
         return true;
     }
     return false;
@@ -2652,10 +2649,10 @@ function can_use_html_editor() {
     global $USER, $CFG;
 
     if (!empty($USER->htmleditor) and !empty($CFG->htmleditor)) {
-        if (check_browser_version("MSIE", 5.5)) {
-            return "MSIE";
-        } else if (check_browser_version("Gecko", 20030516)) {
-            return "Gecko";
+        if (check_browser_version('MSIE', 5.5)) {
+            return 'MSIE';
+        } else if (check_browser_version('Gecko', 20030516)) {
+            return 'Gecko';
         }
     }
     return false;
@@ -2668,9 +2665,9 @@ function check_gd_version() {
 
     if (function_exists('gd_info')){
         $gd_info = gd_info();
-        if (substr_count($gd_info['GD Version'], "2.")) {
+        if (substr_count($gd_info['GD Version'], '2.')) {
             $gdversion = 2;
-        } else if (substr_count($gd_info['GD Version'], "1.")) {
+        } else if (substr_count($gd_info['GD Version'], '1.')) {
             $gdversion = 1;
         }
 
@@ -2688,9 +2685,9 @@ function check_gd_version() {
             foreach ($parts as $key => $val) {
                 $parts[$key] = trim(strip_tags($val));
             }
-            if ($parts[0] == "GD Version") {
-                if (substr_count($parts[1], "2.0")) {
-                    $parts[1] = "2.0";
+            if ($parts[0] == 'GD Version') {
+                if (substr_count($parts[1], '2.0')) {
+                    $parts[1] = '2.0';
                 }
                 $gdversion = intval($parts[1]);
             }
@@ -2706,21 +2703,21 @@ function moodle_needs_upgrading() {
 /// if there are any mismatches ... returns true or false
     global $CFG;
 
-    include_once("$CFG->dirroot/version.php");  # defines $version and upgrades
+    include_once($CFG->dirroot .'/version.php');  # defines $version and upgrades
     if ($CFG->version) {
         if ($version > $CFG->version) {
             return true;
         }
-        if ($mods = get_list_of_plugins("mod")) {
+        if ($mods = get_list_of_plugins('mod')) {
             foreach ($mods as $mod) {
-                $fullmod = "$CFG->dirroot/mod/$mod";
+                $fullmod = $CFG->dirroot .'/mod/'. $mod;
                 unset($module);
-                if (!is_readable("$fullmod/version.php")) {
-                    notify("Module '$mod' is not readable - check permissions");
+                if (!is_readable($fullmod .'/version.php')) {
+                    notify('Module "'. $mod .'" is not readable - check permissions');
                     continue;
                 }
-                include_once("$fullmod/version.php");  # defines $module with version etc
-                if ($currmodule = get_record("modules", "name", $mod)) {
+                include_once($fullmod .'/version.php');  # defines $module with version etc
+                if ($currmodule = get_record('modules', 'name', $mod)) {
                     if ($module->version > $currmodule->version) {
                         return true;
                     }
@@ -2758,32 +2755,32 @@ function notify_login_failures() {
         $CFG->notifyloginthreshold = 10; // default to something sensible.
     }
 
-    $notifyipsrs = $db->Execute("SELECT ip FROM {$CFG->prefix}log WHERE time > {$CFG->lastnotifyfailure}
-                          AND module='login' AND action='error' GROUP BY ip HAVING count(*) > $CFG->notifyloginthreshold");
+    $notifyipsrs = $db->Execute('SELECT ip FROM '. $CFG->prefix .'log WHERE time > '. $CFG->lastnotifyfailure .'
+                          AND module=\'login\' AND action=\'error\' GROUP BY ip HAVING count(*) > '. $CFG->notifyloginthreshold);
 
-    $notifyusersrs = $db->Execute("SELECT info FROM {$CFG->prefix}log WHERE time > {$CFG->lastnotifyfailure}
-                          AND module='login' AND action='error' GROUP BY info HAVING count(*) > $CFG->notifyloginthreshold");
+    $notifyusersrs = $db->Execute('SELECT info FROM '. $CFG->prefix .'log WHERE time > '. $CFG->lastnotifyfailure .'
+                          AND module=\'login\' AND action=\'error\' GROUP BY info HAVING count(*) > '. $CFG->notifyloginthreshold);
 
     if ($notifyipsrs) {
         $ipstr = '';
         while ($row = $notifyipsrs->FetchRow()) {
-            $ipstr .= "'".$row['ip']."',";
+            $ipstr .= "'". $row['ip'] ."',";
         }
         $ipstr = substr($ipstr,0,strlen($ipstr)-1);
     }
     if ($notifyusersrs) {
         $userstr = '';
         while ($row = $notifyusersrs->FetchRow()) {
-            $userstr .= "'".$row['info']."',";
+            $userstr .= "'". $row['info'] ."',";
         }
         $userstr = substr($userstr,0,strlen($userstr)-1);
     }
 
     if (strlen($userstr) > 0 || strlen($ipstr) > 0) {
         $count = 0;
-        $logs = get_logs("time > {$CFG->lastnotifyfailure} AND module='login' AND action='error' "
-                 .((strlen($ipstr) > 0 && strlen($userstr) > 0) ? " AND ( ip IN ($ipstr) OR info IN ($userstr) ) "
-                 : ((strlen($ipstr) != 0) ? " AND ip IN ($ipstr) " : " AND info IN ($userstr) ")),"l.time DESC","","",$count);
+        $logs = get_logs('time > '. $CFG->lastnotifyfailure .' AND module=\'login\' AND action=\'error\' '
+                 .((strlen($ipstr) > 0 && strlen($userstr) > 0) ? ' AND ( ip IN ('. $ipstr .') OR info IN ('. $userstr .') ) '
+                 : ((strlen($ipstr) != 0) ? ' AND ip IN ('. $ipstr .') ' : ' AND info IN ('. $userstr .') ')), 'l.time DESC', '', '', $count);
 
         // if we haven't run in the last hour and we have something useful to report and we are actually supposed to be reporting to somebody
         if (is_array($recip) and count($recip) > 0 and ((time() - (60 * 60)) > $CFG->lastnotifyfailure)
@@ -2791,8 +2788,8 @@ function notify_login_failures() {
 
             $message = '';
             $site = get_site();
-            $subject = get_string('notifyloginfailuressubject','',$site->fullname);
-            $message .= get_string('notifyloginfailuresmessagestart','',$CFG->wwwroot)
+            $subject = get_string('notifyloginfailuressubject', '', $site->fullname);
+            $message .= get_string('notifyloginfailuresmessagestart', '', $CFG->wwwroot)
                  .(($CFG->lastnotifyfailure != 0) ? '('.userdate($CFG->lastnotifyfailure).')' : '')."\n\n";
             foreach ($logs as $log) {
                 $log->time = userdate($log->time);
@@ -2800,19 +2797,19 @@ function notify_login_failures() {
             }
             $message .= "\n\n".get_string('notifyloginfailuresmessageend','',$CFG->wwwroot)."\n\n";
             foreach ($recip as $admin) {
-                mtrace("Emailing $admin->username about ".count($logs)." failed login attempts");
+                mtrace('Emailing '. $admin->username .' about '. count($logs) .' failed login attempts');
                 email_to_user($admin,get_admin(),$subject,$message);
             }
-            $conf->name = "lastnotifyfailure";
+            $conf->name = 'lastnotifyfailure';
             $conf->value = time();
-            if ($current = get_record("config", "name", "lastnotifyfailure")) {
+            if ($current = get_record('config', 'name', 'lastnotifyfailure')) {
                 $conf->id = $current->id;
-                if (! update_record("config", $conf)) {
-                    mtrace("Could not update last notify time");
+                if (! update_record('config', $conf)) {
+                    mtrace('Could not update last notify time');
                 }
 
-            } else if (! insert_record("config", $conf)) {
-                mtrace("Could not set last notify time");
+            } else if (! insert_record('config', $conf)) {
+                mtrace('Could not set last notify time');
             }
         }
     }
@@ -2862,12 +2859,12 @@ function count_words($string) {
 }
 
 function random_string ($length=15) {
-    $pool  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-    $pool .= "abcdefghijklmnopqrstuvwxyz";
-    $pool .= "0123456789";
+    $pool  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+    $pool .= 'abcdefghijklmnopqrstuvwxyz';
+    $pool .= '0123456789';
     $poollen = strlen($pool);
     mt_srand ((double) microtime() * 1000000);
-    $string = "";
+    $string = '';
     for ($i = 0; $i < $length; $i++) {
         $string .= substr($pool, (mt_rand()%($poollen)), 1);
     }
@@ -2892,7 +2889,7 @@ function generate_password($maxlen=10) {
 
     global $CFG;
 
-    $fillers = "1234567890!$-+";
+    $fillers = '1234567890!$-+';
     $wordlist = file($CFG->wordlist);
 
     srand((double) microtime() * 1000000);
@@ -2964,12 +2961,12 @@ function draw_rand_array($array, $draws) {
 }
 
 function microtime_diff($a, $b) {
-    list($a_dec, $a_sec) = explode(" ", $a);
-    list($b_dec, $b_sec) = explode(" ", $b);
+    list($a_dec, $a_sec) = explode(' ', $a);
+    list($b_dec, $b_sec) = explode(' ', $b);
     return $b_sec - $a_sec + $b_dec - $a_dec;
 }
 
-function make_menu_from_list($list, $separator=",") {
+function make_menu_from_list($list, $separator=',') {
 /// Given a list (eg a,b,c,d,e) this function returns
 /// an array of 1->a, 2->b, 3->c etc
 
@@ -2988,12 +2985,12 @@ function make_grades_menu($gradingtype) {
 
     $grades = array();
     if ($gradingtype < 0) {
-        if ($scale = get_record("scale", "id", - $gradingtype)) {
+        if ($scale = get_record('scale', 'id', - $gradingtype)) {
             return make_menu_from_list($scale->scale);
         }
     } else if ($gradingtype > 0) {
         for ($i=$gradingtype; $i>=0; $i--) {
-            $grades[$i] = "$i / $gradingtype";
+            $grades[$i] = $i .' / '. $gradingtype;
         }
         return $grades;
     }
@@ -3045,17 +3042,17 @@ function site_scale_used($scaleid) {
     return $return;
 }
 
-function make_unique_id_code($extra="") {
+function make_unique_id_code($extra='') {
 
-    $hostname = "unknownhost";
-    if (!empty($_SERVER["HTTP_HOST"])) {
-        $hostname = $_SERVER["HTTP_HOST"];
-    } else if (!empty($_ENV["HTTP_HOST"])) {
-        $hostname = $_ENV["HTTP_HOST"];
-    } else if (!empty($_SERVER["SERVER_NAME"])) {
-        $hostname = $_SERVER["SERVER_NAME"];
-    } else if (!empty($_ENV["SERVER_NAME"])) {
-        $hostname = $_ENV["SERVER_NAME"];
+    $hostname = 'unknownhost';
+    if (!empty($_SERVER['HTTP_HOST'])) {
+        $hostname = $_SERVER['HTTP_HOST'];
+    } else if (!empty($_ENV['HTTP_HOST'])) {
+        $hostname = $_ENV['HTTP_HOST'];
+    } else if (!empty($_SERVER['SERVER_NAME'])) {
+        $hostname = $_SERVER['SERVER_NAME'];
+    } else if (!empty($_ENV['SERVER_NAME'])) {
+        $hostname = $_ENV['SERVER_NAME'];
     }
 
     $date = gmdate("ymdHis");
@@ -3063,9 +3060,9 @@ function make_unique_id_code($extra="") {
     $random =  random_string(6);
 
     if ($extra) {
-        return "$hostname+$date+$random+$extra";
+        return $hostname .'+'. $date .'+'. $random .'+'. $extra;
     } else {
-        return "$hostname+$date+$random";
+        return $hostname .'+'. $date .'+'. $random;
     }
 }
 
@@ -3087,13 +3084,13 @@ function make_unique_id_code($extra="") {
 
 function address_in_subnet($addr, $subnetstr) {
 
-    $subnets = explode(",", $subnetstr);
+    $subnets = explode(',', $subnetstr);
     $found = false;
     $addr = trim($addr);
 
     foreach ($subnets as $subnet) {
         $subnet = trim($subnet);
-        if (strpos($subnet, "/") !== false) { /// type 1
+        if (strpos($subnet, '/') !== false) { /// type 1
 
             list($ip, $mask) = explode('/', $subnet);
             $mask = 0xffffffff << (32 - $mask);
@@ -3117,7 +3114,7 @@ function mtrace($string, $eol="\n") {
     if (defined('STDOUT')) {
         fwrite(STDOUT, $string.$eol);
     } else {
-        echo "$string$eol";
+        echo $string . $eol;
     }
 
     flush();
@@ -3125,9 +3122,9 @@ function mtrace($string, $eol="\n") {
 
 function getremoteaddr() {
 //Returns most reliable client address
-    if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
-    else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
-    else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
+    if (getenv('HTTP_CLIENT_IP')) $ip = getenv('HTTP_CLIENT_IP');
+    else if(getenv('HTTP_X_FORWARDED_FOR')) $ip = getenv('HTTP_X_FORWARDED_FOR');
+    else if(getenv('REMOTE_ADDR')) $ip = getenv('REMOTE_ADDR');
     else $ip = false; //just in case
     return $ip;
 }
index 79b744c409acf1999eae7c8a9cfae403fd80fd88..7540c0653ff36e811038d02932ebf27ad49753d2 100644 (file)
 /// Constants
 
 /// Define text formatting types ... eventually we can add Wiki, BBcode etc
-define("FORMAT_MOODLE",   "0");   // Does all sorts of transformations and filtering
-define("FORMAT_HTML",     "1");   // Plain HTML (with some tags stripped)
-define("FORMAT_PLAIN",    "2");   // Plain text (even tags are printed in full)
-define("FORMAT_WIKI",     "3");   // Wiki-formatted text
-define("FORMAT_MARKDOWN", "4");   // Markdown-formatted text http://daringfireball.net/projects/markdown/
+define('FORMAT_MOODLE',   '0');   // Does all sorts of transformations and filtering
+define('FORMAT_HTML',     '1');   // Plain HTML (with some tags stripped)
+define('FORMAT_PLAIN',    '2');   // Plain text (even tags are printed in full)
+define('FORMAT_WIKI',     '3');   // Wiki-formatted text
+define('FORMAT_MARKDOWN', '4');   // Markdown-formatted text http://daringfireball.net/projects/markdown/
 
 $ALLOWED_TAGS =
-"<p><br /><b><i><u><font><table><tbody><span><div><tr><td><th><ol><ul><dl><li><dt><dd><h1><h2><h3><h4><h5><h6><hr><img><a><strong><emphasis><em><sup><sub><address><cite><blockquote><pre><strike><embed><object><param><acronym><nolink><style><lang><tex><algebra><math><mi><mn><mo><mtext><mspace><ms><mrow><mfrac><msqrt><mroot><mstyle><merror><mpadded><mphantom><mfenced><msub><msup><msubsup><munder><mover><munderover><mmultiscripts><mtable><mtr><mtd><maligngroup><malignmark><maction><cn><ci><apply><reln><fn><interval><inverse><sep><condition><declare><lambda><compose><ident><quotient><exp><factorial><divide><max><min><minus><plus><power><rem><times><root><gcd><and><or><xor><not><implies><forall><exists><abs><conjugate><eq><neq><gt><lt><geq><leq><ln><log><int><diff><partialdiff><lowlimit><uplimit><bvar><degree><set><list><union><intersect><in><notin><subset><prsubset><notsubset><notprsubset><setdiff><sum><product><limit><tendsto><mean><sdev><variance><median><mode><moment><vector><matrix><matrixrow><determinant><transpose><selector><annotation><semantics><annotation-xml><tt><code>";
+'<p><br /><b><i><u><font><table><tbody><span><div><tr><td><th><ol><ul><dl><li><dt><dd><h1><h2><h3><h4><h5><h6><hr><img><a><strong><emphasis><em><sup><sub><address><cite><blockquote><pre><strike><embed><object><param><acronym><nolink><style><lang><tex><algebra><math><mi><mn><mo><mtext><mspace><ms><mrow><mfrac><msqrt><mroot><mstyle><merror><mpadded><mphantom><mfenced><msub><msup><msubsup><munder><mover><munderover><mmultiscripts><mtable><mtr><mtd><maligngroup><malignmark><maction><cn><ci><apply><reln><fn><interval><inverse><sep><condition><declare><lambda><compose><ident><quotient><exp><factorial><divide><max><min><minus><plus><power><rem><times><root><gcd><and><or><xor><not><implies><forall><exists><abs><conjugate><eq><neq><gt><lt><geq><leq><ln><log><int><diff><partialdiff><lowlimit><uplimit><bvar><degree><set><list><union><intersect><in><notin><subset><prsubset><notsubset><notprsubset><setdiff><sum><product><limit><tendsto><mean><sdev><variance><median><mode><moment><vector><matrix><matrixrow><determinant><transpose><selector><annotation><semantics><annotation-xml><tt><code>';
 
 
 /// Functions
@@ -48,7 +48,7 @@ function s($var) {
 /// returns $var with HTML characters (like "<", ">", etc.) properly quoted,
 
     if (empty($var)) {
-        return "";
+        return '';
     }
     return htmlSpecialChars(stripslashes_safe($var));
 }
@@ -57,12 +57,12 @@ function p($var) {
 /// prints $var with HTML characters (like "<", ">", etc.) properly quoted,
 
     if (empty($var)) {
-        echo "";
+        echo '';
     }
     echo htmlSpecialChars(stripslashes_safe($var));
 }
 
-function nvl(&$var, $default="") {
+function nvl(&$var, $default='') {
 /// if $var is undefined, return $default, otherwise return $var
 
     return isset($var) ? $var : $default;
@@ -81,7 +81,7 @@ function strip_querystring($url) {
 function get_referer() {
 /// returns the URL of the HTTP_REFERER, less the querystring portion
 
-    return strip_querystring(nvl($_SERVER["HTTP_REFERER"]));
+    return strip_querystring(nvl($_SERVER['HTTP_REFERER']));
 }
 
 
@@ -91,29 +91,29 @@ function me() {
 /// return different things depending on a lot of things like your OS, Web
 /// server, and the way PHP is compiled (ie. as a CGI, module, ISAPI, etc.)
 
-    if (!empty($_SERVER["REQUEST_URI"])) {
-        return $_SERVER["REQUEST_URI"];
+    if (!empty($_SERVER['REQUEST_URI'])) {
+        return $_SERVER['REQUEST_URI'];
 
-    } else if (!empty($_SERVER["PHP_SELF"])) {
-        if (!empty($_SERVER["QUERY_STRING"])) {
-            return $_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"];
+    } else if (!empty($_SERVER['PHP_SELF'])) {
+        if (!empty($_SERVER['QUERY_STRING'])) {
+            return $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
         }
-        return $_SERVER["PHP_SELF"];
+        return $_SERVER['PHP_SELF'];
 
-    } else if (!empty($_SERVER["SCRIPT_NAME"])) {
-        if (!empty($_SERVER["QUERY_STRING"])) {
-            return $_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];
+    } else if (!empty($_SERVER['SCRIPT_NAME'])) {
+        if (!empty($_SERVER['QUERY_STRING'])) {
+            return $_SERVER['SCRIPT_NAME'] .'?'. $_SERVER['QUERY_STRING'];
         }
-        return $_SERVER["SCRIPT_NAME"];
+        return $_SERVER['SCRIPT_NAME'];
 
-    } else if (!empty($_SERVER["URL"])) {     // May help IIS (not well tested)
-        if (!empty($_SERVER["QUERY_STRING"])) {
-            return $_SERVER["URL"]."?".$_SERVER["QUERY_STRING"];
+    } else if (!empty($_SERVER['URL'])) {     // May help IIS (not well tested)
+        if (!empty($_SERVER['QUERY_STRING'])) {
+            return $_SERVER['URL'] .'?'. $_SERVER['QUERY_STRING'];
         }
-        return $_SERVER["URL"];
+        return $_SERVER['URL'];
 
     } else {
-        notify("Warning: Could not find any of these web server variables: \$REQUEST_URI, \$PHP_SELF, \$SCRIPT_NAME or \$URL");
+        notify('Warning: Could not find any of these web server variables: $REQUEST_URI, $PHP_SELF, $SCRIPT_NAME or $URL');
         return false;
     }
 }
@@ -122,16 +122,16 @@ function me() {
 function qualified_me() {
 /// like me() but returns a full URL
 
-    if (!empty($_SERVER["SERVER_NAME"])) {
-        $hostname = $_SERVER["SERVER_NAME"];
-    } else if (!empty($_ENV["SERVER_NAME"])) {
-        $hostname = $_ENV["SERVER_NAME"];
-    } else if (!empty($_SERVER["HTTP_HOST"])) {
-        $hostname = $_SERVER["HTTP_HOST"];
-    } else if (!empty($_ENV["HTTP_HOST"])) {
-        $hostname = $_ENV["HTTP_HOST"];
+    if (!empty($_SERVER['SERVER_NAME'])) {
+        $hostname = $_SERVER['SERVER_NAME'];
+    } else if (!empty($_ENV['SERVER_NAME'])) {
+        $hostname = $_ENV['SERVER_NAME'];
+    } else if (!empty($_SERVER['HTTP_HOST'])) {
+        $hostname = $_SERVER['HTTP_HOST'];
+    } else if (!empty($_ENV['HTTP_HOST'])) {
+        $hostname = $_ENV['HTTP_HOST'];
     } else {
-        notify("Warning: could not find the name of this server!");
+        notify('Warning: could not find the name of this server!');
         return false;
     }
     if (isset($_SERVER['HTTPS'])) {
@@ -147,7 +147,7 @@ function qualified_me() {
 }
 
 
-function match_referer($goodreferer = "") {
+function match_referer($goodreferer = '') {
 /// returns true if the referer is the same as the goodreferer.  If
 /// goodreferer is not specified, use qualified_me as the goodreferer
     global $CFG;
@@ -156,7 +156,7 @@ function match_referer($goodreferer = "") {
         return true;
     }
 
-    if ($goodreferer == "nomatch") {   // Don't bother checking referer
+    if ($goodreferer == 'nomatch') {   // Don't bother checking referer
         return true;
     }
 
@@ -166,10 +166,10 @@ function match_referer($goodreferer = "") {
 
     $referer = get_referer();
 
-    return (($referer == $goodreferer) or ($referer == "$CFG->wwwroot/"));
+    return (($referer == $goodreferer) or ($referer == $CFG->wwwroot .'/'));
 }
 
-function data_submitted($url="") {
+function data_submitted($url='') {
 /// Used on most forms in Moodle to check for data
 /// Returns the data as an object, if it's found.
 /// This object can be used in foreach loops without
@@ -189,7 +189,7 @@ function data_submitted($url="") {
             return (object)$_POST;
         } else {
             if ($CFG->debug > 10) {
-                notice("The form did not come from this page! (referer = ".get_referer().")");
+                notice('The form did not come from this page! (referer = '. get_referer() .')');
             }
             return false;
         }
@@ -292,7 +292,7 @@ function read_template($filename, &$var) {
 ///
 /// WARNING: do not use this on big files!!
 
-    $temp = str_replace("\\", "\\\\", implode(file($filename), ""));
+    $temp = str_replace("\\", "\\\\", implode(file($filename), ''));
     $temp = str_replace('"', '\"', $temp);
     eval("\$template = \"$temp\";");
     return $template;
@@ -310,7 +310,7 @@ function checked(&$var, $set_value = 1, $unset_value = 0) {
     }
 }
 
-function frmchecked(&$var, $true_value = "checked", $false_value = "") {
+function frmchecked(&$var, $true_value = 'checked', $false_value = '') {
 /// prints the word "checked" if a variable is true, otherwise prints nothing,
 /// used for printing the word "checked" in a checkbox form input
 
@@ -322,8 +322,8 @@ function frmchecked(&$var, $true_value = "checked", $false_value = "") {
 }
 
 
-function link_to_popup_window ($url, $name="popup", $linkname="click here",
-                               $height=400, $width=500, $title="Popup window", $options="none", $return=false) {
+function link_to_popup_window ($url, $name='popup', $linkname='click here',
+                               $height=400, $width=500, $title='Popup window', $options='none', $return=false) {
 /// This will create a HTML link that will work on both
 /// Javascript and non-javascript browsers.
 /// Relies on the Javascript function openpopup in javascript.php
@@ -331,8 +331,8 @@ function link_to_popup_window ($url, $name="popup", $linkname="click here",
 
     global $CFG;
 
-    if ($options == "none") {
-        $options = "menubar=0,location=0,scrollbars,resizable,width=$width,height=$height";
+    if ($options == 'none') {
+        $options = 'menubar=0,location=0,scrollbars,resizable,width='. $width .',height='. $height;
     }
     $fullscreen = 0;
 
@@ -340,7 +340,7 @@ function link_to_popup_window ($url, $name="popup", $linkname="click here",
         $url = substr($url,strlen($CFG->wwwroot)+1);
     }
 
-    $link = "<a target=\"$name\" title=\"$title\" href=\"$CFG->wwwroot$url\" ".
+    $link = '<a target="'. $name .'" title="'. $title .'" href="'. $CFG->wwwroot . $url .'" '.
            "onclick=\"return openpopup('$url', '$name', '$options', $fullscreen);\">$linkname</a>\n";
     if ($return) {
         return $link;
@@ -350,8 +350,8 @@ function link_to_popup_window ($url, $name="popup", $linkname="click here",
 }
 
 
-function button_to_popup_window ($url, $name="popup", $linkname="click here",
-                                 $height=400, $width=500, $title="Popup window", $options="none") {
+function button_to_popup_window ($url, $name='popup', $linkname='click here',
+                                 $height=400, $width=500, $title='Popup window', $options='none') {
 /// This will create a HTML link that will work on both
 /// Javascript and non-javascript browsers.
 /// Relies on the Javascript function openpopup in javascript.php
@@ -359,12 +359,12 @@ function button_to_popup_window ($url, $name="popup", $linkname="click here",
 
     global $CFG;
 
-    if ($options == "none") {
-        $options = "menubar=0,location=0,scrollbars,resizable,width=$width,height=$height";
+    if ($options == 'none') {
+        $options = 'menubar=0,location=0,scrollbars,resizable,width='. $width .',height='. $height;
     }
     $fullscreen = 0;
 
-    echo "<input type=\"button\" name=\"popupwindow\" title=\"$title\" value=\"$linkname ...\" ".
+    echo '<input type="button" name="popupwindow" title="'. $title .'" value="'. $linkname .' ..." '.
          "onClick=\"return openpopup('$url', '$name', '$options', $fullscreen);\" />\n";
 }
 
@@ -372,57 +372,57 @@ function button_to_popup_window ($url, $name="popup", $linkname="click here",
 function close_window_button() {
 /// Prints a simple button to close a window
 
-    echo "<center>\n";
-    echo "<script type=\"text/javascript\">\n";
-    echo "<!--\n";
+    echo '<center>' . "\n";
+    echo '<script type="text/javascript">' . "\n";
+    echo '<!--' . "\n";
     echo "document.write('<form>');\n";
     echo "document.write('<input type=\"button\" onClick=\"self.close();\" value=\"".get_string("closewindow")."\" />');\n";
     echo "document.write('</form>');\n";
-    echo "-->\n";
-    echo "</script>\n";
-    echo "<noscript>\n";
-    echo "<a href=\"".$_SERVER['HTTP_REFERER']."\"><---</a>\n";
-    echo "</noscript>\n";
-    echo "</center>\n";
+    echo '-->' . "\n";
+    echo '</script>' . "\n";
+    echo '<noscript>' . "\n";
+    echo '<a href="'. $_SERVER['HTTP_REFERER'] .'"><---</a>' . "\n";
+    echo '</noscript>' . "\n";
+    echo '</center>' . "\n";
 }
 
 
-function choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) {
+function choose_from_menu ($options, $name, $selected='', $nothing='choose', $script='', $nothingvalue='0', $return=false) {
 /// Given an array of value, creates a popup menu to be part of a form
 /// $options["value"]["label"]
 
-    if ($nothing == "choose") {
-        $nothing = get_string("choose")."...";
+    if ($nothing == 'choose') {
+        $nothing = get_string('choose') .'...';
     }
 
     if ($script) {
-        $javascript = "onchange=\"$script\"";
+        $javascript = 'onchange="'. $script .'"';
     } else {
-        $javascript = "";
+        $javascript = '';
     }
 
-    $output = "<select name=\"$name\" $javascript>\n";
+    $output = '<select name="'. $name .'" '. $javascript .'>' . "\n";
     if ($nothing) {
-        $output .= "   <option value=\"$nothingvalue\"\n";
+        $output .= '   <option value="'. $nothingvalue .'"'. "\n";
         if ($nothingvalue === $selected) {
-            $output .= " selected=\"selected\"";
+            $output .= ' selected="selected"';
         }
-        $output .= ">$nothing</option>\n";
+        $output .= '>'. $nothing .'</option>' . "\n";
     }
     if (!empty($options)) {
         foreach ($options as $value => $label) {
-            $output .= "   <option value=\"$value\"";
+            $output .= '   <option value="'. $value .'"';
             if ($value == $selected) {
-                $output .= " selected=\"selected\"";
+                $output .= ' selected="selected"';
             }
-            if ($label === "") {
-                $output .= ">$value</option>\n";
+            if ($label === '') {
+                $output .= '>'. $value .'</option>' . "\n";
             } else {
-                $output .= ">$label</option>\n";
+                $output .= '>'. $label .'</option>' . "\n";
             }
         }
     }
-    $output .= "</select>\n";
+    $output .= '</select>' . "\n";
 
     if ($return) {
         return $output;
@@ -431,7 +431,7 @@ function choose_from_menu ($options, $name, $selected="", $nothing="choose", $sc
     }
 }
 
-function popup_form ($common, $options, $formname, $selected="", $nothing="choose", $help="", $helptext="", $return=false, $targetwindow="self") {
+function popup_form ($common, $options, $formname, $selected='', $nothing='choose', $help='', $helptext='', $return=false, $targetwindow='self') {
 ///  Implements a complete little popup form
 ///  $common   = the URL up to the point of the variable that changes
 ///  $options  = A list of value-label pairs for the popup list
@@ -475,35 +475,35 @@ function popup_form ($common, $options, $formname, $selected="", $nothing="choos
         return '';
     }
 
-    if ($nothing == "choose") {
-        $nothing = get_string("choose")."...";
+    if ($nothing == 'choose') {
+        $nothing = get_string('choose') .'...';
     }
 
     $startoutput = '<form action="" method="get" target="'.$CFG->framename.'" name="'.$formname.'">';
     $output = "<select name=\"popup\" onchange=\"$targetwindow.location=document.$formname.popup.options[document.$formname.popup.selectedIndex].value;\">\n";
 
-    if ($nothing != "") {
+    if ($nothing != '') {
         $output .= "   <option value=\"javascript:void(0)\">$nothing</option>\n";
     }
 
     foreach ($options as $value => $label) {
-        if (substr($label,0,2) == "--") {
-            $output .= "   <optgroup label=\"$label\"></optgroup>";   // Plain labels
+        if (substr($label,0,2) == '--') {
+            $output .= '   <optgroup label="'. $label .'"></optgroup>';   // Plain labels
             continue;
         } else {
-            $output .= "   <option value=\"$common$value\"";
+            $output .= '   <option value="'. $common . $value .'"';
             if ($value == $selected) {
                 $output .= ' selected="selected"';
             }
         }
         if ($label) {
-            $output .= ">$label</option>\n";
+            $output .= '>'. $label .'</option>' . "\n";
         } else {
-            $output .= ">$value</option>\n";
+            $output .= '>'. $value .'</option>' . "\n";
         }
     }
-    $output .= "</select>";
-    $output .= "</form>\n";
+    $output .= '</select>';
+    $output .= '</form>' . "\n";
 
     if ($help) {
         $button = helpbutton($help, $helptext, 'moodle', true, false, '', true);
@@ -523,7 +523,7 @@ function popup_form ($common, $options, $formname, $selected="", $nothing="choos
 function formerr($error) {
 /// Prints some red text
     if (!empty($error)) {
-        echo "<font color=\"#ff0000\">$error</font>";
+        echo '<font color="#ff0000">'. $error .'</font>';
     }
 }
 
@@ -551,7 +551,7 @@ function detect_munged_arguments($string, $allowdots=1) {
     return false;
 }
 
-function get_slash_arguments($file="file.php") {
+function get_slash_arguments($file='file.php') {
 /// Searches the current environment variables for some slash arguments
 
     if (!$string = me()) {
@@ -574,7 +574,7 @@ function parse_slash_arguments($string, $i=0) {
     if (detect_munged_arguments($string)) {
         return false;
     }
-    $args = explode("/", $string);
+    $args = explode('/', $string);
 
     if ($i) {     // return just the required argument
         return $args[$i];
@@ -587,11 +587,11 @@ function parse_slash_arguments($string, $i=0) {
 
 function format_text_menu() {
 /// Just returns an array of formats suitable for a popup menu
-    return array (FORMAT_MOODLE => get_string("formattext"),
-                  FORMAT_HTML   => get_string("formathtml"),
-                  FORMAT_PLAIN  => get_string("formatplain"),
-                  FORMAT_WIKI   => get_string("formatwiki"),
-                  FORMAT_MARKDOWN  => get_string("formatmarkdown"));
+    return array (FORMAT_MOODLE => get_string('formattext'),
+                  FORMAT_HTML   => get_string('formathtml'),
+                  FORMAT_PLAIN  => get_string('formatplain'),
+                  FORMAT_WIKI   => get_string('formatwiki'),
+                  FORMAT_MARKDOWN  => get_string('formatmarkdown'));
 }
 
 function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL ) {
@@ -631,7 +631,7 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL
         case FORMAT_PLAIN:
             $text = htmlentities($text);
             $text = rebuildnolinktag($text);
-            $text = str_replace("  ", "&nbsp; ", $text);
+            $text = str_replace('  ', '&nbsp; ', $text);
             $text = nl2br($text);
             break;
 
@@ -729,8 +729,8 @@ function filter_text($text, $courseid=NULL) {
     if (!empty($CFG->textfilters)) {
         $textfilters = explode(',', $CFG->textfilters);
         foreach ($textfilters as $textfilter) {
-            if (is_readable("$CFG->dirroot/$textfilter/filter.php")) {
-                include_once("$CFG->dirroot/$textfilter/filter.php");
+            if (is_readable($CFG->dirroot .'/'. $textfilter .'/filter.php')) {
+                include_once($CFG->dirroot .'/'. $textfilter .'/filter.php');
                 $functionname = basename($textfilter).'_filter';
                 if (function_exists($functionname)) {
                     $text = $functionname($courseid, $text);
@@ -791,7 +791,7 @@ function cleanAttributes2($htmlTag){
     ///         17/08/2004              ::          Eamon DOT Costello AT dcu DOT ie
 
     global $CFG;
-    require_once("$CFG->libdir/kses.php");
+    require_once($CFG->libdir .'/kses.php');
 
     $htmlTag = kses_stripslashes($htmlTag);
     if (substr($htmlTag, 0, 1) != '<'){
@@ -816,7 +816,7 @@ function cleanAttributes2($htmlTag){
     if (preg_match('%/\s*$%', $attrlist)){
         $xhtml_slash = ' /';
     }
-    return "<$slash$elem$attStr$xhtml_slash>";
+    return '<'. $slash . $elem . $attStr . $xhtml_slash .'>';
 }
 
 
@@ -858,7 +858,7 @@ function replace_smilies(&$text) {
             $alttext = get_string($image, 'pix');
 
             $e[] = $emoticon;
-            $img[] = "<img alt=\"$alttext\" width=\"15\" height=\"15\" src=\"$CFG->pixpath/s/$image.gif\" />";
+            $img[] = '<img alt="'. $alttext .'" width="15" height="15" src="'. $CFG->pixpath .'/s/'. $image.gif .'" />';
         }
         $runonce = true;
     }
@@ -916,7 +916,7 @@ function text_to_html($text, $smiley=true, $para=true, $newlines=true) {
 
 /// Wrap the whole thing in a paragraph tag if required
     if ($para) {
-        return "<p>".$text."</p>";
+        return '<p>'.$text.'</p>';
     } else {
         return $text;
     }
@@ -926,7 +926,7 @@ function wiki_to_html($text,$courseid) {
 /// Given Wiki formatted text, make it into XHTML using external function
     global $CFG;
 
-    require_once("$CFG->libdir/wiki.php");
+    require_once($CFG->libdir .'/wiki.php');
 
     $wiki = new Wiki;
     return $wiki->format($text,$courseid);
@@ -936,7 +936,7 @@ function markdown_to_html($text) {
 /// Given Markdown formatted text, make it into XHTML using external function
     global $CFG;
 
-    require_once("$CFG->libdir/markdown.php");
+    require_once($CFG->libdir .'/markdown.php');
 
     return Markdown($text);
 }
@@ -945,7 +945,7 @@ function html_to_text($html) {
 /// Given HTML text, make it into plain text using external function
     global $CFG;
 
-    require_once("$CFG->libdir/html2text.php");
+    require_once($CFG->libdir .'/html2text.php');
 
     return html2text($html);
 }
@@ -964,7 +964,7 @@ function convert_urls_into_links(&$text) {
 }
 
 function highlight($needle, $haystack, $case=0,
-                    $left_string="<span class=\"highlight\">", $right_string="</span>") {
+                    $left_string='<span class="highlight">', $right_string='</span>') {
 /// This function will highlight search words in a given string
 /// It cares about HTML and will not ruin links.  It's best to use
 /// this function after performing any conversions to HTML.
@@ -975,13 +975,13 @@ function highlight($needle, $haystack, $case=0,
     }
 
     $list_of_words = eregi_replace("[^-a-zA-Z0-9&']", " ", $needle);
-    $list_array = explode(" ", $list_of_words);
+    $list_array = explode(' ', $list_of_words);
     for ($i=0; $i<sizeof($list_array); $i++) {
         if (strlen($list_array[$i]) == 1) {
-            $list_array[$i] = "";
+            $list_array[$i] = '';
         }
     }
-    $list_of_words = implode(" ", $list_array);
+    $list_of_words = implode(' ', $list_array);
     $list_of_words_cp = $list_of_words;
     $final = array();
     preg_match_all('/<(.+?)>/is',$haystack,$list_of_words);
@@ -991,20 +991,20 @@ function highlight($needle, $haystack, $case=0,
     }
 
     $haystack = str_replace($final,array_keys($final),$haystack);
-    $list_of_words_cp = eregi_replace(" +", "|", $list_of_words_cp);
+    $list_of_words_cp = eregi_replace(' +', '|', $list_of_words_cp);
 
-    if ($list_of_words_cp{0}=="|") {
-        $list_of_words_cp{0} = "";
+    if ($list_of_words_cp{0}=='|') {
+        $list_of_words_cp{0} = '';
     }
-    if ($list_of_words_cp{strlen($list_of_words_cp)-1}=="|") {
-        $list_of_words_cp{strlen($list_of_words_cp)-1}="";
+    if ($list_of_words_cp{strlen($list_of_words_cp)-1}=='|') {
+        $list_of_words_cp{strlen($list_of_words_cp)-1}='';
     }
-    $list_of_words_cp = "(".trim($list_of_words_cp).")";
+    $list_of_words_cp = '('. trim($list_of_words_cp) .')';
 
     if (!$case){
-        $haystack = eregi_replace("$list_of_words_cp", "$left_string"."\\1"."$right_string", $haystack);
+        $haystack = eregi_replace($list_of_words_cp, $left_string ."\\1". $right_string, $haystack);
     } else {
-        $haystack = ereg_replace("$list_of_words_cp", "$left_string"."\\1"."$right_string", $haystack);
+        $haystack = ereg_replace($list_of_words_cp, $left_string ."\\1". $right_string, $haystack);
     }
     $haystack = str_replace(array_keys($final),$final,$haystack);
 
@@ -1024,7 +1024,7 @@ function highlightfast($needle, $haystack) {
         $parts[$key] = substr($haystack, $pos, strlen($part));
         $pos += strlen($part);
 
-        $parts[$key] .= "<span class=\"highlight\">".substr($haystack, $pos, strlen($needle))."</span>";
+        $parts[$key] .= '<span class="highlight">'.substr($haystack, $pos, strlen($needle)).'</span>';
         $pos += strlen($needle);
     }
 
@@ -1034,8 +1034,8 @@ function highlightfast($needle, $haystack) {
 
 /// STANDARD WEB PAGE PARTS ///////////////////////////////////////////////////
 
-function print_header ($title="", $heading="", $navigation="", $focus="", $meta="",
-                       $cache=true, $button="&nbsp;", $menu="", $usexml=false, $bodytags="") {
+function print_header ($title='', $heading='', $navigation='', $focus='', $meta='',
+                       $cache=true, $button='&nbsp;', $menu='', $usexml=false, $bodytags='') {
 // $title - appears top of window
 // $heading - appears top of page
 // $navigation - premade navigation string
@@ -1054,21 +1054,21 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
         $CFG->courselang = $course->lang;
     }
 
-    if (file_exists("$CFG->dirroot/theme/$CFG->theme/styles.php")) {
+    if (file_exists($CFG->dirroot .'/theme/'. $CFG->theme .'/styles.php')) {
         $styles = $CFG->stylesheet;
     } else {
-        $styles = "$CFG->wwwroot/theme/standard/styles.php";
+        $styles = $CFG->wwwroot .'/theme/standard/styles.php';
     }
 
-    if ($navigation == "home") {
+    if ($navigation == 'home') {
         $home = true;
-        $navigation = "";
+        $navigation = '';
     } else {
         $home = false;
     }
 
-    if ($button == "") {
-        $button = "&nbsp;";
+    if ($button == '') {
+        $button = '&nbsp;';
     }
 
     if (!$menu and $navigation) {
@@ -1078,9 +1078,9 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
             $wwwroot = str_replace('http','https',$CFG->wwwroot);
         }
         if (isset($USER->id)) {
-            $menu = "<font size=\"2\"><a target=\"$CFG->framename\" href=\"$wwwroot/login/logout.php\">".get_string("logout")."</a></font>";
+            $menu = '<font size="2"><a target="'. $CFG->framename .'" href="'. $wwwroot .'/login/logout.php">'. get_string('logout') .'</a></font>';
         } else {
-            $menu = "<font size=\"2\"><a target=\"$CFG->framename\" href=\"$wwwroot/login/index.php\">".get_string("login")."</a></font>";
+            $menu = '<font size="2"><a target="'. $CFG->framename .'" href="'. $wwwroot .'/login/index.php">'. get_string('login') .'</a></font>';
         }
     }
 
@@ -1109,26 +1109,26 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
     $meta = "<style type=\"text/css\">@import url($CFG->wwwroot/lib/editor/htmlarea.css);</style>\n$meta\n";
 
     if (!empty($CFG->unicode)) {
-        $encoding = "utf-8";
+        $encoding = 'utf-8';
     } else if (!empty($CFG->courselang)) {
-        $encoding = get_string("thischarset");
+        $encoding = get_string('thischarset');
         moodle_setlocale();
     } else {
         if (!empty($SESSION->encoding)) {
             $encoding = $SESSION->encoding;
         } else {
-            $SESSION->encoding = $encoding = get_string("thischarset");
+            $SESSION->encoding = $encoding = get_string('thischarset');
         }
     }
-    $meta = "<meta http-equiv=\"content-type\" content=\"text/html; charset=$encoding\" />\n$meta\n";
+    $meta = '<meta http-equiv="content-type" content="text/html; charset='. $encoding .'" />'. "\n". $meta ."\n";
     if (!$usexml) {
         @header('Content-type: text/html; charset='.$encoding);
     }
 
-    if ( get_string("thisdirection") == "rtl" ) {
-        $direction = " dir=\"rtl\"";
+    if ( get_string('thisdirection') == 'rtl' ) {
+        $direction = ' dir="rtl"';
     } else {
-        $direction = " dir=\"ltr\"";
+        $direction = ' dir="ltr"';
     }
 
     if (!$cache) {   // Do everything we can to prevent clients and proxies caching
@@ -1138,8 +1138,8 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
         @header('Cache-Control: post-check=0, pre-check=0', false);
         @header('Pragma: no-cache');
 
-        $meta .= "\n<meta http-equiv=\"pragma\" content=\"no-cache\" />";
-        $meta .= "\n<meta http-equiv=\"expires\" content=\"0\" />";
+        $meta .= "\n".'<meta http-equiv="pragma" content="no-cache" />';
+        $meta .= "\n".'<meta http-equiv="expires" content="0" />';
     }
 
     if ($usexml) {       // Added by Gustav Delius / Mad Alex for MathML output
@@ -1149,18 +1149,18 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
         if(!$mathplayer) {
             header('Content-Type: application/xhtml+xml');
         }
-        echo "<?xml version=\"1.0\" ?>\n";
+        echo '<?xml version="1.0" ?>'."\n";
         if (!empty($CFG->xml_stylesheets)) {
-            $stylesheets = explode(";", $CFG->xml_stylesheets);
+            $stylesheets = explode(';', $CFG->xml_stylesheets);
             foreach ($stylesheets as $stylesheet) {
-                echo "<?xml-stylesheet type=\"text/xsl\" href=\"$CFG->wwwroot/$stylesheet\" ?>\n";
+                echo '<?xml-stylesheet type="text/xsl" href="'. $CFG->wwwroot .'/'. $stylesheet .'" ?>' . "\n";
             }
         }
-        echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1";
+        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1';
         if (!empty($CFG->xml_doctype_extra)) {
-            echo " plus $CFG->xml_doctype_extra";
+            echo ' plus '. $CFG->xml_doctype_extra;
         }
-        echo "//" . strtoupper($currentlanguage) . "\" \"$CFG->xml_dtd\">\n";
+        echo '//' . strtoupper($currentlanguage) . '" "'. $CFG->xml_dtd .'">'."\n";
         $direction = " xmlns=\"http://www.w3.org/1999/xhtml\"
                        xmlns:math=\"http://www.w3.org/1998/Math/MathML\"
                        xml:lang=\"en\"
@@ -1168,8 +1168,8 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
                        $direction";
         if($mathplayer) {
             $meta .= '<object id="mathplayer" classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">' . "\n";
-            $meta .= "<!--comment required to prevent this becoming an empty tag-->\n";
-            $meta .= "</object>\n";
+            $meta .= '<!--comment required to prevent this becoming an empty tag-->'."\n";
+            $meta .= '</object>'."\n";
             $meta .= '<?import namespace="math" implementation="#mathplayer" ?>' . "\n";
         }
     }
@@ -1177,12 +1177,12 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
     $title = str_replace('"', '&quot;', $title);
     $title = strip_tags($title);
 
-    include ("$CFG->dirroot/theme/$CFG->theme/header.html");
+    include ($CFG->dirroot .'/theme/'. $CFG->theme .'/header.html');
 }
 
 
-function print_header_simple($title="", $heading="", $navigation="", $focus="", $meta="",
-                       $cache=true, $button="&nbsp;", $menu="", $usexml=false, $bodytags="") {
+function print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='',
+                       $cache=true, $button='&nbsp;', $menu='', $usexml=false, $bodytags='') {
 /// This version of print_header is simpler because the course name does not have to be
 /// provided explicitly in the strings. It can be used on the site page as in courses
 /// Eventually all print_header could be replaced by print_header_simple
@@ -1191,10 +1191,10 @@ function print_header_simple($title="", $heading="", $navigation="", $focus="",
 
     $shortname ='';
     if ($course->category) {
-        $shortname = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
+        $shortname = '<a href="../../course/view.php?id='. $course->id .'">'. $course->shortname .'</a> ->';
     }
 
-    print_header("$course->shortname: $title", "$course->fullname $heading", "$shortname $navigation", $focus, $meta,
+    print_header($course->shortname .': '. $title, $course->fullname .' '. $heading, $shortname .' '. $navigation, $focus, $meta,
                        $cache, $button, $menu, $usexml, $bodytags);
 }
 
@@ -1207,16 +1207,16 @@ function print_footer ($course=NULL, $usercourse=NULL) {
 
 /// Course links
     if ($course) {
-        if ($course == "home") {   // special case for site home page - please do not remove
-            $homelink  = "<p align=\"center\"><a title=\"moodle $CFG->release ($CFG->version)\" href=\"http://moodle.org/\" target=\"_blank\">";
-            $homelink .= "<br /><img width=\"100\" height=\"30\" src=\"pix/moodlelogo.gif\" border=\"0\" /></a></p>";
+        if ($course == 'home') {   // special case for site home page - please do not remove
+            $homelink  = '<p align="center"><a title="moodle '. $CFG->release .' ('. $CFG->version .')" href="http://moodle.org/" target="_blank">';
+            $homelink .= '<br /><img width="100" height="30" src="pix/moodlelogo.gif" border="0" /></a></p>';
             $course = get_site();
             $homepage = true;
         } else {
             $homelink = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>";
         }
     } else {
-        $homelink = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/\">".get_string("home")."</a>";
+        $homelink = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/\">".get_string('home').'</a>';
         $course = get_site();
     }
 
@@ -1227,26 +1227,26 @@ function print_footer ($course=NULL, $usercourse=NULL) {
 /// User links
     $loggedinas = user_login_string($usercourse, $USER);
 
-    include ("$CFG->dirroot/theme/$CFG->theme/footer.html");
+    include ($CFG->dirroot .'/theme/'. $CFG->theme .'/footer.html');
 }
 
-function style_sheet_setup($lastmodified=0, $lifetime=300, $themename="") {
+function style_sheet_setup($lastmodified=0, $lifetime=300, $themename='') {
 /// This function is called by stylesheets to set up the header
 /// approriately as well as the current path
 
     global $CFG;
 
-    header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");
-    header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT");
-    header("Cache-control: max_age = $lifetime");
-    header("Pragma: ");
-    header("Content-type: text/css");  // Correct MIME type
+    header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $lastmodified) . ' GMT');
+    header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $lifetime) . ' GMT');
+    header('Cache-control: max_age = '. $lifetime);
+    header('Pragma: ');
+    header('Content-type: text/css');  // Correct MIME type
 
     if (!empty($themename)) {
         $CFG->theme = $themename;
     }
 
-    return "$CFG->wwwroot/theme/$CFG->theme";
+    return $CFG->wwwroot .'/theme/'. $CFG->theme;
 
 }
 
@@ -1259,13 +1259,13 @@ function user_login_string($course, $user=NULL) {
     }
 
     if (isset($user->realuser)) {
-        if ($realuser = get_record("user", "id", $user->realuser)) {
+        if ($realuser = get_record('user', 'id', $user->realuser)) {
             $fullname = fullname($realuser, true);
             $realuserinfo = " [<a target=\"{$CFG->framename}\"
             href=\"$CFG->wwwroot/course/loginas.php?id=$course->id&amp;return=$realuser->id\">$fullname</a>] ";
         }
     } else {
-        $realuserinfo = "";
+        $realuserinfo = '';
     }
 
     if (empty($CFG->loginhttps)) {
@@ -1278,15 +1278,15 @@ function user_login_string($course, $user=NULL) {
         $fullname = fullname($user, true);
         $username = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id\">$fullname</a>";
         if (isguest($user->id)) {
-            $loggedinas = $realuserinfo.get_string("loggedinas", "moodle", "$username").
-                      " (<a target=\"{$CFG->framename}\" href=\"$wwwroot/login/index.php\">".get_string("login")."</a>)";
+            $loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username).
+                      " (<a target=\"{$CFG->framename}\" href=\"$wwwroot/login/index.php\">".get_string('login').'</a>)';
         } else {
-            $loggedinas = $realuserinfo.get_string("loggedinas", "moodle", "$username").
-                      " (<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</a>)";
+            $loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username).
+                      " (<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/login/logout.php\">".get_string('logout').'</a>)';
         }
     } else {
-        $loggedinas = get_string("loggedinnot", "moodle").
-                      " (<a target=\"{$CFG->framename}\" href=\"$wwwroot/login/index.php\">".get_string("login")."</a>)";
+        $loggedinas = get_string('loggedinnot', 'moodle').
+                      " (<a target=\"{$CFG->framename}\" href=\"$wwwroot/login/index.php\">".get_string('login').'</a>)';
     }
     return $loggedinas;
 }
@@ -1297,7 +1297,7 @@ function print_navigation ($navigation) {
 
    if ($navigation) {
        if (! $site = get_site()) {
-           $site->shortname = get_string("home");;
+           $site->shortname = get_string('home');;
        }
        $navigation = str_replace('->', '&raquo;', $navigation);
        echo "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/\">$site->shortname</a> &raquo; $navigation";
@@ -1305,19 +1305,19 @@ function print_navigation ($navigation) {
 }
 
 function print_headline($text, $size=2) {
-    echo "<b><font size=\"$size\">$text</font></b><br />\n";
+    echo '<b><font size="'. $size .'">'. $text .'</font></b><br />'."\n";
 }
 
-function print_heading($text, $align="center", $size=3) {
-    echo "<p align=\"$align\"><font size=\"$size\"><b>".stripslashes_safe($text)."</b></font></p>";
+function print_heading($text, $align='center', $size=3) {
+    echo '<p align="'. $align .'"><font size="'. $size .'"><b>'. stripslashes_safe($text) .'</b></font></p>';
 }
 
-function print_heading_with_help($text, $helppage, $module="moodle", $icon="") {
+function print_heading_with_help($text, $helppage, $module='moodle', $icon='') {
 // Centered heading with attached help button (same title text)
 // and optional icon attached
-    echo "<p align=\"center\"><font size=\"3\">$icon<b>".stripslashes_safe($text);
+    echo '<p align="center"><font size="3">'. $icon .'<b>'. stripslashes_safe($text);
     helpbutton($helppage, $text, $module);
-    echo "</b></font></p>";
+    echo '</b></font></p>';
 }
 
 function print_continue($link) {
@@ -1325,83 +1325,83 @@ function print_continue($link) {
     global $CFG;
 
     if (!$link) {
-        $link = $_SERVER["HTTP_REFERER"];
+        $link = $_SERVER['HTTP_REFERER'];
     }
 
-    print_heading("<a target=\"{$CFG->framename}\" href=\"$link\">".get_string("continue")."</a>");
+    print_heading('<a target="'. $CFG->framename .'" href="'. $link .'">'. get_string('continue').'</a>');
 }
 
 
-function print_simple_box($message, $align="", $width="", $color="#FFFFFF", $padding=5, $class="generalbox") {
+function print_simple_box($message, $align='', $width='', $color='#FFFFFF', $padding=5, $class='generalbox') {
     print_simple_box_start($align, $width, $color, $padding, $class);
     echo stripslashes_safe($message);
     print_simple_box_end();
 }
 
-function print_simple_box_start($align="", $width="", $color="#FFFFFF", $padding=5, $class="generalbox") {
+function print_simple_box_start($align='', $width='', $color='#FFFFFF', $padding=5, $class='generalbox') {
     global $THEME;
 
     if ($align) {
-        $align = "align=\"$align\"";
+        $align = 'align="'. $align .'"';
     }
     if ($width) {
-        $width = "width=\"$width\"";
+        $width = 'width="'. $width .'"';
     }
     echo "<table $align $width class=\"$class\" border=\"0\" cellpadding=\"$padding\" cellspacing=\"0\"><tr><td bgcolor=\"$color\" class=\"$class"."content\">";
 }
 
 function print_simple_box_end() {
-    echo "</td></tr></table>";
+    echo '</td></tr></table>';
 }
 
-function print_single_button($link, $options, $label="OK", $method="get") {
-    echo "<form action=\"$link\" method=\"$method\">";
+function print_single_button($link, $options, $label='OK', $method='get') {
+    echo '<form action="'. $link .'" method="'. $method .'">';
     if ($options) {
         foreach ($options as $name => $value) {
-            echo "<input type=\"hidden\" name=\"$name\" value=\"$value\" />";
+            echo '<input type="hidden" name="'. $name .'" value="'. $value .'" />';
         }
     }
-    echo "<input type=\"submit\" value=\"$label\" /></form>";
+    echo '<input type="submit" value="'. $label .'" /></form>';
 }
 
 function print_spacer($height=1, $width=1, $br=true) {
     global $CFG;
-    echo "<img height=\"$height\" width=\"$width\" src=\"$CFG->wwwroot/pix/spacer.gif\" alt=\"\" />";
+    echo '<img height="'. $height .'" width="'. $width .'" src="'. $CFG->wwwroot .'/pix/spacer.gif" alt="" />';
     if ($br) {
-        echo "<br />\n";
+        echo '<br />'."\n";
     }
 }
 
-function print_file_picture($path, $courseid=0, $height="", $width="", $link="") {
+function print_file_picture($path, $courseid=0, $height='', $width='', $link='') {
 // Given the path to a picture file in a course, or a URL,
 // this function includes the picture in the page.
     global $CFG;
 
     if ($height) {
-        $height = "height=\"$height\"";
+        $height = 'height="'. $height .'"';
     }
     if ($width) {
-        $width = "width=\"$width\"";
+        $width = 'width="'. $width .'"';
     }
     if ($link) {
-        echo "<a href=\"$link\">";
+        echo '<a href="'. $link .'">';
     }
-    if (substr(strtolower($path), 0, 7) == "http://") {
-        echo "<img border=\"0\" $height $width src=\"$path\" />";
+    if (substr(strtolower($path), 0, 7) == 'http://') {
+        echo '<img border="0" '.$height . $width .' src="'. $path .'" />';
 
     } else if ($courseid) {
-        echo "<img border=\"0\" $height $width src=\"";
+        echo '<img border="0" '. $height . $width .' src="';
         if ($CFG->slasharguments) {        // Use this method if possible for better caching
-            echo "$CFG->wwwroot/file.php/$courseid/$path";
+            echo $CFG->wwwroot .'/file.php/'. $courseid .'/'. $path;
         } else {
-            echo "$CFG->wwwroot/file.php?file=/$courseid/$path";
+            echo $CFG->wwwroot .'/file.php?file=/'. $courseid .'/'. $path;
         }
-        echo "\" />";
+        echo '" />';
     } else {
-        echo "Error: must pass URL or course";
+        echo 'Error: must pass URL or course';
     }
     if ($link) {
-        echo "</a>";
+        echo '</a>';
     }
 }
 
@@ -1409,31 +1409,31 @@ function print_user_picture($userid, $courseid, $picture, $large=false, $returns
     global $CFG;
 
     if ($link) {
-        $output = "<a href=\"$CFG->wwwroot/user/view.php?id=$userid&amp;course=$courseid\">";
+        $output = '<a href="'. $CFG->wwwroot .'/user/view.php?id='. $userid .'&amp;course='. $courseid .'">';
     } else {
-        $output = "";
+        $output = '';
     }
     if ($large) {
-        $file = "f1";
+        $file = 'f1';
         $size = 100;
     } else {
-        $file = "f2";
+        $file = 'f2';
         $size = 35;
     }
     if ($picture) {  // Print custom user picture
         if ($CFG->slasharguments) {        // Use this method if possible for better caching
-            $output .= "<img align=\"middle\" src=\"$CFG->wwwroot/user/pix.php/$userid/$file.jpg\"".
-                       " border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />";
+            $output .= '<img align="middle" src="'. $CFG->wwwroot .'/user/pix.php/'. $userid .'/'. $file.jpg .'"'.
+                       ' border="0" width="'. $size .'" height="'. $size .'" alt="" />';
         } else {
-            $output .= "<img align=\"middle\" src=\"$CFG->wwwroot/user/pix.php?file=/$userid/$file.jpg\"".
-                       " border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />";
+            $output .= '<img align="middle" src="'. $CFG->wwwroot .'/user/pix.php?file=/'. $userid .'/'. $file.jpg .'"'.
+                       ' border="0" width="'. $size .'" height="'. $size .'" alt="" />';
         }
     } else {         // Print default user pictures (use theme version if available)
         $output .= "<img align=\"middle\" src=\"$CFG->pixpath/u/$file.png\"".
                    " border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />";
     }
     if ($link) {
-        $output .= "</a>";
+        $output .= '</a>';
     }
 
     if ($returnstring) {
@@ -1456,25 +1456,25 @@ function print_user($user, $course) {
 
     if (empty($string)) {     // Cache all the strings for the rest of the page
 
-        $string->email       = get_string("email");
-        $string->location    = get_string("location");
-        $string->lastaccess  = get_string("lastaccess");
-        $string->activity    = get_string("activity");
-        $string->unenrol     = get_string("unenrol");
-        $string->loginas     = get_string("loginas");
-        $string->fullprofile = get_string("fullprofile");
-        $string->role        = get_string("role");
-        $string->name        = get_string("name");
-        $string->never       = get_string("never");
-
-        $datestring->day     = get_string("day");
-        $datestring->days    = get_string("days");
-        $datestring->hour    = get_string("hour");
-        $datestring->hours   = get_string("hours");
-        $datestring->min     = get_string("min");
-        $datestring->mins    = get_string("mins");
-        $datestring->sec     = get_string("sec");
-        $datestring->secs    = get_string("secs");
+        $string->email       = get_string('email');
+        $string->location    = get_string('location');
+        $string->lastaccess  = get_string('lastaccess');
+        $string->activity    = get_string('activity');
+        $string->unenrol     = get_string('unenrol');
+        $string->loginas     = get_string('loginas');
+        $string->fullprofile = get_string('fullprofile');
+        $string->role        = get_string('role');
+        $string->name        = get_string('name');
+        $string->never       = get_string('never');
+
+        $datestring->day     = get_string('day');
+        $datestring->days    = get_string('days');
+        $datestring->hour    = get_string('hour');
+        $datestring->hours   = get_string('hours');
+        $datestring->min     = get_string('min');
+        $datestring->mins    = get_string('mins');
+        $datestring->sec     = get_string('sec');
+        $datestring->secs    = get_string('secs');
 
         $countries = get_list_of_countries();
 
@@ -1492,13 +1492,13 @@ function print_user($user, $course) {
     echo '<font size="3"><b>'.fullname($user, $isteacher).'</b></font>';
     echo '<p>';
     if (!empty($user->role) and ($user->role <> $course->teacher)) {
-        echo "$string->role: $user->role<br />";
+        echo $string->role .': '. $user->role .'<br />';
     }
     if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category and !isguest()) or $isteacher) {
-        echo "$string->email: <a href=\"mailto:$user->email\">$user->email</a><br />";
+        echo $string->email .': <a href="mailto:'. $user->email .'">'. $user->email .'</a><br />';
     }
     if ($user->city or $user->country) {
-        echo "$string->location: ";
+        echo $string->location .': ';
         if ($user->city) {
             echo $user->city;
         }
@@ -1508,30 +1508,30 @@ function print_user($user, $course) {
             }
             echo $countries[$user->country];
         }
-        echo "<br />";
+        echo '<br />';
     }
     if ($user->lastaccess) {
-        echo "$string->lastaccess: ".userdate($user->lastaccess);
-        echo "&nbsp (".format_time(time() - $user->lastaccess, $datestring).")";
+        echo $string->lastaccess .': '. userdate($user->lastaccess);
+        echo '&nbsp ('. format_time(time() - $user->lastaccess, $datestring) .')';
     } else {
-        echo "$string->lastaccess: $string->never";
+        echo $string->lastaccess .': '. $string->never;
     }
     echo '</td><td valign="bottom" bgcolor="#ffffff" nowrap="nowrap" class="userinfoboxlinkcontent">';
 
     echo '<font size="1">';
     if ($isteacher) {
         $timemidnight = usergetmidnight(time());
-        echo "<a href=\"$CFG->wwwroot/course/user.php?id=$course->id&amp;user=$user->id\">$string->activity</a><br />";
+        echo '<a href="'. $CFG->wwwroot .'/course/user.php?id='. $course->id .'&amp;user='. $user->id .'">'. $string->activity .'</a><br />';
         if (!iscreator($user->id) or ($isadmin and !isadmin($user->id))) {  // Includes admins
             if ($course->category and isteacheredit($course->id) and isstudent($course->id, $user->id)) {  // Includes admins
-                echo "<a href=\"$CFG->wwwroot/course/unenrol.php?id=$course->id&amp;user=$user->id\">$string->unenrol</a><br />";
+                echo '<a href="'. $CFG->wwwroot .'/course/unenrol.php?id='. $course->id .'&amp;user='. $user->id .'">'. $string->unenrol .'</a><br />';
             }
             if ($USER->id != $user->id) {
-                echo "<a href=\"$CFG->wwwroot/course/loginas.php?id=$course->id&amp;user=$user->id\">$string->loginas</a><br />";
+                echo '<a href="'. $CFG->wwwroot .'/course/loginas.php?id='. $course->id .'&amp;user='. $user->id .'">'. $string->loginas .'</a><br />';
             }
         }
     }
-    echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id\">$string->fullprofile...</a>";
+    echo '<a href="'. $CFG->wwwroot .'/user/view.php?id='. $user->id .'&amp;course='. $course->id .'">'. $string->fullprofile .'...</a>';
     echo '</font>';
 
     echo '</td></tr></table>';
@@ -1552,15 +1552,15 @@ function print_group_picture($group, $courseid, $large=false, $returnstring=fals
     }
 
     if ($link or $isteacheredit) {
-        $output = "<a href=\"$CFG->wwwroot/course/group.php?id=$courseid&amp;group=$group->id\">";
+        $output = '<a href="'. $CFG->wwwroot .'/course/group.php?id='. $courseid .'&amp;group='. $group->id .'">';
     } else {
         $output = '';
     }
     if ($large) {
-        $file = "f1";
+        $file = 'f1';
         $size = 100;
     } else {
-        $file = "f2";
+        $file = 'f2';
         $size = 35;
     }
     if ($group->picture) {  // Print custom group picture
@@ -1573,7 +1573,7 @@ function print_group_picture($group, $courseid, $large=false, $returnstring=fals
         }
     }
     if ($link or $isteacheredit) {
-        $output .= "</a>";
+        $output .= '</a>';
     }
 
     if ($returnstring) {
@@ -1627,88 +1627,88 @@ function print_table($table) {
     if (isset($table->align)) {
         foreach ($table->align as $key => $aa) {
             if ($aa) {
-                $align[$key] = " align=\"$aa\"";
+                $align[$key] = ' align="'. $aa .'"';
             } else {
-                $align[$key] = "";
+                $align[$key] = '';
             }
         }
     }
     if (isset($table->size)) {
         foreach ($table->size as $key => $ss) {
             if ($ss) {
-                $size[$key] = " width=\"$ss\"";
+                $size[$key] = ' width="'. $ss .'"';
             } else {
-                $size[$key] = "";
+                $size[$key] = '';
             }
         }
     }
     if (isset($table->wrap)) {
         foreach ($table->wrap as $key => $ww) {
             if ($ww) {
-                $wrap[$key] = " nowrap=\"nowrap\" ";
+                $wrap[$key] = ' nowrap="nowrap" ';
             } else {
-                $wrap[$key] = "";
+                $wrap[$key] = '';
             }
         }
     }
 
     if (empty($table->width)) {
-        $table->width = "80%";
+        $table->width = '80%';
     }
 
     if (empty($table->cellpadding)) {
-        $table->cellpadding = "5";
+        $table->cellpadding = '5';
     }
 
     if (empty($table->cellspacing)) {
-        $table->cellspacing = "1";
+        $table->cellspacing = '1';
     }
 
-    print_simple_box_start("center", "$table->width", "#ffffff", 0);
-    echo "<table width=\"100%\" border=\"0\" align=\"center\" ";
+    print_simple_box_start('center', $table->width, '#ffffff', 0);
+    echo '<table width="100%" border="0" align="center" ';
     echo " cellpadding=\"$table->cellpadding\" cellspacing=\"$table->cellspacing\" class=\"generaltable\">\n";
 
     $countcols = 0;
 
     if (!empty($table->head)) {
         $countcols = count($table->head);;
-        echo "<tr>";
+        echo '<tr>';
         foreach ($table->head as $key => $heading) {
 
             if (!isset($size[$key])) {
-                $size[$key] = "";
+                $size[$key] = '';
             }
             if (!isset($align[$key])) {
-                $align[$key] = "";
+                $align[$key] = '';
             }
-            echo "<th valign=\"top\" ".$align[$key].$size[$key]." nowrap=\"nowrap\" class=\"generaltableheader\">$heading</th>";
+            echo '<th valign="top" '. $align[$key].$size[$key] .' nowrap="nowrap" class="generaltableheader">'. $heading .'</th>';
         }
-        echo "</tr>\n";
+        echo '</tr>'."\n";
     }
 
     if (!empty($table->data)) {
         foreach ($table->data as $row) {
-            echo "<tr valign=\"top\">";
-            if ($row == "hr" and $countcols) {
-                echo "<td colspan=\"$countcols\"><div class=\"tabledivider\"></div></td>";
+            echo '<tr valign="top">';
+            if ($row == 'hr' and $countcols) {
+                echo '<td colspan="'. $countcols .'"><div class="tabledivider"></div></td>';
             } else {  /// it's a normal row of data
                 foreach ($row as $key => $item) {
                     if (!isset($size[$key])) {
-                        $size[$key] = "";
+                        $size[$key] = '';
                     }
                     if (!isset($align[$key])) {
-                        $align[$key] = "";
+                        $align[$key] = '';
                     }
                     if (!isset($wrap[$key])) {
-                        $wrap[$key] = "";
+                        $wrap[$key] = '';
                     }
-                    echo "<td ".$align[$key].$size[$key].$wrap[$key]." class=\"generaltablecell\">$item</td>";
+                    echo '<td '. $align[$key].$size[$key].$wrap[$key] .' class="generaltablecell">'. $item .'</td>';
                 }
             }
-            echo "</tr>\n";
+            echo '</tr>'."\n";
         }
     }
-    echo "</table>\n";
+    echo '</table>'."\n";
     print_simple_box_end();
 
     return true;
@@ -1732,96 +1732,96 @@ function make_table($table) {
     if (isset($table->align)) {
         foreach ($table->align as $key => $aa) {
             if ($aa) {
-                $align[$key] = " align=\"$aa\"";
+                $align[$key] = ' align="'. $aa .'"';
             } else {
-                $align[$key] = "";
+                $align[$key] = '';
             }
         }
     }
     if (isset($table->size)) {
         foreach ($table->size as $key => $ss) {
             if ($ss) {
-                $size[$key] = " width=\"$ss\"";
+                $size[$key] = ' width="'. $ss .'"';
             } else {
-                $size[$key] = "";
+                $size[$key] = '';
             }
         }
     }
     if (isset($table->wrap)) {
         foreach ($table->wrap as $key => $ww) {
             if ($ww) {
-                $wrap[$key] = " nowrap=\"nowrap\" ";
+                $wrap[$key] = ' nowrap="nowrap" ';
             } else {
-                $wrap[$key] = "";
+                $wrap[$key] = '';
             }
         }
     }
 
     if (empty($table->width)) {
-        $table->width = "80%";
+        $table->width = '80%';
     }
 
     if (empty($table->tablealign)) {
-        $table->tablealign = "center";
+        $table->tablealign = 'center';
     }
 
     if (empty($table->cellpadding)) {
-        $table->cellpadding = "5";
+        $table->cellpadding = '5';
     }
 
     if (empty($table->cellspacing)) {
-        $table->cellspacing = "1";
+        $table->cellspacing = '1';
     }
 
     if (empty($table->class)) {
-        $table->class = "generaltable";
+        $table->class = 'generaltable';
     }
 
     if (empty($table->fontsize)) {
-        $fontsize = "";
+        $fontsize = '';
     } else {
-        $fontsize = "<font size=\"$table->fontsize\">";
+        $fontsize = '<font size="'. $table->fontsize .'">';
     }
 
-    $output =  "<table width=\"$table->width\" valign=\"top\" align=\"$table->tablealign\" ";
-    $output .= " cellpadding=\"$table->cellpadding\" cellspacing=\"$table->cellspacing\" class=\"$table->class\">\n";
+    $output =  '<table width="'. $table->width .'" valign="top" align="'. $table->tablealign .'" ';
+    $output .= ' cellpadding="'. $table->cellpadding .'" cellspacing="'. $table->cellspacing .'" class="'. $table->class .'">'."\n";
 
     if (!empty($table->head)) {
-        $output .= "<tr>";
+        $output .= '<tr>';
         foreach ($table->head as $key => $heading) {
             if (!isset($size[$key])) {
-                $size[$key] = "";
+                $size[$key] = '';
             }
             if (!isset($align[$key])) {
-                $align[$key] = "";
+                $align[$key] = '';
             }
-            $output .= "<th valign=\"top\" ".$align[$key].$size[$key]." nowrap=\"nowrap\" class=\"{$table->class}header\">$fontsize$heading</th>";
+            $output .= '<th valign="top" '. $align[$key].$size[$key] .' nowrap="nowrap" class="'. $table->class .'header">'.$fontsize.$heading.'</th>';
         }
-        $output .= "</tr>\n";
+        $output .= '</tr>'."\n";
     }
 
     foreach ($table->data as $row) {
-        $output .= "<tr valign=\"top\">";
+        $output .= '<tr valign="top">';
         foreach ($row as $key => $item) {
             if (!isset($size[$key])) {
-                $size[$key] = "";
+                $size[$key] = '';
             }
             if (!isset($align[$key])) {
-                $align[$key] = "";
+                $align[$key] = '';
             }
             if (!isset($wrap[$key])) {
-                $wrap[$key] = "";
+                $wrap[$key] = '';
             }
-            $output .= "<td ".$align[$key].$size[$key].$wrap[$key]." class=\"{$table->class}cell\">$fontsize$item</td>";
+            $output .= '<td '. $align[$key].$size[$key].$wrap[$key] .' class="'. $table->class .'cell">'. $fontsize . $item .'</td>';
         }
-        $output .= "</tr>\n";
+        $output .= '</tr>'."\n";
     }
-    $output .= "</table>\n";
+    $output .= '</table>'."\n";
 
     return $output;
 }
 
-function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value="", $courseid=0) {
+function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0) {
 /// Prints a basic textarea field
 /// $width and height are legacy fields and no longer used
 
@@ -1835,13 +1835,13 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
 
     if ($usehtmleditor) {
         if (!empty($courseid) and isteacher($courseid)) {
-            echo "<script type=\"text/javascript\" src=\"$CFG->wwwroot/lib/editor/htmlarea.php?id=$courseid\"></script>\n";
+            echo '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/htmlarea.php?id='. $courseid .'"></script>'."\n";
         } else {
-            echo "<script type=\"text/javascript\" src=\"$CFG->wwwroot/lib/editor/htmlarea.php\"></script>\n";
+            echo '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/htmlarea.php"></script>'."\n";
         }
-        echo "<script type=\"text/javascript\" src=\"$CFG->wwwroot/lib/editor/dialog.js\"></script>\n";
-        echo "<script type=\"text/javascript\" src=\"$CFG->wwwroot/lib/editor/lang/en.php\"></script>\n";
-        echo "<script type=\"text/javascript\" src=\"$CFG->wwwroot/lib/editor/popupwin.js\"></script>\n";
+        echo '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/dialog.js"></script>'."\n";
+        echo '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/lang/en.php"></script>'."\n";
+        echo '<script type="text/javascript" src="'. $CFG->wwwroot .'/lib/editor/popupwin.js"></script>'."\n";
 
         if ($rows < 10) {
             $rows = 10;
@@ -1853,15 +1853,15 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
 
     echo "<textarea id=\"$name\" name=\"$name\" rows=\"$rows\" cols=\"$cols\">";
     p($value);
-    echo "</textarea>\n";
+    echo '</textarea>'."\n";
 }
 
-function print_richedit_javascript($form, $name, $source="no") {
+function print_richedit_javascript($form, $name, $source='no') {
 /// Legacy function, provided for backward compatability
     use_html_editor($name);
 }
 
-function use_html_editor($name="") {
+function use_html_editor($name='') {
 /// Sets up the HTML editor on textareas in the current page.
 /// If a field name is provided, then it will only be
 /// applied to that field - otherwise it will be used
@@ -1869,14 +1869,14 @@ function use_html_editor($name="") {
 ///
 /// In most cases no arguments need to be supplied
 
-    echo "<script language=\"javascript\" type=\"text/javascript\" defer=\"defer\">\n";
+    echo '<script language="javascript" type="text/javascript" defer="defer">'."\n";
     print_editor_config();
     if (empty($name)) {
-        echo "\nHTMLArea.replaceAll(config);\n";
+        echo "\n".'HTMLArea.replaceAll(config);'."\n";
     } else {
         echo "\nHTMLArea.replace('$name', config);\n";
     }
-    echo "</script>\n";
+    echo '</script>'."\n";
 }
 
 
@@ -1886,11 +1886,11 @@ function update_course_icon($courseid) {
 
     if (isteacheredit($courseid)) {
         if (!empty($USER->editing)) {
-            $string = get_string("turneditingoff");
-            $edit = "off";
+            $string = get_string('turneditingoff');
+            $edit = 'off';
         } else {
-            $string = get_string("turneditingon");
-            $edit = "on";
+            $string = get_string('turneditingon');
+            $edit = 'on';
         }
         return "<form target=\"$CFG->framename\" method=\"get\" action=\"$CFG->wwwroot/course/view.php\">".
                "<input type=\"hidden\" name=\"id\" value=\"$courseid\" />".
@@ -1904,13 +1904,13 @@ function update_module_button($moduleid, $courseid, $string) {
     global $CFG;
 
     if (isteacheredit($courseid)) {
-        $string = get_string("updatethis", "", $string);
+        $string = get_string('updatethis', '', $string);
         return "<form target=\"$CFG->framename\" method=\"get\" action=\"$CFG->wwwroot/course/mod.php\">".
                "<input type=\"hidden\" name=\"update\" value=\"$moduleid\" />".
                "<input type=\"hidden\" name=\"return\" value=\"true\" />".
                "<input type=\"submit\" value=\"$string\" /></form>";
     } else {
-        return "";
+        return '';
     }
 }
 
@@ -1920,11 +1920,11 @@ function update_category_button($categoryid) {
 
     if (iscreator()) {
         if (!empty($USER->categoryediting)) {
-            $string = get_string("turneditingoff");
-            $edit = "off";
+            $string = get_string('turneditingoff');
+            $edit = 'off';
         } else {
-            $string = get_string("turneditingon");
-            $edit = "on";
+            $string = get_string('turneditingon');
+            $edit = 'on';
         }
         return "<form target=\"$CFG->framename\" method=\"get\" action=\"$CFG->wwwroot/course/category.php\">".
                "<input type=\"hidden\" name=\"id\" value=\"$categoryid\" />".
@@ -1939,11 +1939,11 @@ function update_categories_button() {
 
     if (isadmin()) {
         if (!empty($USER->categoriesediting)) {
-            $string = get_string("turneditingoff");
-            $edit = "off";
+            $string = get_string('turneditingoff');
+            $edit = 'off';
         } else {
-            $string = get_string("turneditingon");
-            $edit = "on";
+            $string = get_string('turneditingon');
+            $edit = 'on';
         }
         return "<form target=\"$CFG->framename\" method=\"get\" action=\"$CFG->wwwroot/course/index.php\">".
                "<input type=\"hidden\" name=\"edit\" value=\"$edit\" />".
@@ -1971,11 +1971,11 @@ function update_groups_button($courseid) {
 
     if (isteacheredit($courseid)) {
         if (!empty($USER->groupsediting)) {
-            $string = get_string("turneditingoff");
-            $edit = "off";
+            $string = get_string('turneditingoff');
+            $edit = 'off';
         } else {
-            $string = get_string("turneditingon");
-            $edit = "on";
+            $string = get_string('turneditingon');
+            $edit = 'on';
         }
         return "<form target=\"$CFG->framename\" method=\"get\" action=\"$CFG->wwwroot/course/groups.php\">".
                "<input type=\"hidden\" name=\"id\" value=\"$courseid\" />".
@@ -1988,7 +1988,7 @@ function print_group_menu($groups, $groupmode, $currentgroup, $urlroot) {
 /// Prints an appropriate group selection menu
 
 /// Add an "All groups" to the start of the menu
-    $groupsmenu[0] = get_string("allparticipants");
+    $groupsmenu[0] = get_string('allparticipants');
     foreach ($groups as $key => $groupname) {
         $groupsmenu[$key] = $groupname;
     }
@@ -2001,13 +2001,13 @@ function print_group_menu($groups, $groupmode, $currentgroup, $urlroot) {
     }
     echo ':';
     echo '</td><td nowrap="nowrap" align="left">';
-    popup_form($urlroot.'&amp;group=', $groupsmenu, 'selectgroup', $currentgroup, "", "", "", false, "self");
+    popup_form($urlroot.'&amp;group=', $groupsmenu, 'selectgroup', $currentgroup, '', '', '', false, 'self');
     echo '</tr></table>';
 
 }
 
 
-function navmenu($course, $cm=NULL, $targetwindow="self") {
+function navmenu($course, $cm=NULL, $targetwindow='self') {
 // Given a course and a (current) coursemodule
 // This function returns a small popup menu with all the
 // course activity modules in it, as a navigation menu
@@ -2021,18 +2021,18 @@ function navmenu($course, $cm=NULL, $targetwindow="self") {
     }
 
     if ($course->format == 'weeks') {
-        $strsection = get_string("week");
+        $strsection = get_string('week');
     } else {
-        $strsection = get_string("topic");
+        $strsection = get_string('topic');
     }
 
     if (!$modinfo = unserialize($course->modinfo)) {
-        return "";
+        return '';
     }
     $isteacher = isteacher($course->id);
     $section = -1;
-    $selected = "";
-    $url = "";
+    $selected = '';
+    $url = '';
     $previousmod = NULL;
     $backmod = NULL;
     $nextmod = NULL;
@@ -2042,10 +2042,10 @@ function navmenu($course, $cm=NULL, $targetwindow="self") {
     $menu = array();
     $strjumpto = get_string('jumpto');
 
-    $sections = get_records('course_sections','course',$course->id,'section',"section,visible,summary");
+    $sections = get_records('course_sections','course',$course->id,'section','section,visible,summary');
 
     foreach ($modinfo as $mod) {
-        if ($mod->mod == "label") {
+        if ($mod->mod == 'label') {
             continue;
         }
 
@@ -2055,7 +2055,7 @@ function navmenu($course, $cm=NULL, $targetwindow="self") {
             if ($thissection->visible or !$course->hiddensections or $isteacher) {
                 $thissection->summary = strip_tags($thissection->summary);
                 if ($course->format == 'weeks' or empty($thissection->summary)) {
-                    $menu[] = "-------------- $strsection $mod->section --------------";
+                    $menu[] = '-------------- '. $strsection ." ". $mod->section .' --------------';
                 } else {
                     if (strlen($thissection->summary) < 47) {
                         $menu[] = '-- '.$thissection->summary;
@@ -2070,7 +2070,7 @@ function navmenu($course, $cm=NULL, $targetwindow="self") {
 
         //Only add visible or teacher mods to jumpmenu
         if ($mod->visible or $isteacher) {
-            $url = "$mod->mod/view.php?id=$mod->cm";
+            $url = $mod->mod .'/view.php?id='. $mod->cm;
             if ($flag) { // the current mod is the "next" mod
                 $nextmod = $mod;
                 $flag = false;
@@ -2085,10 +2085,10 @@ function navmenu($course, $cm=NULL, $targetwindow="self") {
             } else {
                 $mod->name = strip_tags(urldecode($mod->name));
                 if (strlen($mod->name) > 55) {
-                    $mod->name = substr($mod->name, 0, 50)."...";
+                    $mod->name = substr($mod->name, 0, 50).'...';
                 }
                 if (!$mod->visible) {
-                    $mod->name = "(".$mod->name.")";
+                    $mod->name = '('.$mod->name.')';
                 }
             }
             $menu[$url] = $mod->name;
@@ -2111,10 +2111,10 @@ function navmenu($course, $cm=NULL, $targetwindow="self") {
                    "<input type=\"hidden\" name=\"id\" value=\"$nextmod->cm\" />".
                    "<input type=\"submit\" value=\"&gt;\" /></form>";
     }
-    return "<table><tr>$logslink<td>$backmod</td><td>" .
-            popup_form("$CFG->wwwroot/mod/", $menu, "navmenu", $selected, $strjumpto,
-                       "", "", true, $targetwindow).
-            "</td><td>$nextmod</td></tr></table>";
+    return '<table><tr>'.$logslink .'<td>'. $backmod .'</td><td>' .
+            popup_form($CFG->wwwroot .'/mod/', $menu, 'navmenu', $selected, $strjumpto,
+                       '', '', true, $targetwindow).
+            '</td><td>'. $nextmod .'</td></tr></table>';
 }
 
 
@@ -2128,7 +2128,7 @@ function print_date_selector($day, $month, $year, $currenttime=0) {
     $currentdate = usergetdate($currenttime);
 
     for ($i=1; $i<=31; $i++) {
-        $days[$i] = "$i";
+        $days[$i] = $i;
     }
     for ($i=1; $i<=12; $i++) {
         $months[$i] = userdate(gmmktime(12,0,0,$i,1,2000), "%B");
@@ -2136,9 +2136,9 @@ function print_date_selector($day, $month, $year, $currenttime=0) {
     for ($i=2000; $i<=2010; $i++) {
         $years[$i] = $i;
     }
-    choose_from_menu($days,   $day,   $currentdate['mday'], "");
-    choose_from_menu($months, $month, $currentdate['mon'],  "");
-    choose_from_menu($years,  $year,  $currentdate['year'], "");
+    choose_from_menu($days,   $day,   $currentdate['mday'], '');
+    choose_from_menu($months, $month, $currentdate['mon'],  '');
+    choose_from_menu($years,  $year,  $currentdate['year'], '');
 }
 
 function print_time_selector($hour, $minute, $currenttime=0, $step=5) {
@@ -2158,11 +2158,11 @@ function print_time_selector($hour, $minute, $currenttime=0, $step=5) {
     for ($i=0; $i<=59; $i+=$step) {
         $minutes[$i] = sprintf("%02d",$i);
     }
-    choose_from_menu($hours,   $hour,   $currentdate['hours'],   "");
-    choose_from_menu($minutes, $minute, $currentdate['minutes'], "");
+    choose_from_menu($hours,   $hour,   $currentdate['hours'],   '');
+    choose_from_menu($minutes, $minute, $currentdate['minutes'], '');
 }
 
-function print_timer_selector($timelimit = 0, $unit = "") {
+function print_timer_selector($timelimit = 0, $unit = '') {
 /// Prints time limit value selector
 
     global $CFG;
@@ -2177,7 +2177,7 @@ function print_timer_selector($timelimit = 0, $unit = "") {
     for ($i=1; $i<=$maxvalue; $i++) {
         $minutes[$i] = $i.$unit;
     }
-    choose_from_menu($minutes, "timelimit", $timelimit, get_string("none"));
+    choose_from_menu($minutes, 'timelimit', $timelimit, get_string('none'));
 }
 
 function print_grade_menu($courseid, $name, $current, $includenograde=true) {
@@ -2186,24 +2186,24 @@ function print_grade_menu($courseid, $name, $current, $includenograde=true) {
 
     global $CFG;
 
-    $strscale = get_string("scale");
-    $strscales = get_string("scales");
+    $strscale = get_string('scale');
+    $strscales = get_string('scales');
 
     $scales = get_scales_menu($courseid);
     foreach ($scales as $i => $scalename) {
-        $grades[-$i] = "$strscale: $scalename";
+        $grades[-$i] = $strscale .': '. $scalename;
     }
     if ($includenograde) {
-        $grades[0] = get_string("nograde");
+        $grades[0] = get_string('nograde');
     }
     for ($i=100; $i>=1; $i--) {
         $grades[$i] = $i;
     }
-    choose_from_menu($grades, "$name", "$current", "");
+    choose_from_menu($grades, $name, $current, '');
 
-    $helpicon = "$CFG->pixpath/help.gif";
+    $helpicon = $CFG->pixpath .'/help.gif';
     $linkobject = "<img align=\"middle\" border=\"0\" height=\"17\" width=\"22\" alt=\"$strscales\" src=\"$helpicon\" />";
-    link_to_popup_window ("/course/scales.php?id=$courseid&amp;list=true", "ratingscales",
+    link_to_popup_window ('/course/scales.php?id='. $courseid .'&amp;list=true', 'ratingscales',
                           $linkobject, 400, 500, $strscales);
 }
 
@@ -2213,11 +2213,11 @@ function print_scale_menu($courseid, $name, $current) {
 
     global $CFG;
 
-    $strscales = get_string("scales");
-    choose_from_menu(get_scales_menu($courseid), "$name", $current, "");
-    $helpicon = "$CFG->pixpath/help.gif";
+    $strscales = get_string('scales');
+    choose_from_menu(get_scales_menu($courseid), $name, $current, '');
+    $helpicon = $CFG->pixpath .'/help.gif';
     $linkobject = "<img align=\"middle\" border=\"0\" height=\"17\" width=\"22\" alt=\"$strscales\" src=\"$helpicon\" />";
-    link_to_popup_window ("/course/scales.php?id=$courseid&amp;list=true", "ratingscales",
+    link_to_popup_window ('/course/scales.php?id='. $courseid .'&amp;list=true', 'ratingscales',
                           $linkobject, 400, 500, $strscales);
 }
 
@@ -2228,27 +2228,27 @@ function print_scale_menu_helpbutton($courseid, $scale) {
 
     global $CFG;
 
-    $strscales = get_string("scales");
-    $helpicon = "$CFG->pixpath/help.gif";
+    $strscales = get_string('scales');
+    $helpicon = $CFG->pixpath .'/help.gif';
     $linkobject = "<img align=\"middle\" border=\"0\" height=\"17\" width=\"22\" alt=\"$scale->name\" src=\"$helpicon\" />";
-    link_to_popup_window ("/course/scales.php?id=$courseid&amp;list=true&amp;scale=$scale->id", "ratingscale",
+    link_to_popup_window ('/course/scales.php?id='. $courseid .'&amp;list=true&amp;scale='. $scale->id, 'ratingscale',
                           $linkobject, 400, 500, $scale->name);
 }
 
 
-function error ($message, $link="") {
+function error ($message, $link='') {
     global $CFG, $SESSION;
 
-    print_header(get_string("error"));
-    echo "<br />";
-    print_simple_box($message, "center", "", "#FFBBBB");
+    print_header(get_string('error'));
+    echo '<br />';
+    print_simple_box($message, 'center', '', '#FFBBBB');
 
     if (!$link) {
         if ( !empty($SESSION->fromurl) ) {
-            $link = "$SESSION->fromurl";
+            $link = $SESSION->fromurl;
             unset($SESSION->fromurl);
         } else {
-            $link = "$CFG->wwwroot/";
+            $link = $CFG->wwwroot .'/';
         }
     }
     print_continue($link);
@@ -2256,7 +2256,7 @@ function error ($message, $link="") {
     die;
 }
 
-function helpbutton ($page, $title="", $module="moodle", $image=true, $linktext=false, $text="", $return=false) {
+function helpbutton ($page, $title='', $module='moodle', $image=true, $linktext=false, $text='', $return=false) {
     // $page = the keyword that defines a help page
     // $title = the title of links, rollover tips, alt tags etc
     // $module = which module is the page defined in
@@ -2265,12 +2265,12 @@ function helpbutton ($page, $title="", $module="moodle", $image=true, $linktext=
     //         the $page variable is ignored.
     global $CFG, $THEME;
 
-    if ($module == "") {
-        $module = "moodle";
+    if ($module == '') {
+        $module = 'moodle';
     }
 
     if ($image) {
-        $icon = "$CFG->pixpath/help.gif";
+        $icon = $CFG->pixpath .'/help.gif';
         if ($linktext) {
             $linkobject = "<span style=\"cursor:help;\">$title<img align=\"middle\" border=\"0\" ".
                           " height=\"17\" width=\"22\" alt=\"\" src=\"$icon\" /></span>";
@@ -2279,15 +2279,15 @@ function helpbutton ($page, $title="", $module="moodle", $image=true, $linktext=
                           " alt=\"$title\" style=\"cursor:help;\" src=\"$icon\" />";
         }
     } else {
-        $linkobject = "<span style=\"cursor:help;\">$title</span>";
+        $linkobject = '<span style="cursor:help;">'. $title .'</span>';
     }
     if ($text) {
-        $url = "/help.php?module=$module&amp;text=".htmlentities(urlencode($text));
+        $url = '/help.php?module='. $module .'&amp;text='. htmlentities(urlencode($text));
     } else {
-        $url = "/help.php?module=$module&amp;file=$page.html";
+        $url = '/help.php?module='. $module .'&amp;file='. $page .'.html';
     }
 
-    $link = link_to_popup_window ($url, "popup", $linkobject, 400, 500, $title, 'none', true);
+    $link = link_to_popup_window ($url, 'popup', $linkobject, 400, 500, $title, 'none', true);
 
     if ($return) {
         return $link;
@@ -2302,28 +2302,28 @@ function emoticonhelpbutton($form, $field) {
 
     $SESSION->inserttextform = $form;
     $SESSION->inserttextfield = $field;
-    helpbutton("emoticons", get_string("helpemoticons"), "moodle", false, true);
-    echo "&nbsp;";
-    link_to_popup_window ("/help.php?module=moodle&amp;file=emoticons.html", "popup",
+    helpbutton('emoticons', get_string('helpemoticons'), 'moodle', false, true);
+    echo '&nbsp;';
+    link_to_popup_window ('/help.php?module=moodle&amp;file=emoticons.html', 'popup',
                           "<img src=\"$CFG->pixpath/s/smiley.gif\" border=\"0\" align=\"middle\" width=\"15\" height=\"15\" alt=\"\" />",
-                           400, 500, get_string("helpemoticons"));
-    echo "<br />";
+                           400, 500, get_string('helpemoticons'));
+    echo '<br />';
 }
 
-function notice ($message, $link="") {
+function notice ($message, $link='') {
     global $CFG, $THEME;
 
     if (!$link) {
-        if (!empty($_SERVER["HTTP_REFERER"])) {
-            $link = $_SERVER["HTTP_REFERER"];
+        if (!empty($_SERVER['HTTP_REFERER'])) {
+            $link = $_SERVER['HTTP_REFERER'];
         } else {
-            $link = "$CFG->wwwroot/";
+            $link = $CFG->wwwroot .'/';
         }
     }
 
-    echo "<br />";
-    print_simple_box($message, "center", "50%", "$THEME->cellheading", "20", "noticebox");
-    print_heading("<a href=\"$link\">".get_string("continue")."</a>");
+    echo '<br />';
+    print_simple_box($message, 'center', '50%', $THEME->cellheading, '20', 'noticebox');
+    print_heading('<a href="'. $link .'">'. get_string('continue') .'</a>');
     print_footer(get_site());
     die;
 }
@@ -2331,17 +2331,17 @@ function notice ($message, $link="") {
 function notice_yesno ($message, $linkyes, $linkno) {
     global $THEME;
 
-    print_simple_box_start("center", "60%", "$THEME->cellheading");
-    echo "<p align=\"center\"><font size=\"3\">$message</font></p>";
-    echo "<p align=\"center\"><font size=\"3\"><b>";
-    echo "<a href=\"$linkyes\">".get_string("yes")."</a>";
-    echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
-    echo "<a href=\"$linkno\">".get_string("no")."</a>";
-    echo "</b></font></p>";
+    print_simple_box_start('center', '60%', $THEME->cellheading);
+    echo '<p align="center"><font size="3">'. $message .'</font></p>';
+    echo '<p align="center"><font size="3"><b>';
+    echo '<a href="'. $linkyes .'">'. get_string('yes') .'</a>';
+    echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
+    echo '<a href="'. $linkno .'">'. get_string('no') .'</a>';
+    echo '</b></font></p>';
     print_simple_box_end();
 }
 
-function redirect($url, $message="", $delay="0") {
+function redirect($url, $message='', $delay='0') {
 // Redirects the user to another page, after printing a notice
 
     // '&' needs to be encoded into '&amp;' for XHTML compliance,
@@ -2352,33 +2352,33 @@ function redirect($url, $message="", $delay="0") {
     $url = html_entity_decode($url); // for php < 4.3.0 this is defined in moodlelib.php
     $encodedurl = htmlentities($url);
     if (empty($message)) {
-        echo "<meta http-equiv=\"refresh\" content=\"$delay; url=$encodedurl\" />";
-        echo "<script type=\"text/javascript\">\n<!--\nlocation.replace('$url');\n//-->\n</script>";   // To cope with Mozilla bug
+        echo '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />';
+        echo '<script type="text/javascript">'. "\n" .'<!--'. "\n". 'location.replace(\'$url\');'. "\n". '//-->'. "\n". '</script>';   // To cope with Mozilla bug
     } else {
         if (empty($delay)) {
             $delay = 3;  // There's no point having a message with no delay
         }
-        print_header("", "", "", "", "<meta http-equiv=\"refresh\" content=\"$delay; url=$encodedurl\" />");
-        echo "<center>";
-        echo "<p>$message</p>";
-        echo "<p>( <a href=\"$encodedurl\">".get_string("continue")."</a> )</p>";
-        echo "</center>";
+        print_header('', '', '', '', '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />');
+        echo '<center>';
+        echo '<p>'. $message .'</p>';
+        echo '<p>( <a href="'. $encodedurl .'">'. get_string('continue') .'</a> )</p>';
+        echo '</center>';
         flush();
         sleep($delay);
-        echo "<script type=\"text/javascript\">\n<!--\nlocation.replace('$url');\n//-->\n</script>";   // To cope with Mozilla bug
+        echo '<script type="text/javascript">'."\n".'<!--'."\n".'location.replace(\'$url\');'."\n".'//-->'."\n".'</script>';   // To cope with Mozilla bug
     }
     die;
 }
 
-function notify ($message, $color="red", $align="center") {
-    echo "<p align=\"$align\"><b><font color=\"$color\">$message</font></b></p>\n";
+function notify ($message, $color='red', $align='center') {
+    echo '<p align="'. $align .'"><b><font color="'. $color .'">'. $message .'</font></b></p>' . "\n";
 }
 
 function obfuscate_email($email) {
 /// Given an email address, this function will return an obfuscated version of it
     $i = 0;
     $length = strlen($email);
-    $obfuscated = "";
+    $obfuscated = '';
     while ($i < $length) {
         if (rand(0,2)) {
             $obfuscated.='%'.dechex(ord($email{$i}));
@@ -2395,7 +2395,7 @@ function obfuscate_text($plaintext) {
 /// with HTML entity equivalents.   Return string is obviously longer.
     $i=0;
     $length = strlen($plaintext);
-    $obfuscated="";
+    $obfuscated='';
     $prev_obfuscated = false;
     while ($i < $length) {
         $c = ord($plaintext{$i});
@@ -2414,7 +2414,7 @@ function obfuscate_text($plaintext) {
     return $obfuscated;
 }
 
-function obfuscate_mailto($email, $label="", $dimmed=false) {
+function obfuscate_mailto($email, $label='', $dimmed=false) {
 /// This function uses the above two functions to generate a fully
 /// obfuscated email link, ready to use.
 
@@ -2439,16 +2439,16 @@ function print_paging_bar($totalcount, $page, $perpage, $baseurl) {
     $maxdisplay = 18;
 
     if ($totalcount > $perpage) {
-        echo "<center>";
-        echo "<p>".get_string("page").":";
+        echo '<center>';
+        echo '<p>'.get_string('page').':';
         if ($page > 0) {
             $pagenum=$page-1;
-            echo "&nbsp;(<a  href=\"{$baseurl}page=$pagenum\">".get_string("previous")."</a>)&nbsp;";
+            echo '&nbsp;(<a  href="'. $baseurl .'page='. $pagenum .'">'. get_string('previous') .'</a>)&nbsp;';
         }
         $lastpage = ceil($totalcount / $perpage);
         if ($page > 15) {
             $startpage = $page - 10;
-            echo "&nbsp<a href=\"{$baseurl}page=0\">1</a>&nbsp;...";
+            echo '&nbsp<a href="'. $baseurl .'page=0">1</a>&nbsp;...';
         } else {
             $startpage = 0;
         }
@@ -2457,23 +2457,23 @@ function print_paging_bar($totalcount, $page, $perpage, $baseurl) {
         while ($displaycount < $maxdisplay and $currpage < $lastpage) {
             $displaypage = $currpage+1;
             if ($page == $currpage) {
-                echo "&nbsp;&nbsp;$displaypage";
+                echo '&nbsp;&nbsp;'. $displaypage;
             } else {
-                echo "&nbsp;&nbsp;<a href=\"{$baseurl}page=$currpage\">$displaypage</a>";
+                echo '&nbsp;&nbsp;<a href="'. $baseurl .'page='. $currpage .'">'. $displaypage .'</a>';
             }
             $displaycount++;
             $currpage++;
         }
         if ($currpage < $lastpage) {
             $lastpageactual = $lastpage - 1;
-            echo "&nbsp;...<a href=\"{$baseurl}page=$lastpageactual\">$lastpage</a>&nbsp;";
+            echo '&nbsp;...<a href="'. $baseurl .'page='. $lastpageactual .'">'. $lastpage .'</a>&nbsp;';
         }
         $pagenum = $page + 1;
         if ($pagenum != $displaypage) {
-            echo "&nbsp;&nbsp;(<a href=\"{$baseurl}page=$pagenum\">".get_string("next")."</a>)";
+            echo '&nbsp;&nbsp;(<a href="'. $baseurl .'page='. $pagenum .'">'. get_string('next') .'</a>)';
         }
-        echo "</p>";
-        echo "</center>";
+        echo '</p>';
+        echo '</center>';
     }
 }
 
@@ -2504,31 +2504,31 @@ function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $fo
     if ($content) {
         echo $content;
         if ($footer) {
-            echo "<center><font size=\"-2\">$footer</font></center>";
+            echo '<center><font size="-2">'. $footer .'</font></center>';
         }
     } else {
-        echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
+        echo '<table width="100%" border="0" cellspacing="0" cellpadding="2">';
         if ($list) {
             foreach ($list as $key => $string) {
-                echo "<tr bgcolor=\"$THEME->cellcontent2\">";
+                echo '<tr bgcolor="'. $THEME->cellcontent2 .'">';
                 if ($icons) {
-                    echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"16\">".$icons[$key]."</td>";
+                    echo '<td class="sideblocklinks" valign="top" width="16">'. $icons[$key] .'</td>';
                 }
-                echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"*\"><font size=\"-1\">$string</font></td>";
-                echo "</tr>";
+                echo '<td class="sideblocklinks" valign="top" width="*"><font size="-1">'. $string .'</font></td>';
+                echo '</tr>';
             }
         }
         if ($footer) {
-            echo "<tr bgcolor=\"$THEME->cellcontent2\">";
-            echo "<td class=\"sideblocklinks\" ";
+            echo '<tr bgcolor="'. $THEME->cellcontent2 .'">';
+            echo '<td class="sideblocklinks" ';
             if ($icons) {
                 echo ' colspan="2" ';
             }
             echo '>';
-            echo "<center><font size=\"-2\">$footer</font></center>";
-            echo "</td></tr>";
+            echo '<center><font size="-2">'. $footer .'</font></center>';
+            echo '</td></tr>';
         }
-        echo "</table>";
+        echo '</table>';
     }
 
     print_side_block_end();
@@ -2579,7 +2579,7 @@ function print_editor_config() {
     global $CFG;
 
     // print new config
-    echo "var config = new HTMLArea.Config();\n";
+    echo 'var config = new HTMLArea.Config();'."\n";
     echo "config.pageStyle = \"body {";
     if(!(empty($CFG->editorbackgroundcolor))) {
         echo " background-color: $CFG->editorbackgroundcolor;";
@@ -2596,8 +2596,8 @@ function print_editor_config() {
     echo " }\";\n";
     echo "config.killWordOnPaste = ";
     echo(empty($CFG->editorkillword)) ? "false":"true";
-    echo ";\n";
-    echo "config.fontname = {\n";
+    echo ';'."\n";
+    echo 'config.fontname = {'."\n";
 
     $fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array();
     $i = 1;                     // Counter is used to get rid of the last comma.
@@ -2605,15 +2605,15 @@ function print_editor_config() {
 
     foreach($fontlist as $fontline) {
         if(!empty($fontline)) {
-            list($fontkey, $fontvalue) = split(":", $fontline);
-            echo "\"". $fontkey ."\":\t'". $fontvalue ."'";
+            list($fontkey, $fontvalue) = split(':', $fontline);
+            echo '"'. $fontkey ."\":\t'". $fontvalue ."'";
             if($i < $count) {
-                echo ",\n";
+                echo ','."\n";
             }
         }
         $i++;
     }
-    echo "};";
+    echo '};';
     if(!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) {
         print_speller_code($usehtmleditor=true);
     }
@@ -2625,14 +2625,14 @@ function print_speller_code ($usehtmleditor=false) {
     global $CFG;
 
     if(!$usehtmleditor) {
-        echo "\n<script language=\"javascript\" type=\"text/javascript\">\n";
-        echo "function openSpellChecker() {\n";
+        echo "\n".'<script language="javascript" type="text/javascript">'."\n";
+        echo 'function openSpellChecker() {'."\n";
         echo "\tvar speller = new spellChecker();\n";
         echo "\tspeller.popUpUrl = \"" . $CFG->wwwroot ."/lib/speller/spellchecker.html\";\n";
         echo "\tspeller.spellCheckScript = \"". $CFG->wwwroot ."/lib/speller/server-scripts/spellchecker.php\";\n";
         echo "\tspeller.spellCheckAll();\n";
-        echo "}\n";
-        echo "</script>\n";
+        echo '}'."\n";
+        echo '</script>'."\n";
     } else {
         echo "\nfunction spellClickHandler(editor, buttonId) {\n";
         echo "\teditor._textArea.value = editor.getHTML();\n";
@@ -2642,14 +2642,14 @@ function print_speller_code ($usehtmleditor=false) {
         echo "\tspeller._moogle_edit=1;\n";
         echo "\tspeller._editor=editor;\n";
         echo "\tspeller.openChecker();\n";
-        echo "}\n";
+        echo '}'."\n";
     }
 }
 
 function print_speller_button () {
 // print button for spellchecking
 // when editor is disabled
-    echo "<input type=\"button\" value=\"Check spelling\" onclick=\"openSpellChecker();\" />\n";
+    echo '<input type="button" value="Check spelling" onclick="openSpellChecker();" />'."\n";
 }
 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
-?>
+?>
\ No newline at end of file