]> git.mjollnir.org Git - moodle.git/commitdiff
Resolved problems with previous replacement of
authorgustav_delius <gustav_delius>
Tue, 21 Sep 2004 11:41:58 +0000 (11:41 +0000)
committergustav_delius <gustav_delius>
Tue, 21 Sep 2004 11:41:58 +0000 (11:41 +0000)
& to &amp; and fixed redirect() to entity encode the
inut where needed.
Julian Sedding

29 files changed:
admin/user.php
course/lib.php
lib/datalib.php
lib/editor/coursefiles.php
lib/editor/popups/insert_image.php
lib/moodlelib.php
lib/weblib.php
mod/chat/chatd.php
mod/chat/gui_header/chatmsg.php
mod/chat/gui_header_js/jsupdate.php
mod/chat/users.php
mod/forum/discuss.php
mod/forum/index.php
mod/forum/lib.php
mod/forum/post.php
mod/forum/restorelib.php
mod/forum/rsslib.php
mod/forum/search.php
mod/forum/subscribers.php
mod/forum/view.php
mod/glossary/restorelib.php
mod/glossary/rsslib.php
mod/lesson/restorelib.php
mod/wiki/admin.php
mod/wiki/lib.php
mod/wiki/view.php
user/edit.php
user/index.php
user/view.php

index 2f1ca0be6465afc6001013e7bf9de83eb3ee5a00..dce311dc84d6cf1b681bf4fc837b5db1830b1ef1 100644 (file)
@@ -95,7 +95,7 @@
         }
 
         redirect("$CFG->wwwroot/user/edit.php?id=$user->id&amp;course=$site->id");
-        
+
     } else {                        // List all users for editing
 
         $stredituser = get_string("edituser");
         $strshowallusers = get_string("showallusers");
 
         if ($firstinitial or $lastinitial or $search or $page) {
-            print_header("$site->shortname: $stredituser", $site->fullname, 
+            print_header("$site->shortname: $stredituser", $site->fullname,
                          "<a href=\"index.php\">$stradministration</a> -> ".
                          "<a href=\"users.php\">$strusers</a> -> ".
                          "<a href=\"user.php\">$stredituser</a>");
         } else {
-            print_header("$site->shortname: $stredituser", $site->fullname, 
+            print_header("$site->shortname: $stredituser", $site->fullname,
                          "<a href=\"index.php\">$stradministration</a> -> ".
                          "<a href=\"users.php\">$strusers</a> -> $stredituser");
         }
         echo "</center>";
 
         print_paging_bar($usercount, $page, $perpage,
-                "user.php?sort=$sort&amp;dir=$dir&amp;perpage=$perpage&amp;firstinitial=$firstinitial&amp;lastinitial=$lastinitial&amp;search=$search&");
+                "user.php?sort=$sort&amp;dir=$dir&amp;perpage=$perpage&amp;firstinitial=$firstinitial&amp;lastinitial=$lastinitial&amp;search=$search&amp;");
 
         flush();
 
             if ($search) {
                 echo "<input type=\"button\" onclick=\"document.location='user.php';\" value=\"$strshowallusers\">";
             }
-            echo "</form>";    
+            echo "</form>";
             echo "</td></tr></table>";
             print_heading("<a href=\"user.php?newuser=true\">".get_string("addnewuser")."</a>");
 
 
             print_paging_bar($usercount, $page, $perpage,
                              "user.php?sort=$sort&amp;dir=$dir&amp;perpage=$perpage".
-                             "&amp;firstinitial=$firstinitial&amp;lastinitial=$lastinitial&amp;search=$search&");
+                             "&amp;firstinitial=$firstinitial&amp;lastinitial=$lastinitial&amp;search=$search&amp;");
 
         }
 
index 523189e32e492f66851183b9ada611caebb54617..faf19a642b675bac3be3cbbab5e107b1fd0a61c5 100644 (file)
@@ -259,7 +259,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
                         $CFG->prefix.'user_teachers ut '.
                    'WHERE us.course='.$course->id.' AND gm.groupid='.$selectedgroup.
                    ' AND (gm.userid=us.userid OR gm.userid=ut.userid) AND gm.userid=u.id';
-            $courseusers = get_records_sql($sql); 
+            $courseusers = get_records_sql($sql);
         } else {
             $courseusers = get_course_users($course->id, '', '', 'u.id, u.firstname, u.lastname');
         }
@@ -410,7 +410,7 @@ function make_log_url($module, $url) {
     }
 }
 
-function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100, 
+function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
                    $url="", $modname="", $modid=0, $modaction="", $groupid=0) {
 
     // It is assumed that $date is the GMT time of midnight for that day,
@@ -435,7 +435,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
     $joins = array();
 
     if ($course->category) {
-        $joins[] = "l.course='$course->id'"; 
+        $joins[] = "l.course='$course->id'";
     } else {
         $courses[0] = '';
         if ($ccc = get_courses("all", "c.id ASC", "c.id,c.shortname")) {
@@ -511,7 +511,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
     print_string("displayingrecords", "", $totalcount);
     echo "</p>";
 
-    print_paging_bar($totalcount, $page, $perpage, "$url&amp;perpage=$perpage&");
+    print_paging_bar($totalcount, $page, $perpage, "$url&amp;perpage=$perpage&amp;");
 
     echo '<table border="0" align="center" cellpadding="3" cellspacing="3">';
     foreach ($logs as $log) {
@@ -548,7 +548,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
     }
     echo '</table>';
 
-    print_paging_bar($totalcount, $page, $perpage, "$url&amp;perpage=$perpage&");
+    print_paging_bar($totalcount, $page, $perpage, "$url&amp;perpage=$perpage&amp;");
 }
 
 
index 363f3d10e7c2e7ad08a64007680bd9aaa690d763..9350923a568fc21ed43725897377a0ee176f9e41 100644 (file)
@@ -12,7 +12,7 @@ if ($SITE = get_site()) {
 
 /**
 * execute a given sql command string
-* 
+*
 * Completely general function - it just runs some SQL and reports success.
 *
 * @param    type description
@@ -21,7 +21,7 @@ function execute_sql($command, $feedback=true) {
 /// Completely general function - it just runs some SQL and reports success.
 
     global $db;
-    
+
     $result = $db->Execute("$command");
 
     if ($result) {
@@ -38,9 +38,9 @@ function execute_sql($command, $feedback=true) {
 }
 /**
 * Run an arbitrary sequence of semicolon-delimited SQL commands
-* 
-* Assumes that the input text (file or string) consists of 
-* a number of SQL statements ENDING WITH SEMICOLONS.  The 
+*
+* Assumes that the input text (file or string) consists of
+* a number of SQL statements ENDING WITH SEMICOLONS.  The
 * semicolons MUST be the last character in a line.
 * Lines that are blank or that start with "#" are ignored.
 * Only tested with mysql dump files (mysqldump -p -d moodle)
@@ -52,7 +52,7 @@ function modify_database($sqlfile="", $sqlstring="") {
 
     global $CFG;
 
-    $success = true;  // Let's be optimistic 
+    $success = true;  // Let's be optimistic
 
     if (!empty($sqlfile)) {
         if (!is_readable($sqlfile)) {
@@ -72,7 +72,7 @@ function modify_database($sqlfile="", $sqlstring="") {
         $line = rtrim($line);
         $length = strlen($line);
 
-        if ($length and $line[0] <> "#") { 
+        if ($length and $line[0] <> "#") {
             if (substr($line, $length-1, 1) == ";") {
                 $line = substr($line, 0, $length-1);   // strip ;
                 $command .= $line;
@@ -95,7 +95,7 @@ function modify_database($sqlfile="", $sqlstring="") {
 
 /**
 * Add a new field to a table, or modify an existing one (if oldfield is defined).
-* 
+*
 * Add a new field to a table, or modify an existing one (if oldfield is defined).
 *
 * @param    type description
@@ -143,7 +143,7 @@ function table_column($table, $oldfield, $field, $type="integer", $size="10",
             //Check db-version
             $dbinfo = $db->ServerInfo();
             $dbver = substr($dbinfo['version'],0,3);
-            
+
             //to prevent conflicts with reserved words
             $realfield = "\"$field\"";
             $field = "\"${field}_alter_column_tmp\"";
@@ -153,7 +153,7 @@ function table_column($table, $oldfield, $field, $type="integer", $size="10",
                 case "integer":
                     if ($size <= 4) {
                         $type = "INT2";
-                    } 
+                    }
                     if ($size <= 10) {
                         $type = "INT";
                     }
@@ -180,7 +180,7 @@ function table_column($table, $oldfield, $field, $type="integer", $size="10",
             execute_sql("ALTER TABLE {$CFG->prefix}$table ADD COLUMN $field $type");
             //Add default values
             execute_sql("UPDATE {$CFG->prefix}$table SET $field=$default");
-             
+
 
             if ($dbver >= "7.3") {
                 // modifying 'not null' is posible before 7.3
@@ -194,14 +194,14 @@ function table_column($table, $oldfield, $field, $type="integer", $size="10",
             }
 
             execute_sql("ALTER TABLE {$CFG->prefix}$table ALTER COLUMN $field SET DEFAULT $default");
-            
+
             if ( $oldfield != "\"\"" ) {
                 execute_sql("UPDATE {$CFG->prefix}$table SET $field = $oldfield");
                 execute_sql("ALTER TABLE  {$CFG->prefix}$table drop column $oldfield");
             }
 
-            execute_sql("ALTER TABLE {$CFG->prefix}$table RENAME COLUMN $field TO $realfield"); 
-            
+            execute_sql("ALTER TABLE {$CFG->prefix}$table RENAME COLUMN $field TO $realfield");
+
             return execute_sql("COMMIT");
             break;
 
@@ -240,7 +240,7 @@ function table_column($table, $oldfield, $field, $type="integer", $size="10",
 
 /**
 * Returns true or false depending on whether the specified record exists
-* 
+*
 * Returns true or false depending on whether the specified record exists
 *
 * @param    type description
@@ -267,7 +267,7 @@ function record_exists($table, $field1="", $value1="", $field2="", $value2="", $
 
 /**
 * Returns true or false depending on whether the specified record exists
-* 
+*
 * The sql statement is provided as a string.
 *
 * @param    type description
@@ -293,7 +293,7 @@ function record_exists_sql($sql) {
 
 /**
 * Get all the records and count them
-* 
+*
 * Get all the records and count them
 *
 * @param    type description
@@ -319,7 +319,7 @@ function count_records($table, $field1="", $value1="", $field2="", $value2="", $
 
 /**
 * Get all the records and count them
-* 
+*
 * Get all the records and count them
 *
 * @param    type description
@@ -339,7 +339,7 @@ function count_records_select($table, $select="", $countitem="COUNT(*)") {
 
 /**
 * Get all the records and count them
-* 
+*
 * The sql statement is provided as a string.
 *
 * @param    type description
@@ -366,7 +366,7 @@ function count_records_sql($sql) {
 
 /**
 * Get a single record as an object
-* 
+*
 * Get a single record as an object
 *
 * @param    string  $table the name of the table to select from
@@ -379,7 +379,7 @@ function count_records_sql($sql) {
 * @return   object(fieldset)    a fieldset object containing the first record selected
 */
 function get_record($table, $field1, $value1, $field2="", $value2="", $field3="", $value3="") {
-    
+
     global $CFG ;
 
     $select = "WHERE $field1 = '$value1'";
@@ -396,7 +396,7 @@ function get_record($table, $field1, $value1, $field2="", $value2="", $field3=""
 
 /**
 * Get a single record as an object
-* 
+*
 * The sql statement is provided as a string.
 * A LIMIT is normally added to only look for 1 record
 *
@@ -442,7 +442,7 @@ function get_record_sql($sql) {
 
 /**
 * Gets one record from a table, as an object
-* 
+*
 * "select" is a fragment of SQL to define the selection criteria
 *
 * @param    type description
@@ -461,7 +461,7 @@ function get_record_select($table, $select="", $fields="*") {
 
 /**
 * Get a number of records as an array of objects
-* 
+*
 * Can optionally be sorted eg "time ASC" or "time DESC"
 * If "fields" is specified, only those fields are returned
 * The "key" is the first column returned, eg usually "id"
@@ -487,7 +487,7 @@ function get_records($table, $field="", $value="", $sort="", $fields="*", $limit
             case "postgres7":
                  $limit = "LIMIT $limitnum OFFSET $limitfrom";
                  break;
-            default: 
+            default:
                  $limit = "LIMIT $limitnum,$limitfrom";
         }
     } else {
@@ -503,7 +503,7 @@ function get_records($table, $field="", $value="", $sort="", $fields="*", $limit
 
 /**
 * Get a number of records as an array of objects
-* 
+*
 * Can optionally be sorted eg "time ASC" or "time DESC"
 * "select" is a fragment of SQL to define the selection criteria
 * The "key" is the first column returned, eg usually "id"
@@ -527,7 +527,7 @@ function get_records_select($table, $select="", $sort="", $fields="*", $limitfro
             case "postgres7":
                  $limit = "LIMIT $limitnum OFFSET $limitfrom";
                  break;
-            default: 
+            default:
                  $limit = "LIMIT $limitnum,$limitfrom";
         }
     } else {
@@ -544,8 +544,8 @@ function get_records_select($table, $select="", $sort="", $fields="*", $limitfro
 
 /**
 * Get a number of records as an array of objects
-* 
-* Differs from get_records() in that the values variable 
+*
+* Differs from get_records() in that the values variable
 * can be a comma-separated list of values eg  "4,5,6,10"
 * Can optionally be sorted eg "time ASC" or "time DESC"
 * The "key" is the first column returned, eg usually "id"
@@ -573,7 +573,7 @@ function get_records_list($table, $field="", $values="", $sort="", $fields="*")
 
 /**
 * Get a number of records as an array of objects
-* 
+*
 * The "key" is the first column returned, eg usually "id"
 * The sql statement is provided as a string.
 *
@@ -589,7 +589,7 @@ function get_records_sql($sql) {
         }
         return false;
     }
-    
+
     if ( $rs->RecordCount() > 0 ) {
         if ($records = $rs->GetAssoc(true)) {
             foreach ($records as $key => $record) {
@@ -606,11 +606,11 @@ function get_records_sql($sql) {
 
 /**
 * Get a number of records as an array of objects
-* 
+*
 * Can optionally be sorted eg "time ASC" or "time DESC"
 * If "fields" is specified, only those fields are returned
 * The "key" is the first column returned, eg usually "id"
-* 
+*
 * @param    type description
 */
 function get_records_menu($table, $field="", $value="", $sort="", $fields="*") {
@@ -632,11 +632,11 @@ function get_records_menu($table, $field="", $value="", $sort="", $fields="*") {
 
 /**
 * Get a number of records as an array of objects
-* 
+*
 * Can optionally be sorted eg "time ASC" or "time DESC"
 * "select" is a fragment of SQL to define the selection criteria
 * Returns associative array of first two fields
-* 
+*
 * @param    type description
 */
 function get_records_select_menu($table, $select="", $sort="", $fields="*") {
@@ -656,10 +656,10 @@ function get_records_select_menu($table, $select="", $sort="", $fields="*") {
 
 
 /**
-* Given an SQL select, this function returns an associative 
-* 
-* array of the first two columns.  This is most useful in 
-* combination with the choose_from_menu function to create 
+* Given an SQL select, this function returns an associative
+*
+* array of the first two columns.  This is most useful in
+* combination with the choose_from_menu function to create
 * a form menu.
 *
 * @param    type description
@@ -681,7 +681,7 @@ function get_records_sql_menu($sql) {
             $rs->MoveNext();
         }
         return $menu;
-        
+
     } else {
         return false;
     }
@@ -689,7 +689,7 @@ function get_records_sql_menu($sql) {
 
 /**
 * Get a single field from a database record
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -725,7 +725,7 @@ function get_field($table, $return, $field1, $value1, $field2="", $value2="", $f
 
 /**
 * Get a single field from a database record
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -751,7 +751,7 @@ function get_field_sql($sql) {
 
 /**
 * Set a single field in a database record
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -775,7 +775,7 @@ function set_field($table, $newfield, $newvalue, $field1, $value1, $field2="", $
 
 /**
 * Delete one or more records from a table
-* 
+*
 * Delete one or more records from a table
 *
 * @param    type description
@@ -801,7 +801,7 @@ function delete_records($table, $field1="", $value1="", $field2="", $value2="",
 
 /**
 * Delete one or more records from a table
-* 
+*
 * "select" is a fragment of SQL to define the selection criteria
 *
 * @param    type description
@@ -820,26 +820,26 @@ function delete_records_select($table, $select="") {
 
 /**
 * Insert a record into a table and return the "id" field if required
-* 
+*
 * If the return ID isn't required, then this just reports success as true/false.
 * $dataobject is an object containing needed data
 *
 * @param    type description
 */
 function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
-                                                                                                                
+
     global $db, $CFG;
 
 /// Execute a dummy query to get an empty recordset
     if (!$rs = $db->Execute("SELECT * FROM $CFG->prefix$table WHERE $primarykey ='-1'")) {
         return false;
     }
-                                                                                                                
+
 /// Get the correct SQL from adoDB
     if (!$insertSQL = $db->GetInsertSQL($rs, (array)$dataobject, true)) {
         return false;
     }
-                                                                                                                
+
 /// Run the SQL statement
     if (!$rs = $db->Execute($insertSQL)) {
         if (isset($CFG->debug) and $CFG->debug > 7) {
@@ -847,9 +847,9 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
         }
         return false;
     }
-                                                                                                                
+
 /// If a return ID is not needed then just return true now
-    if (!$returnid) { 
+    if (!$returnid) {
         return true;
     }
 
@@ -864,7 +864,7 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
             }
             return false;
 
-        default: 
+        default:
             return $db->Insert_ID();  // Should work on most databases, but not all!
     }
 }
@@ -872,9 +872,9 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
 
 /**
 * Update a record in a table
-* 
+*
 * $dataobject is an object containing needed data
-* Relies on $dataobject having a variable "id" to 
+* Relies on $dataobject having a variable "id" to
 * specify the record to update
 *
 * @param    type description
@@ -929,8 +929,8 @@ function update_record($table, $dataobject) {
 /// USER DATABASE ////////////////////////////////////////////////
 
 /**
-* Get a complete user record, which includes all the info 
-* 
+* Get a complete user record, which includes all the info
+*
 * in the user record, as well as membership information
 * Suitable for setting as $USER session cookie.
 *
@@ -993,7 +993,7 @@ function get_user_info_from_db($field, $value) {
 
 /**
 * Does this username and password specify a valid admin user?
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -1002,18 +1002,18 @@ function adminlogin($username, $md5password) {
 
     global $CFG;
 
-    return record_exists_sql("SELECT u.id 
-                                FROM {$CFG->prefix}user u, 
-                                     {$CFG->prefix}user_admins a 
-                              WHERE u.id = a.userid 
-                                AND u.username = '$username' 
+    return record_exists_sql("SELECT u.id
+                                FROM {$CFG->prefix}user u,
+                                     {$CFG->prefix}user_admins a
+                              WHERE u.id = a.userid
+                                AND u.username = '$username'
                                 AND u.password = '$md5password'");
 }
 
 
 /**
 * Get the guest user information from the database
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -1025,7 +1025,7 @@ function get_guest() {
 
 /**
 * Returns $user object of the main admin user
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -1036,7 +1036,7 @@ function get_admin () {
 
     if ( $admins = get_admins() ) {
         foreach ($admins as $admin) {
-            return $admin;   // ie the first one 
+            return $admin;   // ie the first one
         }
     } else {
         return false;
@@ -1045,7 +1045,7 @@ function get_admin () {
 
 /**
 * Returns list of all admins
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -1054,8 +1054,8 @@ function get_admins() {
 
     global $CFG;
 
-    return get_records_sql("SELECT u.*, a.id as adminid 
-                              FROM {$CFG->prefix}user u, 
+    return get_records_sql("SELECT u.*, a.id as adminid
+                              FROM {$CFG->prefix}user u,
                                    {$CFG->prefix}user_admins a
                              WHERE a.userid = u.id
                              ORDER BY a.id ASC");
@@ -1063,7 +1063,7 @@ function get_admins() {
 
 /**
 * Returns list of all creators
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -1081,7 +1081,7 @@ function get_creators() {
 
 /**
 * Returns $user object of the main teacher for a course
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -1103,7 +1103,7 @@ function get_teacher($courseid) {
 
 /**
 * Searches logs to find all enrolments since a certain date
-* 
+*
 * used to print recent activity
 *
 * @param    type description
@@ -1116,9 +1116,9 @@ function get_recent_enrolments($courseid, $timestart) {
                             FROM {$CFG->prefix}user u,
                                  {$CFG->prefix}user_students s,
                                  {$CFG->prefix}log l
-                            WHERE l.time > '$timestart' 
+                            WHERE l.time > '$timestart'
                               AND l.course = '$courseid'
-                              AND l.module = 'course' 
+                              AND l.module = 'course'
                               AND l.action = 'enrol'
                               AND l.info = u.id
                               AND u.id = s.userid
@@ -1129,21 +1129,21 @@ function get_recent_enrolments($courseid, $timestart) {
 /**
 * Returns array of userinfo of all students in this course
 * or on this site if courseid is id of site
-* 
+*
 * @param    type description
 */
 function get_course_students($courseid, $sort="s.timeaccess", $dir="", $page=0, $recordsperpage=99999,
                              $firstinitial="", $lastinitial="", $group=NULL, $search="", $fields='', $exceptions='') {
 
     global $CFG;
-    
-    if ($courseid == SITEID and $CFG->allusersaresitestudents) { 
+
+    if ($courseid == SITEID and $CFG->allusersaresitestudents) {
         // return users with confirmed, undeleted accounts who are not site teachers
         // the following is a mess because of different conventions in the different user functions
         $sort = str_replace('s.timeaccess', 'lastaccess', $sort); // site users can't be sorted by timeaccess
         $sort = str_replace('timeaccess', 'lastaccess', $sort); // site users can't be sorted by timeaccess
         $sort = str_replace('u.', '', $sort); // the get_user function doesn't use the u. prefix to fields
-        $fields = str_replace('u.', '', $fields); 
+        $fields = str_replace('u.', '', $fields);
         if ($sort) {
             $sort = "$sort $dir";
         }
@@ -1154,7 +1154,7 @@ function get_course_students($courseid, $sort="s.timeaccess", $dir="", $page=0,
             }
             $exceptions = ltrim($exceptions, ',');
         }
-        return get_users(true, $search, true, $exceptions, $sort, $firstinitial, $lastinitial, 
+        return get_users(true, $search, true, $exceptions, $sort, $firstinitial, $lastinitial,
                           $page, $recordsperpage, $fields ? $fields : '*');
     }
 
@@ -1169,7 +1169,7 @@ function get_course_students($courseid, $sort="s.timeaccess", $dir="", $page=0,
              $limit = "LIMIT $recordsperpage OFFSET ".($page);
              $LIKE = "ILIKE";
              break;
-        default: 
+        default:
              $fullname = " firstname||\" \"||lastname ";
              $limit = "LIMIT $recordsperpage,$page";
              $LIKE = "ILIKE";
@@ -1211,7 +1211,7 @@ function get_course_students($courseid, $sort="s.timeaccess", $dir="", $page=0,
         $groupmembers = ", {$CFG->prefix}groups_members gm ";
         $select .= " AND u.id = gm.userid AND gm.groupid = '$group'";
     }
-    
+
     if (!empty($exceptions)) {
         $select .= " AND u.id NOT IN ($exceptions)";
     }
@@ -1229,7 +1229,7 @@ function get_course_students($courseid, $sort="s.timeaccess", $dir="", $page=0,
     if ($courseid != SITEID) {
         return $students;
     }
-    
+
     // We are here because we need the students for the site.
     // These also include teachers on real courses minus those on the site
     if ($teachers = get_records('user_teachers', 'course', SITEID)) {
@@ -1254,7 +1254,7 @@ function get_course_students($courseid, $sort="s.timeaccess", $dir="", $page=0,
 
 /**
 * Counts the students in a given course (or site), or a subset of them
-* 
+*
 * @param    type description
 */
 function count_course_students($course, $search="", $firstinitial="", $lastinitial="", $group=NULL, $exceptions='') {
@@ -1267,9 +1267,9 @@ function count_course_students($course, $search="", $firstinitial="", $lastiniti
 
 
 /**
-* Returns list of all teachers in this course 
+* Returns list of all teachers in this course
 * (also works for site)
-* 
+*
 * @param    type description
 */
 function get_course_teachers($courseid, $sort="t.authority ASC", $exceptions='') {
@@ -1283,11 +1283,11 @@ function get_course_teachers($courseid, $sort="t.authority ASC", $exceptions='')
     }
 
     return get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest,
-                                   u.email, u.city, u.country, u.lastlogin, u.picture, u.lang, u.timezone, 
+                                   u.email, u.city, u.country, u.lastlogin, u.picture, u.lang, u.timezone,
                                    u.emailstop, t.authority,t.role,t.editall,t.timeaccess as lastaccess
-                            FROM {$CFG->prefix}user u, 
+                            FROM {$CFG->prefix}user u,
                                  {$CFG->prefix}user_teachers t
-                            WHERE t.course = '$courseid' AND t.userid = u.id 
+                            WHERE t.course = '$courseid' AND t.userid = u.id
                               AND u.deleted = '0' AND u.confirmed = '1' $except
                             ORDER BY $sort");
 }
@@ -1333,11 +1333,11 @@ function search_users($courseid, $groupid, $searchtext, $sort='', $exceptions=''
              $fullname = " u.firstname||' '||u.lastname ";
              $LIKE = "ILIKE";
              break;
-        default: 
+        default:
              $fullname = " u.firstname||\" \"||u.lastname ";
              $LIKE = "ILIKE";
     }
-    
+
     if (!empty($exceptions)) {
         $except = " AND u.id NOT IN ($exceptions) ";
     } else {
@@ -1349,7 +1349,7 @@ function search_users($courseid, $groupid, $searchtext, $sort='', $exceptions=''
     } else {
         $order = '';
     }
-    
+
     $select = "u.deleted = '0' AND u.confirmed = '1'";
 
     if (!$courseid or $courseid == SITEID) {
@@ -1358,18 +1358,18 @@ function search_users($courseid, $groupid, $searchtext, $sort='', $exceptions=''
                       WHERE $select
                           AND ($fullname $LIKE '%$searchtext%' OR u.email $LIKE '%$searchtext%')
                           $except $order");
-    } else { 
+    } else {
 
         if ($groupid) {
             return get_records_sql("SELECT u.id, u.firstname, u.lastname, u.email
-                          FROM {$CFG->prefix}user u, 
+                          FROM {$CFG->prefix}user u,
                                {$CFG->prefix}groups_members g
                           WHERE $select AND g.groupid = '$groupid' AND g.userid = u.id
                               AND ($fullname $LIKE '%$searchtext%' OR u.email $LIKE '%$searchtext%')
                               $except $order");
         } else {
             if (!$teachers = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.email
-                          FROM {$CFG->prefix}user u, 
+                          FROM {$CFG->prefix}user u,
                                {$CFG->prefix}user_teachers s
                           WHERE $select AND s.course = '$courseid' AND s.userid = u.id
                               AND ($fullname $LIKE '%$searchtext%' OR u.email $LIKE '%$searchtext%')
@@ -1377,7 +1377,7 @@ function search_users($courseid, $groupid, $searchtext, $sort='', $exceptions=''
                 $teachers = array();
             }
             if (!$students = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.email
-                          FROM {$CFG->prefix}user u, 
+                          FROM {$CFG->prefix}user u,
                                {$CFG->prefix}user_students s
                           WHERE $select AND s.course = '$courseid' AND s.userid = u.id
                               AND ($fullname $LIKE '%$searchtext%' OR u.email $LIKE '%$searchtext%')
@@ -1403,8 +1403,8 @@ function get_site_users($sort="u.lastaccess DESC", $fields='*', $exceptions='')
 
 
 /**
-* Returns a subset of users 
-* 
+* Returns a subset of users
+*
 * longdesc
 *
 * @param    bookean $get    if false then only a count of the records is returned
@@ -1434,7 +1434,7 @@ function get_users($get=true, $search="", $confirmed=false, $exceptions="", $sor
              $fullname = " firstname||' '||lastname ";
              $LIKE = "ILIKE";
              break;
-        default: 
+        default:
              $limit = "LIMIT $recordsperpage,$page";
              $fullname = " firstname||\" \"||lastname ";
              $LIKE = "ILIKE";
@@ -1456,10 +1456,10 @@ function get_users($get=true, $search="", $confirmed=false, $exceptions="", $sor
 
     if ($firstinitial) {
         $select .= " AND firstname $LIKE '$firstinitial%'";
-    } 
+    }
     if ($lastinitial) {
         $select .= " AND lastname $LIKE '$lastinitial%'";
-    } 
+    }
 
     if ($sort and $get) {
         $sort = " ORDER BY $sort ";
@@ -1477,7 +1477,7 @@ function get_users($get=true, $search="", $confirmed=false, $exceptions="", $sor
 
 /**
 * shortdesc
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -1498,7 +1498,7 @@ function get_users_listing($sort="lastaccess", $dir="ASC", $page=0, $recordsperp
              $fullname = " firstname||' '||lastname ";
              $LIKE = "ILIKE";
              break;
-        default: 
+        default:
              $limit = "LIMIT $recordsperpage,$page";
              $fullname = " firstname||' '||lastname ";
              $LIKE = "LIKE";
@@ -1524,7 +1524,7 @@ function get_users_listing($sort="lastaccess", $dir="ASC", $page=0, $recordsperp
 
 /// warning: will return UNCONFIRMED USERS
     return get_records_sql("SELECT id, username, email, firstname, lastname, city, country, lastaccess, confirmed
-                              FROM {$CFG->prefix}user 
+                              FROM {$CFG->prefix}user
                              WHERE $select $sort $limit ");
 
 }
@@ -1532,42 +1532,42 @@ function get_users_listing($sort="lastaccess", $dir="ASC", $page=0, $recordsperp
 
 /**
 * shortdesc
-* 
+*
 * longdesc
 *
 * @param    type description
 */
 function get_users_confirmed() {
     global $CFG;
-    return get_records_sql("SELECT * 
-                              FROM {$CFG->prefix}user 
-                             WHERE confirmed = 1 
+    return get_records_sql("SELECT *
+                              FROM {$CFG->prefix}user
+                             WHERE confirmed = 1
                                AND deleted = 0
-                               AND username <> 'guest' 
+                               AND username <> 'guest'
                                AND username <> 'changeme'");
 }
 
 
 /**
 * shortdesc
-* 
+*
 * longdesc
 *
 * @param    type description
 */
 function get_users_unconfirmed($cutofftime=2000000000) {
     global $CFG;
-    return get_records_sql("SELECT * 
-                             FROM {$CFG->prefix}user 
+    return get_records_sql("SELECT *
+                             FROM {$CFG->prefix}user
                             WHERE confirmed = 0
-                              AND firstaccess > 0 
+                              AND firstaccess > 0
                               AND firstaccess < '$cutofftime'");
 }
 
 
 /**
 * shortdesc
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -1576,15 +1576,15 @@ function get_users_longtimenosee($cutofftime) {
     global $CFG;
     return get_records_sql("SELECT DISTINCT *
                               FROM {$CFG->prefix}user_students
-                             WHERE timeaccess > '0' 
+                             WHERE timeaccess > '0'
                                AND timeaccess < '$cutofftime' ");
 }
 
 /**
 * Returns an array of group objects that the user is a member of
-* in the given course.  If userid isn't specified, then return a 
+* in the given course.  If userid isn't specified, then return a
 * list of all groups in the course.
-* 
+*
 * @param    type description
 */
 function get_groups($courseid, $userid=0) {
@@ -1606,7 +1606,7 @@ function get_groups($courseid, $userid=0) {
 
 /**
 * Returns an array of user objects
-* 
+*
 * @param    type description
 */
 function get_group_users($groupid, $sort="u.lastaccess DESC", $exceptions='') {
@@ -1618,7 +1618,7 @@ function get_group_users($groupid, $sort="u.lastaccess DESC", $exceptions='') {
     }
     return get_records_sql("SELECT DISTINCT u.*
                               FROM {$CFG->prefix}user u,
-                                   {$CFG->prefix}groups_members m 
+                                   {$CFG->prefix}groups_members m
                              WHERE m.groupid = '$groupid'
                                AND m.userid = u.id $except
                           ORDER BY $sort");
@@ -1626,7 +1626,7 @@ function get_group_users($groupid, $sort="u.lastaccess DESC", $exceptions='') {
 
 /**
 * An efficient way of finding all the users who aren't in groups yet
-* 
+*
 * @param    type description
 */
 function get_users_not_in_group($courseid) {
@@ -1638,7 +1638,7 @@ function get_users_not_in_group($courseid) {
 
 /**
 * Returns an array of user objects
-* 
+*
 * @param    type description
 */
 function get_group_students($groupid, $sort="u.lastaccess DESC") {
@@ -1649,8 +1649,8 @@ function get_group_students($groupid, $sort="u.lastaccess DESC") {
                                    {$CFG->prefix}groups g,
                                    {$CFG->prefix}user_students s
                              WHERE m.groupid = '$groupid'
-                               AND m.userid = u.id 
-                               AND m.groupid = g.id 
+                               AND m.userid = u.id
+                               AND m.groupid = g.id
                                AND g.courseid = s.course
                                AND s.userid = u.id
                           ORDER BY $sort");
@@ -1659,7 +1659,7 @@ function get_group_students($groupid, $sort="u.lastaccess DESC") {
 
 /**
 * Returns the user's group in a particular course
-* 
+*
 * @param    type description
 */
 function user_group($courseid, $userid) {
@@ -1681,7 +1681,7 @@ function user_group($courseid, $userid) {
 
 /**
 * Returns $course object of the top-level site.
-* 
+*
 * Returns $course object of the top-level site.
 *
 * @param    type description
@@ -1698,7 +1698,7 @@ function get_site () {
 
 /**
 * Returns list of courses, for whole site, or category
-* 
+*
 * Returns list of courses, for whole site, or category
 *
 * @param    type description
@@ -1740,12 +1740,12 @@ function get_courses($categoryid="all", $sort="c.sortorder ASC", $fields="c.*")
 
 /**
 * Returns list of courses, for whole site, or category
-* 
+*
 * Similar to get_courses, but allows paging
 *
 * @param    type description
 */
-function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c.*", 
+function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c.*",
                           &$totalcount, $limitfrom="", $limitnum="") {
 
     global $USER, $CFG;
@@ -1778,7 +1778,7 @@ function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c
             case "postgres7":
                  $limit = "LIMIT $limitnum OFFSET $limitfrom";
                  break;
-            default: 
+            default:
                  $limit = "LIMIT $limitnum,$limitfrom";
         }
     } else {
@@ -1795,7 +1795,7 @@ function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c
 
 /**
 * shortdesc
-* 
+*
 * longdesc
 *
 * @param    type description
@@ -1826,20 +1826,20 @@ function get_my_courses($userid, $sort="visible DESC,sortorder ASC") {
 
 //  The following is correct but VERY slow with large datasets
 //
-//    return get_records_sql("SELECT c.* 
-//                              FROM {$CFG->prefix}course c, 
-//                                   {$CFG->prefix}user_students s, 
-//                                   {$CFG->prefix}user_teachers t 
+//    return get_records_sql("SELECT c.*
+//                              FROM {$CFG->prefix}course c,
+//                                   {$CFG->prefix}user_students s,
+//                                   {$CFG->prefix}user_teachers t
 //                             WHERE (s.userid = '$userid' AND s.course = c.id)
 //                                OR (t.userid = '$userid' AND t.course = c.id)
-//                             GROUP BY c.id 
+//                             GROUP BY c.id
 //                             ORDER BY $sort");
 }
 
 
 /**
 * Returns a list of courses that match a search
-* 
+*
 * Returns a list of courses that match a search
 *
 * @param    type description
@@ -1855,7 +1855,7 @@ function get_courses_search($searchterms, $sort="fullname ASC", $page=0, $record
         case "postgres7":
              $limit = "LIMIT $recordsperpage OFFSET ".($page * $recordsperpage);
              break;
-        default: 
+        default:
              $limit = "LIMIT $recordsperpage,$page";
     }
 
@@ -1902,7 +1902,7 @@ function get_courses_search($searchterms, $sort="fullname ASC", $page=0, $record
 
     $totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
 
-    $courses = get_records_sql("SELECT * FROM $selectsql ORDER BY $sort $limit"); 
+    $courses = get_records_sql("SELECT * FROM $selectsql ORDER BY $sort $limit");
 
     if ($courses) {  /// Remove unavailable courses from the list
         foreach ($courses as $key => $course) {
@@ -1921,7 +1921,7 @@ function get_courses_search($searchterms, $sort="fullname ASC", $page=0, $record
 
 /**
 * Returns a sorted list of categories
-* 
+*
 * Returns a sorted list of categories
 *
 * @param    type description
@@ -1953,7 +1953,7 @@ function get_categories($parent="none", $sort="sortorder ASC") {
 * @param    type description
 */
 function fix_course_sortorder($categoryid=0, $n=0) {
-    
+
     $count = 0;
     if ($courses = get_courses($categoryid)) {
         foreach ($courses as $course) {
@@ -1963,22 +1963,22 @@ function fix_course_sortorder($categoryid=0, $n=0) {
         }
     }
     set_field("course_categories", "coursecount", $count, "id", $categoryid);
-    
+
     if ($categories = get_categories($categoryid)) {
         foreach ($categories as $category) {
             $n = fix_course_sortorder($category->id, $n);
         }
     }
-    
+
     return $n;
 }
 
 /**
 * This function creates a default separated/connected scale
-* 
+*
 * This function creates a default separated/connected scale
-* so there's something in the database.  The locations of 
-* strings and files is a bit odd, but this is because we 
+* so there's something in the database.  The locations of
+* strings and files is a bit odd, but this is because we
 * need to maintain backward compatibility with many different
 * existing language translations and older sites.
 *
@@ -1997,7 +1997,7 @@ function make_default_scale() {
                            get_string("postrating3", "forum");
     $defaultscale->timemodified = time();
 
-    /// Read in the big description from the file.  Note this is not 
+    /// Read in the big description from the file.  Note this is not
     /// HTML (despite the file extension) but Moodle format text.
     $parentlang = get_string("parentlang");
     if (is_readable("$CFG->dirroot/lang/$CFG->lang/help/forum/ratings.html")) {
@@ -2019,7 +2019,7 @@ function make_default_scale() {
 
 /**
 * Returns a menu of all available scales from the site as well as the given course
-* 
+*
 * Returns a menu of all available scales from the site as well as the given course
 *
 * @param    type description
@@ -2027,9 +2027,9 @@ function make_default_scale() {
 function get_scales_menu($courseid=0) {
 
     global $CFG;
-    
-    $sql = "SELECT id, name FROM {$CFG->prefix}scale 
-             WHERE courseid = '0' or courseid = '$courseid' 
+
+    $sql = "SELECT id, name FROM {$CFG->prefix}scale
+             WHERE courseid = '0' or courseid = '$courseid'
           ORDER BY courseid ASC, name ASC";
 
     if ($scales = get_records_sql_menu("$sql")) {
@@ -2045,7 +2045,7 @@ function get_scales_menu($courseid=0) {
 
 /**
 * Just gets a raw list of all modules in a course
-* 
+*
 * Just gets a raw list of all modules in a course
 *
 * @param    type description
@@ -2054,16 +2054,16 @@ function get_course_mods($courseid) {
     global $CFG;
 
     return get_records_sql("SELECT cm.*, m.name as modname
-                            FROM {$CFG->prefix}modules m, 
+                            FROM {$CFG->prefix}modules m,
                                  {$CFG->prefix}course_modules cm
-                            WHERE cm.course = '$courseid' 
+                            WHERE cm.course = '$courseid'
                             AND cm.deleted = '0'
                             AND cm.module = m.id ");
 }
 
 /**
 * Given an instance of a module, finds the coursemodule description
-* 
+*
 * Given an instance of a module, finds the coursemodule description
 *
 * @param    type description
@@ -2073,13 +2073,13 @@ function get_coursemodule_from_instance($modulename, $instance, $courseid) {
     global $CFG;
 
     return get_record_sql("SELECT cm.*, m.name
-                           FROM {$CFG->prefix}course_modules cm, 
-                                {$CFG->prefix}modules md, 
-                                {$CFG->prefix}$modulename m 
-                           WHERE cm.course = '$courseid' AND 
+                           FROM {$CFG->prefix}course_modules cm,
+                                {$CFG->prefix}modules md,
+                                {$CFG->prefix}$modulename m
+                           WHERE cm.course = '$courseid' AND
                                  cm.deleted = '0' AND
-                                 cm.instance = m.id AND 
-                                 md.name = '$modulename' AND 
+                                 cm.instance = m.id AND
+                                 md.name = '$modulename' AND
                                  md.id = cm.module AND
                                  m.id = '$instance'");
 
@@ -2087,7 +2087,7 @@ function get_coursemodule_from_instance($modulename, $instance, $courseid) {
 
 /**
 * Returns an array of all the active instances of a particular module in a given course, sorted in the order they are defined
-* 
+*
 * Returns an array of all the active instances of a particular
 * module in a given course, sorted in the order they are defined
 * in the course.   Returns false on any errors.
@@ -2104,15 +2104,15 @@ function get_all_instances_in_course($modulename, $course) {
     }
 
     if (!$rawmods = get_records_sql("SELECT cm.id as coursemodule, m.*,cw.section,cm.visible as visible,cm.groupmode
-                            FROM {$CFG->prefix}course_modules cm, 
-                                 {$CFG->prefix}course_sections cw, 
-                                 {$CFG->prefix}modules md, 
-                                 {$CFG->prefix}$modulename m 
-                            WHERE cm.course = '$course->id' AND 
-                                  cm.instance = m.id AND 
+                            FROM {$CFG->prefix}course_modules cm,
+                                 {$CFG->prefix}course_sections cw,
+                                 {$CFG->prefix}modules md,
+                                 {$CFG->prefix}$modulename m
+                            WHERE cm.course = '$course->id' AND
+                                  cm.instance = m.id AND
                                   cm.deleted = '0' AND
-                                  cm.section = cw.id AND 
-                                  md.name = '$modulename' AND 
+                                  cm.section = cw.id AND
+                                  md.name = '$modulename' AND
                                   md.id = cm.module")) {
         return array();
     }
@@ -2141,9 +2141,9 @@ function get_all_instances_in_course($modulename, $course) {
 
 /**
 * determine whether a module instance is visible within a course
-* 
-* Given a valid module object with info about the id and course, 
-* and the module's type (eg "forum") returns whether the object 
+*
+* Given a valid module object with info about the id and course,
+* and the module's type (eg "forum") returns whether the object
 * is visible or not
 *
 * @param    type description
@@ -2156,9 +2156,9 @@ function instance_is_visible($moduletype, $module) {
                                     FROM {$CFG->prefix}course_modules cm,
                                          {$CFG->prefix}modules m
                                    WHERE cm.course = '$module->course' AND
-                                         cm.module = m.id AND 
-                                         m.name = '$moduletype' AND 
-                                         cm.instance = '$module->id'")) { 
+                                         cm.module = m.id AND
+                                         m.name = '$moduletype' AND
+                                         cm.instance = '$module->id'")) {
 
         foreach ($records as $record) { // there should only be one - use the first one
             return $record->visible;
@@ -2176,16 +2176,16 @@ function instance_is_visible($moduletype, $module) {
 
 /**
 * Add an entry to the log table.
-* 
+*
 * Add an entry to the log table.  These are "action" focussed rather
-* than web server hits, and provide a way to easily reconstruct what 
+* than web server hits, and provide a way to easily reconstruct what
 * any particular student has been doing.
 *
 * @param    int     $course  the course id
 * @param    string  $module  the module name - e.g. forum, journal, resource, course, user etc
 * @param    string  $action  view, edit, post (often but not always the same as the file.php)
 * @param    string  $url     the file and parameters used to see the results of the action
-* @param    string  $info    additional description information 
+* @param    string  $info    additional description information
 * @param    string  $cm      the course_module->id if there is one
 * @param    string  $user    if log regards $user other than $USER
 */
@@ -2204,16 +2204,17 @@ function add_to_log($courseid, $module, $action, $url="", $info="", $cm=0, $user
 
     $timenow = time();
     $info = addslashes($info);
+    $url = html_entity_decode($url); // for php < 4.3.0 this is defined in moodlelib.php
 
     $result = $db->Execute("INSERT INTO {$CFG->prefix}log (time, userid, course, ip, module, cmid, action, url, info)
         VALUES ('$timenow', '$userid', '$courseid', '$REMOTE_ADDR', '$module', '$cm', '$action', '$url', '$info')");
 
     if (!$result and ($CFG->debug > 7)) {
         echo "<p>Error: Could not insert a new entry to the Moodle log</p>";  // Don't throw an error
-    }    
+    }
     if (!$user and isset($USER->id)) {
         if ($courseid == SITEID) {
-            $db->Execute("UPDATE {$CFG->prefix}user SET lastIP='$REMOTE_ADDR', lastaccess='$timenow' 
+            $db->Execute("UPDATE {$CFG->prefix}user SET lastIP='$REMOTE_ADDR', lastaccess='$timenow'
                      WHERE id = '$USER->id' ");
         } else if (isstudent($courseid)) {
             $db->Execute("UPDATE {$CFG->prefix}user_students SET timeaccess = '$timenow' ".
@@ -2222,15 +2223,15 @@ function add_to_log($courseid, $module, $action, $url="", $info="", $cm=0, $user
             $db->Execute("UPDATE {$CFG->prefix}user_teachers SET timeaccess = '$timenow' ".
                          "WHERE course = '$courseid' AND userid = '$userid'");
         }
-    }     
+    }
 }
 
 
 /**
 * select all log records based on SQL criteria
-* 
+*
 * select all log records based on SQL criteria
-* 
+*
 * @param    string  $select SQL select criteria
 * @param    string  $order  SQL order by clause to sort the records returned
 */
@@ -2245,7 +2246,7 @@ function get_logs($select, $order="l.time DESC", $limitfrom="", $limitnum="", &$
             case "postgres7":
                  $limit = "LIMIT $limitnum OFFSET $limitfrom";
                  break;
-            default: 
+            default:
                  $limit = "LIMIT $limitnum,$limitfrom";
         }
     } else {
@@ -2259,14 +2260,14 @@ function get_logs($select, $order="l.time DESC", $limitfrom="", $limitnum="", &$
     $selectsql = "{$CFG->prefix}log l LEFT JOIN {$CFG->prefix}user u ON l.userid = u.id ".((strlen($select) > 0) ? "WHERE $select" : "");
     $totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
 
-    return get_records_sql("SELECT l.*, u.firstname, u.lastname, u.picture 
-                                FROM $selectsql $order $limit"); 
+    return get_records_sql("SELECT l.*, u.firstname, u.lastname, u.picture
+                                FROM $selectsql $order $limit");
 }
 
 
 /**
 * select all log records for a given course and user
-* 
+*
 * select all log records for a given course and user
 *
 * @param    type description
@@ -2280,16 +2281,16 @@ function get_logs_usercourse($userid, $courseid, $coursestart) {
         $courseselect = '';
     }
 
-    return get_records_sql("SELECT floor((`time` - $coursestart)/86400) as day, count(*) as num 
-                            FROM {$CFG->prefix}log 
-                           WHERE userid = '$userid' 
+    return get_records_sql("SELECT floor((`time` - $coursestart)/86400) as day, count(*) as num
+                            FROM {$CFG->prefix}log
+                           WHERE userid = '$userid'
                              AND `time` > '$coursestart' $courseselect
                         GROUP BY day ");
 }
 
 /**
 * select all log records for a given course, user, and day
-* 
+*
 * select all log records for a given course, user, and day
 *
 * @param    type description
@@ -2305,7 +2306,7 @@ function get_logs_userday($userid, $courseid, $daystart) {
 
     return get_records_sql("SELECT floor((`time` - $daystart)/3600) as hour, count(*) as num
                             FROM {$CFG->prefix}log
-                           WHERE userid = '$userid' 
+                           WHERE userid = '$userid'
                              AND `time` > '$daystart' $courseselect
                         GROUP BY hour ");
 }
@@ -2313,8 +2314,8 @@ function get_logs_userday($userid, $courseid, $daystart) {
 /**
  * Returns an object with counts of failed login attempts
  *
- * Returns information about failed login attempts.  If the current user is 
- * an admin, then two numbers are returned:  the number of attempts and the 
+ * Returns information about failed login attempts.  If the current user is
+ * an admin, then two numbers are returned:  the number of attempts and the
  * number of accounts.  For non-admins, only the attempts on the given user
  * are shown.
  *
@@ -2345,7 +2346,7 @@ function count_login_failures($mode, $username, $lastlogin) {
 
 /**
 * dump a given object's information in a PRE block
-* 
+*
 * dump a given object's information in a PRE block
 * Mostly just for debugging
 *
index b550d0a347cfb0255db659d803972f120891cfe7..aa4563281ae058f2515b894aca9acebdc06d6c8b 100644 (file)
@@ -61,7 +61,7 @@
                         var value = params[field];
                         switch(field) {
                             case "url"   :   upper.document.getElementById('f_url').value = value;
-                                     upper.ipreview.location.replace('popups/preview.php?id='+ <?php print($course->id);?> +'&amp;imageurl='+ value);
+                                     upper.ipreview.location.replace('popups/preview.php?id='+ <?php print($course->id);?> +'&imageurl='+ value);
                                 break;
                             case "isize" :   upper.document.getElementById('isize').value = value; break;
                             case "itype" :   upper.document.getElementById('itype').value = value; break;
         case "upload":
             html_header($course, $wdir);
             require_once($CFG->dirroot.'/lib/uploadlib.php');
-                
+
             if (!empty($save)) {
                 $um = new upload_manager('userfile',false,false,$course,false,0);
                 $dir = "$basedir$wdir";
index 920774f0d6f642b9999fd8f24e5e6fc66dbbaa8c..55b59cd0c4016a41458a1e1f5c673d795c427eab 100644 (file)
@@ -7,7 +7,7 @@
     if (!$course = get_record("course", "id", $id)) {
         $course->fullname = "";   // Just to keep display happy, though browsing may fail
     }
-    
+
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -17,6 +17,7 @@
 <title><?php print_string("insertimage","editor");?></title>
 <script language="javascript" type="text/javascript" src="popup.js"></script>
 <script language="javascript" type="text/javascript">
+<!--
 var preview_window = null;
 
 function Init() {
@@ -32,7 +33,7 @@ function Init() {
       document.getElementById("f_horiz").value = param["f_horiz"] != -1 ? param["f_horiz"] : 0;
       document.getElementById("f_width").value = param["f_width"];
       document.getElementById("f_height").value = param["f_height"];
-      window.ipreview.location.replace('preview.php?id='+ <?php print($course->id);?> +'&amp;imageurl='+ param.f_url);
+      window.ipreview.location.replace('preview.php?id='+ <?php print($course->id);?> +'&imageurl='+ param.f_url);
   }
   document.getElementById("f_url").focus();
 };
@@ -125,7 +126,7 @@ function checkvalue(elm,formname) {
         alert("Nothing to do!");
         el.focus();
         return false;
-    } 
+    }
 }
 
 function submit_form(dothis) {
@@ -138,12 +139,12 @@ function submit_form(dothis) {
     if(dothis == "zip") {
         window.ibrowser.document.dirform.action.value = "zip";
     }
-        
+
     window.ibrowser.document.dirform.submit();
     return false;
 }
-                  
 
+//-->
 </script>
 <style type="text/css">
 html, body {
@@ -180,13 +181,13 @@ form { margin-bottom: 0px; margin-top: 0px; }
       <tr>
         <td width="15%" align="right"><?php print_string("imageurl","editor");?>:</td>
         <td width="60%"><input name="f_url" type="text" id="f_url" style="width: 100%;" /></td>
-        <td width="23%" align="center"> 
+        <td width="23%" align="center">
           <button name="btnOK" type="button" id="btnOK" onclick="return onOK();"><?php print_string("ok","editor") ?></button></td>
       </tr>
       <tr>
         <td align="right"><?php print_string("alternatetext","editor");?>:</td>
         <td><input name="f_alt" type="text" id="f_alt" style="width: 100%;" /></td>
-        <td align="center"> 
+        <td align="center">
           <button name="btnCancel" type="button" id="btnCancel" onclick="return onCancel();"><?php print_string("cancel","editor") ?></button></td>
       </tr>
     </table>
@@ -258,7 +259,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
   </table></form>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
     <tr>
-      <td width="55%" valign="top"><?php 
+      <td width="55%" valign="top"><?php
       if(isteacher($id)) {
           print_string("filebrowser","editor");
       } else {
@@ -274,7 +275,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
     </tr>
   </table>
     <table width="100%" border="0" cellspacing="0" cellpadding="0">
-      <tr> 
+      <tr>
         <td width="55%"><div class="space"></div>
         <?php if(isteacher($id)) { ?>
         <table border="0" cellpadding="2" cellspacing="0">
@@ -293,7 +294,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
           <input name="btnRename" type="submit" id="btnRename" value="<?php print_string("rename","editor");?>" /></form></td>
           <tr></table>
           <br />
-          <?php 
+          <?php
           } else {
               print "";
           } ?>
@@ -302,14 +303,14 @@ form { margin-bottom: 0px; margin-top: 0px; }
           <legend><?php print_string("properties","editor");?></legend>
           <div class="space"></div>
           <div class="space"></div>
-          &nbsp;&nbsp;<?php print_string("size","editor");?>: 
+          &nbsp;&nbsp;<?php print_string("size","editor");?>:
           <input type="text" id="isize" name="isize" size="10" style="background: transparent; border: none;" />
          <?php print_string("type","editor");?>: <input type="text" id="itype" name="itype" size="10" style="background: transparent; border: none;" />
          <div class="space"></div>
          <div class="space"></div>
          </fieldset></td>
     </tr>
-    <tr> 
+    <tr>
       <td height="22"><?php
       if(isteacher($id)) { ?>
           <form name="cfolder" id="cfolder" action="../coursefiles.php" method="post" target="ibrowser">
@@ -328,7 +329,7 @@ form { margin-bottom: 0px; margin-top: 0px; }
           <input type="file" name="userfile" id="userfile" size="35" />
           <input name="save" type="submit" id="save" onclick="return checkvalue('userfile','uploader');" value="<?php print_string("upload","editor");?>" />
           </form>
-          <?php 
+          <?php
           } else {
               print "";
           } ?>
index e284fff15a0a8fc0e1126be94d3e5e4f4db6bb4a..2bdbbf757fa05737dd3a289dac9bf290bbcf3ebf 100644 (file)
@@ -628,7 +628,7 @@ function isstudent($courseid, $userid=0) {
             return (record_exists('user_students', 'userid', $userid)
                      or record_exists('user_teachers', 'userid', $userid));
         }
-    }  
+    }
 
     if (!$userid) {
         return !empty($USER->student[$courseid]);
@@ -860,7 +860,7 @@ function authenticate_user_login($username, $password) {
     } else {
         $auth = $user->auth;
     }
-    
+
     if (!file_exists("$CFG->dirroot/auth/$auth/lib.php")) {
         $auth = "manual";    // Can't find auth module, default to internal
     }
@@ -923,7 +923,7 @@ function enrol_student($userid, $courseid, $timestart=0, $timeend=0) {
         $student->timeend = $timeend;
         $student->time = time();
         return update_record("user_students", $student);
-        
+
     } else {
         $student->userid = $userid;
         $student->course = $courseid;
@@ -1006,7 +1006,7 @@ function add_teacher($userid, $courseid, $editall=1, $role="", $timestart=0, $ti
         $teacher->authority = 1;
     }
     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);
@@ -1070,14 +1070,14 @@ function add_admin($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
             if (!record_exists('user_teachers', 'course', SITEID, 'userid', $userid)) {
                 if (!add_teacher($userid, SITEID)) {
                     return false;
                 }
             }
-            
+
             return insert_record("user_admins", $admin);
         }
         return false;
@@ -1233,8 +1233,8 @@ function remove_course_contents($courseid, $showfeedback=true) {
 function remove_course_userdata($courseid, $showfeedback=true,
                                 $removestudents=true, $removeteachers=false, $removegroups=true,
                                 $removeevents=true, $removelogs=false) {
-/// This function will empty a course of USER data as much as 
-/// possible.   It will retain the activities and the structure 
+/// This function will empty a course of USER data as much as
+/// possible.   It will retain the activities and the structure
 /// of the course.
 
     global $CFG, $THEME, $USER, $SESSION;
@@ -1616,7 +1616,7 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a
             $mail->AddCustomHeader($from->customheaders);
         }
     }
+
     if ($messagehtml) {
         $mail->IsHTML(true);
         $mail->Encoding = "quoted-printable";           // Encoding to use
@@ -1717,7 +1717,7 @@ function send_password_change_confirmation_email($user) {
 
 
 function email_is_not_allowed($email) {
-/// Check that an email is allowed.  It returns an error message if there 
+/// Check that an email is allowed.  It returns an error message if there
 /// was a problem.
 
     global $CFG;
@@ -2748,22 +2748,22 @@ function notify_login_failures() {
             $recip = get_admins();
             break;
     }
-    
+
     if (empty($CFG->lastnotifyfailure)) {
         $CFG->lastnotifyfailure=0;
     }
-    
-    // we need to deal with the threshold stuff first. 
+
+    // we need to deal with the threshold stuff first.
     if (empty($CFG->notifyloginthreshold)) {
         $CFG->notifyloginthreshold = 10; // default to something sensible.
     }
 
-    $notifyipsrs = $db->Execute("SELECT ip FROM {$CFG->prefix}log WHERE time > {$CFG->lastnotifyfailure} 
+    $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} 
+    $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()) {
@@ -2784,11 +2784,11 @@ function notify_login_failures() {
         $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) 
+        if (is_array($recip) and count($recip) > 0 and ((time() - (60 * 60)) > $CFG->lastnotifyfailure)
             and is_array($logs) and count($logs) > 0) {
-       
+
             $message = '';
             $site = get_site();
             $subject = get_string('notifyloginfailuressubject','',$site->fullname);
@@ -3112,7 +3112,7 @@ function address_in_subnet($addr, $subnetstr) {
 }
 
 function mtrace($string, $eol="\n") {
-// For outputting debugging info 
+// For outputting debugging info
 
     if (defined('STDOUT')) {
         fwrite(STDOUT, $string.$eol);
@@ -3132,5 +3132,15 @@ function getremoteaddr() {
     return $ip;
 }
 
+if(!function_exists('html_entity_decode')) {
+// html_entity_decode is only supported by php 4.3.0 and higher
+// so if it is not predefined, define it here
+    function html_entity_decode($string) {
+        $trans_tbl = get_html_translation_table(HTML_ENTITIES);
+        $trans_tbl = array_flip($trans_tbl);
+        return strtr($string, $trans_tbl);
+    }
+}
+
 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
 ?>
index 09aa1470e476140707844928deda303f31ef5df4..79b744c409acf1999eae7c8a9cfae403fd80fd88 100644 (file)
@@ -480,7 +480,7 @@ function popup_form ($common, $options, $formname, $selected="", $nothing="choos
     }
 
     $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";
+    $output = "<select name=\"popup\" onchange=\"$targetwindow.location=document.$formname.popup.options[document.$formname.popup.selectedIndex].value;\">\n";
 
     if ($nothing != "") {
         $output .= "   <option value=\"javascript:void(0)\">$nothing</option>\n";
@@ -1143,10 +1143,13 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
     }
 
     if ($usexml) {       // Added by Gustav Delius / Mad Alex for MathML output
+                         // Modified by Julian Sedding
         $currentlanguage = current_language();
-
-        @header("Content-type: application/xhtml+xml");
-        echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n";
+        $mathplayer = preg_match("/MathPlayer/i", $_SERVER['HTTP_USER_AGENT']);
+        if(!$mathplayer) {
+            header('Content-Type: application/xhtml+xml');
+        }
+        echo "<?xml version=\"1.0\" ?>\n";
         if (!empty($CFG->xml_stylesheets)) {
             $stylesheets = explode(";", $CFG->xml_stylesheets);
             foreach ($stylesheets as $stylesheet) {
@@ -1158,7 +1161,17 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
             echo " plus $CFG->xml_doctype_extra";
         }
         echo "//" . strtoupper($currentlanguage) . "\" \"$CFG->xml_dtd\">\n";
-        $direction = " xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$currentlanguage\" $direction";
+        $direction = " xmlns=\"http://www.w3.org/1999/xhtml\"
+                       xmlns:math=\"http://www.w3.org/1998/Math/MathML\"
+                       xml:lang=\"en\"
+                       xmlns:xlink=\"http://www.w3.org/1999/xlink\"
+                       $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 .= '<?import namespace="math" implementation="#mathplayer" ?>' . "\n";
+        }
     }
 
     $title = str_replace('"', '&quot;', $title);
@@ -2331,21 +2344,28 @@ function notice_yesno ($message, $linkyes, $linkno) {
 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,
+    // however, this is not true for javascript. Therefore we
+    // first decode all entities in $url (since we cannot rely on)
+    // the correct input) and then encode for where it's needed
+    // echo "<script type='text/javascript'>alert('Redirect $url');</script>";
+    $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=$url\" />";
-        echo "<script type=\"text/javascript\">location.replace('$url');</script>";   // To cope with Mozilla bug
+        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
     } 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=$url\" />");
+        print_header("", "", "", "", "<meta http-equiv=\"refresh\" content=\"$delay; url=$encodedurl\" />");
         echo "<center>";
         echo "<p>$message</p>";
-        echo "<p>( <a href=\"$url\">".get_string("continue")."</a> )</p>";
+        echo "<p>( <a href=\"$encodedurl\">".get_string("continue")."</a> )</p>";
         echo "</center>";
         flush();
         sleep($delay);
-        echo "<script type=\"text/javascript\">location.replace('$url');</script>";   // To cope with Mozilla bug
+        echo "<script type=\"text/javascript\">\n<!--\nlocation.replace('$url');\n//-->\n</script>";   // To cope with Mozilla bug
     }
     die;
 }
index a49d23f414c799048bdd8ab13e533e2829ee2d71..bddda6c73d72e3a6c851481680236dfb166678ef 100755 (executable)
@@ -970,7 +970,7 @@ while(true) {
                     continue;
                 }
 
-                if(!ereg('win=(chat|users|message|beep).*&chat_sid=([a-zA-Z0-9]*)&amp;groupid=([0-9]*) HTTP', $data, $info)) {
+                if(!ereg('win=(chat|users|message|beep).*&chat_sid=([a-zA-Z0-9]*)&groupid=([0-9]*) HTTP', $data, $info)) {
                     // Malformed data
                     $DAEMON->trace('UFO with '.$handle.': Request with malformed data; connection closed', E_USER_WARNING);
                     $DAEMON->dismiss_ufo($handle, true, 'Request with malformed data; connection closed');
index c82f47b55c622d71a55d158a4123955537c3885b..afa4e6cda06936ba519dd8aa55673901a4b5ec7a 100644 (file)
@@ -7,7 +7,7 @@ include("../filter.inc.php");
 if ($arsc_my = arsc_getdatafromsid($arsc_sid))
 {
  include("../shared/language/".$arsc_my["language"].".inc.php");
+
  $arsc_user = $arsc_my["user"];
  $arsc_room = $arsc_my["room"];
  if ($arsc_lastid == "")
@@ -16,7 +16,7 @@ if ($arsc_my = arsc_getdatafromsid($arsc_sid))
   $arsc_b = mysql_fetch_array($arsc_result);
   $arsc_lastid = $arsc_b["timeid"];
  }
+
  if ($arsc_my["level"] < 0)
  {
   switch($arsc_my["level"])
@@ -44,9 +44,9 @@ if ($arsc_my = arsc_getdatafromsid($arsc_sid))
   header("Cache-Control: no-cache, must-revalidate");
   header("Pragma: no-cache");
   header("Content-Type: text/html");
-  header("Refresh: 4; url=chatmsg.php?arsc_sid=".$arsc_sid."&arsc_lastid=".$arsc_lastid."&amp;dummy=".time()."#end");
+  header("Refresh: 4; url=chatmsg.php?arsc_sid=".$arsc_sid."&arsc_lastid=".$arsc_lastid."&dummy=".time()."#end");
   echo $arsc_parameters["htmlhead"];
-  
+
   set_magic_quotes_runtime(0);
   $arsc_sendtime = date("H:i:s");
   $arsc_timeid = arsc_microtime();
index b2f4644646e1b29c9fe4c978b302e5d2bc8717d5..c3c7c5329871bcd8edad3e32db5043fe0b314cf9 100644 (file)
@@ -33,7 +33,7 @@ header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
 header("Cache-Control: no-cache, must-revalidate");
 header("Pragma: no-cache");
 header("Content-Type: text/html");
-header("Refresh: $CFG->chat_refresh_room; url=jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&amp;groupid=$groupid");
+header("Refresh: $CFG->chat_refresh_room; url=jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&groupid=$groupid");
 
 ?>
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
@@ -45,8 +45,8 @@ header("Refresh: $CFG->chat_refresh_room; url=jsupdate.php?chat_sid=$chat_sid&ch
      $beep = false;
 
      if ($chat_lasttime) {
-         if ($messages = get_records_select("chat_messages", 
-                                 "chatid = '$chatuser->chatid' AND timestamp > '$chat_lasttime' $groupselect", 
+         if ($messages = get_records_select("chat_messages",
+                                 "chatid = '$chatuser->chatid' AND timestamp > '$chat_lasttime' $groupselect",
                                  "timestamp ASC")) {
              foreach ($messages as $message) {
                  $formatmessage = chat_format_message($message, $chat->course);
index 95e9142b9404c9c7add25f1c7a470bcbba48dee4..fb02373c750ec76a941d0181b8694cbd3a372662 100644 (file)
@@ -29,7 +29,7 @@ if (isset($_GET['chat_enter'])) {
     $message->message = "enter";
     $message->system = 1;
     $message->timestamp = time();
+
     if (!insert_record("chat_messages", $message)) {
         error("Could not insert a chat message!");
     }
@@ -42,7 +42,7 @@ if (isset($_GET['beep'])) {
     $message->message = "beep $beep";
     $message->system = 0;
     $message->timestamp = time();
+
     if (!insert_record("chat_messages", $message)) {
         error("Could not insert a chat message!");
     }
@@ -66,7 +66,7 @@ header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
 header("Cache-Control: no-cache, must-revalidate");
 header("Pragma: no-cache");
 header("Content-Type: text/html");
-header("Refresh: $CFG->chat_refresh_userlist; url=users.php?chat_sid=$chat_sid&amp;groupid=$groupid");
+header("Refresh: $CFG->chat_refresh_userlist; url=users.php?chat_sid=$chat_sid&groupid=$groupid");
 
 print_header();
 
index b638e5b09c6b4839b6d3b93496ea9b008106e8a7..b4c6613766f509fa78c6dd99a31e88c5ba4d91ed 100644 (file)
@@ -27,7 +27,7 @@
         require_login($course->id);
     }
 
-    if (!empty($move)) { 
+    if (!empty($move)) {
         if (!isteacher($course->id)) {
             error("Only teachers can do that!");
         }
     if ($course->category) {
         print_header("$course->shortname: $discussion->name", "$course->fullname",
                  "<a href=../../course/view.php?id=$course->id>$course->shortname</a> ->
-                  $navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm), false);
+                  $navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm));
     } else {
         print_header("$course->shortname: $discussion->name", "$course->fullname",
-                 "$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm), false);
+                 "$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm));
     }
 
 
             }
             if (!empty($forummenu)) {
                 echo "<div align=\"right\">";
-                echo popup_form("$CFG->wwwroot/mod/forum/", $forummenu, "forummenu", "", 
+                echo popup_form("$CFG->wwwroot/mod/forum/", $forummenu, "forummenu", "",
                                  get_string("movethisdiscussionto", "forum"), "", "", true);
                 echo "</div>";
             }
index 1b220837f402f913a81e12fdc9020e847a6a8988..65b5621848dce87dc7b729cadb1d9c10b9e5452a 100644 (file)
@@ -57,8 +57,8 @@
     }
 
 
-    // Parse and organise all the forums.  Most forums are course modules but 
-    // some special ones are not.  These get placed in the general forums 
+    // Parse and organise all the forums.  Most forums are course modules but
+    // some special ones are not.  These get placed in the general forums
     // category with the forums in section 0.
 
     $generalforums = array();            // For now
@@ -91,7 +91,7 @@
                         unset($learningforums[$forum->keyreference]);
                     }
                     break;
-                case "teacher": 
+                case "teacher":
                     if (isteacher($course->id)) {
                         $forum->visible = true;
                         $generalforums[] = $forum;
                         if (isset($forum->keyreference)) {
                             unset($learningforums[$forum->keyreference]);
                         }
-                    } 
+                    }
                     break;
             }
         }
             } else {
                 $groupmode = NOGROUPS;
             }
-                
+
             if ($groupmode == SEPARATEGROUPS and !isteacheredit($course->id)) {
                 $count = count_records_select("forum_discussions", "forum = '$forum->id' AND (groupid = '$currentgroup' OR groupid = '-1')");
             } else {
                 $count = count_records("forum_discussions", "forum", "$forum->id");
             }
-           
+
             $forum->intro = forum_shorten_post($forum->intro);
             replace_smilies($forum->intro);
             $forum->intro = "<span style=\"font-size:x-small;\">$forum->intro</span>";;
                 $generaltable->data[] = array ($forumlink, "$forum->intro", "$count");
             }
         }
-    } 
+    }
 
 
     // Start of the table for Learning Forums
         // Add extra field for section number, at the front
         array_unshift($learningtable->head, "");
         array_unshift($learningtable->align, "center");
-    
+
 
         if ($learningforums) {
             $currentsection = "";
 
             foreach ($learningforums as $key => $forum) {
                 $groupmode = groupmode($course, $forum);  /// Can do this because forum->groupmode is defined
-                
+
                 if ($groupmode == SEPARATEGROUPS and !isteacheredit($course->id)) {
                     $count = count_records("forum_discussions", "forum", "$forum->id", "groupid", $currentgroup);
                 } else {
                     $count = count_records("forum_discussions", "forum", "$forum->id");
                 }
-    
+
                 $forum->intro = forum_shorten_post($forum->intro);
                 replace_smilies($forum->intro);
                 $forum->intro = "<span style=\"font-size:x-small;\">$forum->intro</span>";
-    
+
                 if ($forum->section != $currentsection) {
                     $printsection = $forum->section;
                     if ($currentsection) {
                 } else {
                     $forumlink = "<a class=\"dimmed\" href=\"view.php?f=$forum->id\">$forum->name</a>";
                 }
-    
+
                 if ($can_subscribe) {
                     if (forum_is_forcesubscribed($forum->id)) {
                         $sublink = get_string("yes");
                     "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> -> $strforums",
                     "", "", true, $searchform, navmenu($course));
     } else {
-        print_header("$course->shortname: $strforums", "$course->fullname", "$strforums", 
+        print_header("$course->shortname: $strforums", "$course->fullname", "$strforums",
                     "", "", true, $searchform, navmenu($course));
     }
 
index 0cffcc65a41e6f0fff322863dcdc9c311f4a5e7b..1c1dd153a9ebc0a240109e74bb2f5e6bb5ef222b 100644 (file)
@@ -93,7 +93,7 @@ function forum_add_instance($forum) {
             error("Could not add the discussion for this forum");
         }
     }
-    
+
     if ($forum->forcesubscribe == FORUM_INITIALSUBSCRIBE) { // all users should be subscribed initially
         $users = get_course_users($forum->course);
         foreach ($users as $user) {
@@ -246,7 +246,7 @@ function forum_cron () {
                        "List-id: <moodlecourse{$post->course}@$hostname>",
                        "Message-Id: <moodlepost{$post->id}@$hostname>",
                        "In-Reply-To: <moodlepost{$post->parent}@$hostname>",
-                       "References: <moodlepost{$post->parent}@$hostname>"  
+                       "References: <moodlepost{$post->parent}@$hostname>"
             );
 
 
@@ -318,15 +318,15 @@ function forum_cron () {
                     $posttext = forum_make_mail_text($course, $forum, $discussion, $post, $userfrom, $userto);
                     $posthtml = forum_make_mail_html($course, $forum, $discussion, $post, $userfrom, $userto);
 
-                    if (!$mailresult = email_to_user($userto, $userfrom, $postsubject, $posttext, 
+                    if (!$mailresult = email_to_user($userto, $userfrom, $postsubject, $posttext,
                                                      $posthtml, '', '', $CFG->forum_replytouser)) {
                         mtrace("Error: mod/forum/cron.php: Could not send out mail for id $post->id to user $userto->id".
                              " ($userto->email) .. not trying again.");
-                        add_to_log($course->id, 'forum', 'mail error', "discuss.php?d=$discussion->id#$post->id", 
+                        add_to_log($course->id, 'forum', 'mail error', "discuss.php?d=$discussion->id#$post->id",
                                    substr($post->subject,0,30), $cm->id, $userto->id);
                         $errorcount++;
                     } else if ($mailresult === 'emailstop') {
-                        add_to_log($course->id, 'forum', 'mail blocked', "discuss.php?d=$discussion->id#$post->id", 
+                        add_to_log($course->id, 'forum', 'mail blocked', "discuss.php?d=$discussion->id#$post->id",
                                    substr($post->subject,0,30), $cm->id, $userto->id);
                     } else {
                         $mailcount++;
@@ -353,7 +353,7 @@ function forum_cron () {
 
     /// Now see if there are any digest mails waiting to be sent, and if we should send them
 
-    if (!isset($CFG->digestmailtimelast)) {    // To catch the first time 
+    if (!isset($CFG->digestmailtimelast)) {    // To catch the first time
         set_config('digestmailtimelast', 0);
     }
 
@@ -506,7 +506,7 @@ function forum_cron () {
                 }
                 $posthtml .= '</body>';
 
-                if (!$mailresult =  email_to_user($userto, $site->shortname, $postsubject, $posttext, $posthtml, 
+                if (!$mailresult =  email_to_user($userto, $site->shortname, $postsubject, $posttext, $posthtml,
                                                   '', '', $CFG->forum_replytouser)) {
                     mtrace("ERROR!");
                     echo "Error: mod/forum/cron.php: Could not send out digest mail to user $userto->id ($userto->email)... not trying again.\n";
@@ -1156,7 +1156,7 @@ function forum_get_discussions($forum="0", $forumsort="d.timemodified DESC",
         $userselect = "";
     }
 
-    
+
     if ($visiblegroups == -1) {
         $groupselect = "";
     } else  {
@@ -1271,7 +1271,7 @@ function forum_get_course_forum($courseid, $type) {
             if ($courseid == SITEID) {
                 $forum->name  = get_string("sitenews");
                 $forum->forcesubscribe = 0;
-            }    
+            }
             break;
         case "social":
             $forum->name  = addslashes(get_string("namesocial", "forum"));
@@ -1586,7 +1586,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
 function forum_print_discussion_header(&$post, $forum, $datestring="") {
 /// This function prints the overview of a discussion in the forum listing.
 /// It needs some discussion information and some post information, these
-/// happen to be combined for efficiency in the $post parameter by the function 
+/// happen to be combined for efficiency in the $post parameter by the function
 /// that calls this one
 ///   forum_print_latest_discussions()
 
@@ -2364,7 +2364,7 @@ function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5,
             $groupmode = SEPARATEGROUPS;
         }
     }
-    
+
 
     if (forum_user_can_post_discussion($forum, $currentgroup)) {
         echo "<p align=\"center\">";
@@ -2721,7 +2721,7 @@ function forum_get_recent_mod_activity(&$activities, &$index, $sincetime, $cours
                               WHERE p.modified > '$sincetime' $forumselect
                                 AND p.userid = u.id $userselect
                                 AND d.course = '$courseid'
-                                AND p.discussion = d.id 
+                                AND p.discussion = d.id
                                 AND cm.instance = f.id
                                 AND cm.course = d.course
                                 AND cm.course = f.course
index a6b6507e7818ae6c8236da6026908f95da8c20bb..eaba012a29fa162fd1ad020582f34e94baa6f3d5 100644 (file)
@@ -45,8 +45,8 @@
             $post->id = $post->edit;
             $message = '';
             if (forum_update_post($post,$message)) {
-                
-                add_to_log($post->course, "forum", "update post", 
+
+                add_to_log($post->course, "forum", "update post",
                           "discuss.php?d=$post->discussion&amp;parent=$post->id", "$post->id", $cm->id);
 
                 $timemessage = 2;
                     $timemessage = 4;
                 }
                 $message .= '<br />'.get_string("postupdated", "forum");
-                
+
                 if ($subscribemessage = forum_post_subscription($post)) {
                     $timemessage = 4;
                 }
                 redirect(forum_go_back_to("discuss.php?d=$post->discussion#$post->id"), $message.$subscribemessage, $timemessage);
 
             } else {
-                error(get_string("couldnotupdate", "forum"), $errordestination); 
+                error(get_string("couldnotupdate", "forum"), $errordestination);
             }
             exit;
 
@@ -69,7 +69,7 @@
             $message = '';
             if ($post->id = forum_add_new_post($post,$message)) {
 
-                add_to_log($post->course, "forum", "add post", 
+                add_to_log($post->course, "forum", "add post",
                           "discuss.php?d=$post->discussion&amp;parent=$post->id", "$post->id", $cm->id);
 
                 $timemessage = 2;
@@ -85,7 +85,7 @@
                 redirect(forum_go_back_to("discuss.php?d=$post->discussion#$post->id"), $message.$subscribemessage, $timemessage);
 
             } else {
-                error(get_string("couldnotadd", "forum"), $errordestination); 
+                error(get_string("couldnotadd", "forum"), $errordestination);
             }
             exit;
 
@@ -96,7 +96,7 @@
             $message = '';
             if ($discussion->id = forum_add_discussion($discussion,$message)) {
 
-                add_to_log($post->course, "forum", "add discussion", 
+                add_to_log($post->course, "forum", "add discussion",
                            "discuss.php?d=$discussion->id", "$discussion->id", $cm->id);
 
                 $timemessage = 2;
                     $timemessage = 4;
                 }
                 $message .= '<br />'.get_string("postadded", "forum", format_time($CFG->maxeditingtime));
-                
+
                 if ($subscribemessage = forum_post_subscription($discussion)) {
                     $timemessage = 4;
                 }
                 redirect(forum_go_back_to("view.php?f=$post->forum"), $message.$subscribemessage, $timemessage);
 
             } else {
-                error(get_string("couldnotadd", "forum"), $errordestination); 
+                error(get_string("couldnotadd", "forum"), $errordestination);
             }
             exit;
         }
         if (isset($confirm)) {    // User has confirmed the delete
 
             if ($post->totalscore) {
-                notice(get_string("couldnotdeleteratings", "forum"), 
+                notice(get_string("couldnotdeleteratings", "forum"),
                         forum_go_back_to("discuss.php?d=$post->discussion"));
 
             } else if (record_exists("forum_posts", "parent", $delete)) {
                 }
                 if (! $post->parent) {  // post is a discussion topic as well, so delete discussion
                     if ($forum->type == "single") {
-                        notice("Sorry, but you are not allowed to delete that discussion!", 
+                        notice("Sorry, but you are not allowed to delete that discussion!",
                                 forum_go_back_to("discuss.php?d=$post->discussion"));
                     }
                     forum_delete_discussion($discussion);
 
-                    add_to_log($discussion->course, "forum", "delete discussion", 
+                    add_to_log($discussion->course, "forum", "delete discussion",
                                "view.php?id=$cm->id", "$forum->id", $cm->id);
 
-                    redirect("view.php?f=$discussion->forum", 
+                    redirect("view.php?f=$discussion->forum",
                              get_string("deleteddiscussion", "forum"), 1);
 
                 } else if (forum_delete_post($post)) {
 
-                    add_to_log($discussion->course, "forum", "delete post", 
+                    add_to_log($discussion->course, "forum", "delete post",
                                "discuss.php?d=$post->discussion", "$post->id", $cm->id);
 
-                    redirect(forum_go_back_to("discuss.php?d=$post->discussion"), 
+                    redirect(forum_go_back_to("discuss.php?d=$post->discussion"),
                              get_string("deletedpost", "forum"), 1);
                 } else {
                     error("An error occurred while deleting record $post->id");
             forum_set_return();
 
             print_header();
-            notice_yesno(get_string("deletesure", "forum"), 
+            notice_yesno(get_string("deletesure", "forum"),
                          "post.php?delete=$delete&amp;confirm=$delete",
                          $_SERVER["HTTP_REFERER"]);
-                         
+
             echo "<center><hr />";
             forum_print_post($post, $forum->course, $ownpost=false, $reply=false, $link=false);
             echo "</center>";
 
 
     } else if (isset($prune)) {  // Teacher is pruning
-        
+
         if (! $post = forum_get_post_full($prune)) {
             error("Post ID was incorrect");
         }
         }
 
         if (isset($_REQUEST['name'])) {    // User has confirmed the prune
-            
+
             $newdiscussion->course = $discussion->course;
             $newdiscussion->forum = $discussion->forum;
             $newdiscussion->name = $name;
             $newdiscussion->groupid = $discussion->groupid;
             $newdiscussion->assessed = $discussion->assessed;
             $newdiscussion->usermodified = $post->userid;
-            
+
             if (!$newid = insert_record('forum_discussions', $newdiscussion)) {
                 error('Could not create new discussion');
             }
-            
+
             $newpost->id = $post->id;
             $newpost->parent = 0;
             $newpost->subject = $name;
             }
 
             forum_change_discussionid($post->id, $newid);
-            
+
             // set timemodified to time of last post in each discussion
             $lastpost = get_record_sql("SELECT MAX(modified) AS time
-                                              FROM {$CFG->prefix}forum_posts 
+                                              FROM {$CFG->prefix}forum_posts
                                               WHERE discussion = '$discussion->id'");
             set_field('forum_discussions', 'timemodified', $lastpost->time, 'id', $discussion->id);
             $lastpost = get_record_sql("SELECT MAX(modified) AS time
-                                              FROM {$CFG->prefix}forum_posts 
+                                              FROM {$CFG->prefix}forum_posts
                                               WHERE discussion = '$newid'");
-            set_field('forum_discussions', 'timemodified', $lastpost->time, 'id', $newid);            
+            set_field('forum_discussions', 'timemodified', $lastpost->time, 'id', $newid);
 
 
             if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) { // For the logs
                 $cm->id = 0;
             }
-            add_to_log($discussion->course, "forum", "prune post", 
+            add_to_log($discussion->course, "forum", "prune post",
                            "discuss.php?d=$newid", "$post->id", $cm->id);
 
             redirect(forum_go_back_to("discuss.php?d=$newid"), get_string("prunedpost", "forum"), 1);
             $course = get_record('course', 'id', $forum->course);
             $strforums = get_string("modulenameplural", "forum");
             print_header_simple("$discussion->name: $post->subject", "",
-                         "<a href=\"../forum/index.php?id=$course->id\">$strforums</a> -> 
-                          <a href=\"view.php?f=$forum->id\">$forum->name</a> -> 
+                         "<a href=\"../forum/index.php?id=$course->id\">$strforums</a> ->
+                          <a href=\"view.php?f=$forum->id\">$forum->name</a> ->
                           <a href=\"discuss.php?d=$discussion->id\">$post->subject</a> -> ".
                           get_string("prune", "forum"), '', "", true, "", navmenu($course, $cm));
-            
+
             print_heading(get_string('pruneheading', 'forum'));
             echo '<center>';
-            
+
             include('prune.html');
-                         
+
             forum_print_post($post, $forum->course, $ownpost=false, $reply=false, $link=false);
             echo '</center>';
         }
     }
 
 
-    // To get here they need to edit a post, and the $post 
+    // To get here they need to edit a post, and the $post
     // variable will be loaded with all the particulars,
     // so bring up the form.
 
index 3a278e5b3c3c09038ddf472806a2092b16d8c15f..a6cc0379346c41494e94e801bd6a2ee9d14f0cf6 100644 (file)
@@ -4,10 +4,10 @@
 
     //This is the "graphical" structure of the forum mod:
     //
-    //                           forum                                      
+    //                           forum
     //                        (CL,pk->id)
     //                            |
-    //             -----------------------------------        
+    //             -----------------------------------
     //             |                                 |
     //        subscriptions                    forum_discussions
     //    (UL,pk->id, fk->forum)             (UL,pk->id, fk->forum)
@@ -15,7 +15,7 @@
     //                                               |
     //                                               |
     //                                           forum_posts
-    //                             (UL,pk->id,fk->discussion,nt->parent,files) 
+    //                             (UL,pk->id,fk->discussion,nt->parent,files)
     //                                               |
     //                                               |
     //                                               |
@@ -71,7 +71,7 @@
                     $forum->scale = -($scale->new_id);
                 }
             }
-            
+
             $forumtobeinserted = true;
             //If the forum is a teacher forum, then we have to look if it exists in destination course
             if ($forum->type == "teacher") {
             if ($user) {
                 $post->userid = $user->new_id;
             }
-     
+
             //The structure is equal to the db, so insert the forum_posts
             $newid = insert_record ("forum_posts",$post);
 
 
         //First, locate course's moddata directory
         $moddata_path = $CFG->dataroot."/".$restore->course_id."/".$CFG->moddata;
-  
+
         //Check it exists and create it
         $status = check_dir_exists($moddata_path,true);
 
     //This function returns a log record with all the necessay transformations
     //done. It's used by restore_log_module() to restore modules log.
     function forum_restore_logs($restore,$log) {
-                    
+
         $status = false;
-                    
+
         //Depending of the action, we recode different things
         switch ($log->action) {
         case "add":
                         $status = true;
                     }
                 }
-            }   
+            }
             break;
         case "delete post":
             if ($log->cmid) {
     }
 
     //Return a content decoded to support interactivities linking. Every module
-    //should have its own. They are called automatically from 
+    //should have its own. They are called automatically from
     //forum_decode_content_links_caller() function in each module
     //in the restore process
     function forum_decode_content_links ($content,$restore) {
                 //If it is a link to this course, update the link to its new location
                 if($rec->new_id && $rec2->new_id) {
                     //Now replace it
-                    $result= preg_replace($searchstring,$CFG->wwwroot.'/mod/forum/discuss.php?d='.$rec->new_id.'&amp;parent='.$rec2->new_id,$result);
+                    $result= preg_replace($searchstring,$CFG->wwwroot.'/mod/forum/discuss.php?d='.$rec->new_id.'&parent='.$rec2->new_id,$result);
                 } else {
                     //It's a foreign link so leave it as original
-                    $result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/forum/discuss.php?d='.$old_id.'&amp;parent='.$old_id2,$result);
+                    $result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/forum/discuss.php?d='.$old_id.'&parent='.$old_id2,$result);
                 }
             }
         }
         $status = true;
 
         echo "<ul>";
-  
+
         //FORUM: Decode every POST (message) in the coure
-        
+
         //Check we are restoring forums
         if ($restore->mods['forum']->restore == 1) {
             echo "<li>".get_string("from")." ".get_string("modulenameplural","forum");
                 $i = 0;   //Counter to send some output to the browser to avoid timeouts
                 foreach ($posts as $post) {
                     //Increment counter
-                    $i++; 
+                    $i++;
                     $content = $post->message;
                     $result = forum_decode_content_links($content,$restore);
                     if ($result != $content) {
index d89eaf49ed59bfeb8edb0c441535cda742fe50ac..c4732653827dfba8955c1c61c52b14055d2f857b 100644 (file)
@@ -82,9 +82,9 @@
     function forum_rss_newstuff($forum, $time) {
     // If there is new stuff in the forum since $time then this returns
     // true.  Otherwise it returns false.
-        if ($forum->rsstype == 1) {  
+        if ($forum->rsstype == 1) {
             $items = forum_rss_feed_discussions($forum, $time);
-        } else {             
+        } else {
             $items = forum_rss_feed_posts($forum, $time);
         }
         return (!empty($items));
         if (empty($CFG->enablerssfeeds)) {
             //Some debug...
             if ($CFG->debug > 7) {
-                echo "DISABLED (admin variables)"; 
-            }           
+                echo "DISABLED (admin variables)";
+            }
         //Check CFG->forum_enablerssfeeds
         } else if (empty($CFG->forum_enablerssfeeds)) {
-            //Some debug... 
+            //Some debug...
             if ($CFG->debug > 7) {
                 echo "DISABLED (module configuration)";
-            }           
+            }
         //It's working so we start...
         } else {
             //Check the forum has rss activated
                     $items = forum_rss_feed_discussions($forum);
                 } else {                //Post RSS
                     $items = forum_rss_feed_posts($forum);
-     
+
                 }
                 //Now, if items, we begin building the structure
                 if (!empty($items)) {
                         $status = $header.$articles.$footer;
                     } else {
                         $status = false;
-                    } 
+                    }
                 } else {
                     $status = false;
                 }
             $newsince = "";
         }
 
-        if ($recs = get_records_sql ("SELECT d.id discussionid, 
-                                             d.name discussionname, 
-                                             u.id userid, 
+        if ($recs = get_records_sql ("SELECT d.id discussionid,
+                                             d.name discussionname,
+                                             u.id userid,
                                              u.firstname userfirstname,
                                              u.lastname userlastname,
                                              p.message postmessage,
         }
         return $items;
     }
-    
+
     //This function returns "items" record array to be used to build the rss feed
     //for a Type=posts forum
     function forum_rss_feed_posts($forum, $newsince=0) {
                 $user->lastname = $rec->userlastname;
                 $item->author = fullname($user);
                 $item->pubdate = $rec->postcreated;
-                $item->link = $CFG->wwwroot."/mod/forum/discuss.php?d=".$rec->discussionid."&amp;parent=".$rec->postid;
+                $item->link = $CFG->wwwroot."/mod/forum/discuss.php?d=".$rec->discussionid."&parent=".$rec->postid;
                 $item->description = format_text($rec->postmessage,$rec->postformat,NULL,$forum->course);
                 $items[] = $item;
                 $articlesleft--;
index 513d623603fe2a209134a7fc5e2a6e8e86bbdc5d..262ed7c7e786c46471975c61b740a94008697f82 100644 (file)
@@ -28,7 +28,7 @@
         require_login($course->id);
     }
 
-    add_to_log($course->id, "forum", "search", "search.php?id=$course->id&amp;search=".urlencode($search), $search); 
+    add_to_log($course->id, "forum", "search", "search.php?id=$course->id&amp;search=".urlencode($search), $search);
 
     $strforums = get_string("modulenameplural", "forum");
     $strsearch = get_string("search", "forum");
@@ -40,7 +40,7 @@
     if (!$search) {
         print_header_simple("$strsearch", "",
                  "<a href=\"index.php?id=$course->id\">$strforums</a> -> $strsearch", "search.search",
-                  "", "", "&nbsp;", navmenu($course));
+                  "", "", "&nbsp;", navmenu($course), true);
 
         print_simple_box_start("center");
         echo "<center>";
@@ -59,9 +59,9 @@
 
 
             print_header_simple("$strsearchresults", "",
-                     "<a href=\"index.php?id=$course->id\">$strforums</a> -> 
-                      <a href=\"search.php?id=$course->id\">$strsearch</a> -> \"$search\"", "search.search", 
-                      "", "", "&nbsp;", navmenu($course));
+                     "<a href=\"index.php?id=$course->id\">$strforums</a> ->
+                      <a href=\"search.php?id=$course->id\">$strsearch</a> -> \"$search\"", "search.search",
+                      "", "", "&nbsp;", navmenu($course), true);
             print_heading(get_string("nopostscontaining", "forum", $search));
 
             print_simple_box_start("center");
         }
 
         print_header_simple("$strsearchresults", "",
-                 "<a href=\"index.php?id=$course->id\">$strforums</a> -> 
-                  <a href=\"search.php?id=$course->id\">$strsearch</a> -> \"$search\"", "search.search", 
-                  "", "",  $searchform, navmenu($course));
+                 "<a href=\"index.php?id=$course->id\">$strforums</a> ->
+                  <a href=\"search.php?id=$course->id\">$strsearch</a> -> \"$search\"", "search.search",
+                  "", "",  $searchform, navmenu($course), true);
 
         print_heading("$strsearchresults: $totalcount");
 
         echo "<center>";
-        print_paging_bar($totalcount, $page, $perpage, "search.php?search=$search&amp;id=$course->id&amp;perpage=$perpage&");
+        print_paging_bar($totalcount, $page, $perpage, "search.php?search=$search&amp;id=$course->id&amp;perpage=$perpage&amp;");
         echo "</center>";
 
         foreach ($posts as $post) {
         }
 
         echo "<center>";
-        print_paging_bar($totalcount, $page, $perpage, "search.php?search=".urlencode($search)."&amp;id=$course->id&amp;perpage=$perpage&");
+        print_paging_bar($totalcount, $page, $perpage, "search.php?search=".urlencode($search)."&amp;id=$course->id&amp;perpage=$perpage&amp;");
         echo "</center>";
     }
 
index 9de147ffc8d55152711a2f6871373c09032710e4..67ad3df82d734c1b2272d1b328d4795504fdd665 100644 (file)
@@ -47,7 +47,7 @@
        <a href=\"view.php?f=$forum->id\">$forum->name</a> -> $strsubscribers";
 
     print_header_simple("$strsubscribers", "", "$navigation", 
-        "", "", true, forum_update_subscriptions_button($course->id, $id));
+        "", "", true, forum_update_subscriptions_button($course->id, $id), true);
 
 /// Check to see if groups are being used in this forum
     if ($groupmode = groupmode($course, $cm)) {   // Groups are being used
index 125b1e4b49416b7006153d616526d0bb5cdf196c..3c13d5366f3bffc9e776df5016696375f6ea34f4 100644 (file)
@@ -76,7 +76,7 @@
     }
 
     print_header_simple("$forum->name", "",
-                 "$navigation $forum->name", "", "", true, $buttontext, navmenu($course, $cm));
+                 "$navigation $forum->name", "", "", true, $buttontext, navmenu($course, $cm), true);
 
     if (!$cm->visible and !isteacher($course->id)) {
         notice(get_string("activityiscurrentlyhidden"));
index 97583964ef932d519799c149939e4d0fba86f08d..cd4bc08352071d5c2c5562e46aa0441717d76653 100644 (file)
 
         global $CFG;
 
-        $status = true;    
+        $status = true;
 
         //Get the comments array
         $comments = $info['#']['COMMENTS']['0']['#']['COMMENT'];
                 }
                 backup_flush(300);
             }
-            if ($newid) { 
+            if ($newid) {
                 //We have the newid, update backup_ids
                 backup_putid($restore->backup_unique_code,"glossary_comments",$oldid,$newid);
             } else {
 
         global $CFG;
 
-        $status = true;    
+        $status = true;
 
         //Get the comments array
         $aliases = $info['#']['ALIASES']['0']['#']['ALIAS'];
 
         global $CFG;
 
-        $status = true;     
+        $status = true;
 
         //Get the entryids array
         $entryids = $info['#']['ENTRIES']['0']['#']['ENTRY'];
             //Now, build the GLOSSARY_ENTRIES_CATEGORIES record structure
             $entry_category->categoryid = $new_category_id;
             $entry_category->entryid = backup_todb($ent_info['#']['ENTRYID']['0']['#']);
-            
+
             //We have to recode the entryid field
             $entry = backup_getid($restore->backup_unique_code,"glossary_entries",$entry_category->entryid);
             if ($entry) {
     //This function returns a log record with all the necessay transformations
     //done. It's used by restore_log_module() to restore modules log.
     function glossary_restore_logs($restore,$log) {
-                    
+
         $status = false;
-                    
+
         //Depending of the action, we recode different things
         switch ($log->action) {
         case "add":
                 //Get the new_id of the glossary_entry (to recode the info and url field)
                 $ent = backup_getid($restore->backup_unique_code,"glossary_entries",$log->info);
                 if ($ent) {
-                    $log->url = "view.php?id=".$log->cmid."&amp;mode=entry&amp;hook=".$ent->new_id;
+                    $log->url = "view.php?id=".$log->cmid."&mode=entry&hook=".$ent->new_id;
                     $log->info = $ent->new_id;
                     $status = true;
                 }
                 //Get the new_id of the glossary_entry (to recode the info and url field)
                 $ent = backup_getid($restore->backup_unique_code,"glossary_entries",$log->info);
                 if ($ent) {
-                    $log->url = "view.php?id=".$log->cmid."&amp;mode=entry&amp;hook=".$ent->new_id;
+                    $log->url = "view.php?id=".$log->cmid."&mode=entry&hook=".$ent->new_id;
                     $log->info = $ent->new_id;
                     $status = true;
                 }
                 //Get the new_id of the glossary_entry (to recode the info and url field)
                 $ent = backup_getid($restore->backup_unique_code,"glossary_entries",$log->info);
                 if ($ent) {
-                    $log->url = "showentry.php?id=".$log->cmid."&amp;eid=".$ent->new_id;
+                    $log->url = "showentry.php?id=".$log->cmid."&eid=".$ent->new_id;
                     $log->info = $ent->new_id;
                     $status = true;
                 }
                 //Get the new_id of the glossary_comment (to recode the info field)
                 $com = backup_getid($restore->backup_unique_code,"glossary_comments",$log->info);
                 if ($ent and $com) {
-                    $log->url = "comments.php?id=".$log->cmid."&amp;eid=".$ent->new_id;
+                    $log->url = "comments.php?id=".$log->cmid."&eid=".$ent->new_id;
                     $log->info = $com->new_id;
                     $status = true;
                 }
                 //Get the new_id of the glossary_comment (to recode the info field)
                 $com = backup_getid($restore->backup_unique_code,"glossary_comments",$log->info);
                 if ($ent and $com) {
-                    $log->url = "comments.php?id=".$log->cmid."&amp;eid=".$ent->new_id;
+                    $log->url = "comments.php?id=".$log->cmid."&eid=".$ent->new_id;
                     $log->info = $com->new_id;
                     $status = true;
                 }
                 //Get the new_id of the glossary_comment (to recode the info field)
                 $com = backup_getid($restore->backup_unique_code,"glossary_comments",$log->info);
                 if ($ent and $com) {
-                    $log->url = "comments.php?id=".$log->cmid."&amp;eid=".$ent->new_id;
+                    $log->url = "comments.php?id=".$log->cmid."&eid=".$ent->new_id;
                     $log->info = $com->new_id;
                     $status = true;
                 }
index 8397f0b1eb9f0309a97c59439ff88221affdcb4e..bd24cb0aa5e59fe850c3de6a67d8bd3a8a26d32f 100644 (file)
         if (empty($CFG->enablerssfeeds)) {
             //Some debug...
             if ($CFG->debug > 7) {
-                echo "DISABLED (admin variables)"; 
-            }           
+                echo "DISABLED (admin variables)";
+            }
         //Check CFG->glossary_enablerssfeeds
         } else if (empty($CFG->glossary_enablerssfeeds)) {
-            //Some debug... 
+            //Some debug...
             if ($CFG->debug > 7) {
                 echo "DISABLED (module configuration)";
-            }           
+            }
         //It's working so we start...
         } else {
             //Check the glossary has rss activated
                     $items = glossary_rss_feed_withauthor($glossary);
                 } else {                //Without author RSS
                     $items = glossary_rss_feed_withoutauthor($glossary);
-     
+
                 }
                 //Now, if items, we begin building the structure
                 if (!empty($items)) {
                         $status = $header.$articles.$footer;
                     } else {
                         $status = false;
-                    } 
+                    }
                 } else {
                     $status = false;
                 }
 
         if ($newsince) {
             $newsince = " AND e.timecreated > '$newsince'";
-        } else {        
+        } else {
             $newsince = "";
-        }       
+        }
 
-        if ($recs = get_records_sql ("SELECT e.id entryid, 
-                                             e.concept entryconcept, 
-                                             e.definition entrydefinition, 
-                                             e.format entryformat, 
-                                             e.timecreated entrytimecreated, 
-                                             u.id userid, 
+        if ($recs = get_records_sql ("SELECT e.id entryid,
+                                             e.concept entryconcept,
+                                             e.definition entrydefinition,
+                                             e.format entryformat,
+                                             e.timecreated entrytimecreated,
+                                             u.id userid,
                                              u.firstname userfirstname,
                                              u.lastname userlastname
                                       FROM {$CFG->prefix}glossary_entries e,
                 $user->lastname = $rec->userlastname;
                 $item->author = fullname($user);
                 $item->pubdate = $rec->entrytimecreated;
-                $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&amp;eid=".$rec->entryid;
+                $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&eid=".$rec->entryid;
                 $item->description = format_text($rec->entrydefinition,$rec->entryformat,NULL,$glossary->course);
                 $items[] = $item;
                 $articlesleft--;
                 $user->lastname = $rec->userlastname;
                 //$item->author = fullname($user);
                 $item->pubdate = $rec->entrytimecreated;
-                $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&amp;eid=".$rec->entryid;
+                $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&eid=".$rec->entryid;
                 $item->description = format_text($rec->entrydefinition,$rec->entryformat,NULL,$glossary->course);
                 $items[] = $item;
                 $articlesleft--;
         }
         return $items;
     }
-    
+
 ?>
index 87754baacbd14bc0abefbff1544fbb62e0e29bc3..11a8aa90bea1a1a9dae1e355d97827e4a6852c4d 100644 (file)
@@ -2,10 +2,10 @@
     //This php script contains all the stuff to backup/restore
     //lesson mods
 
-    //This is the "graphical" structure of the lesson mod: 
+    //This is the "graphical" structure of the lesson mod:
     //
     //                                          lesson ----------------------------|
-    //                                       (CL,pk->id)                           | 
+    //                                       (CL,pk->id)                           |
     //                                             |                               |
     //                                             |                         lesson_grades
     //                                             |                  (UL, pk->id,fk->lessonid)
@@ -42,7 +42,7 @@
         $data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
 
         if ($data) {
-            //Now get completed xmlized object   
+            //Now get completed xmlized object
             $info = $data->info;
             //traverse_xmlize($info);                                                              //Debug
             //print_object ($GLOBALS['traverse_array']);                                           //Debug
@@ -66,7 +66,7 @@
             //The structure is equal to the db, so insert the lesson
             $newid = insert_record("lesson", $lesson);
 
-            //Do some output     
+            //Do some output
             echo "<ul><li>".get_string("modulename","lesson")." \"".$lesson->name."\"<br>";
             backup_flush(300);
 
@@ -84,9 +84,9 @@
                 $status = false;
             }
 
-            //Finalize ul        
+            //Finalize ul
             echo "</ul>";
-        
+
         } else {
             $status = false;
         }
 
             //We'll need this later!!
             $oldid = backup_todb($page_info['#']['PAGEID']['0']['#']);
-           
+
             //Now, build the lesson_pages record structure
             $page->lessonid = $lessonid;
             $page->prevpageid = $prevpageid;
             $newid = insert_record ("lesson_pages",$page);
 
             // save the new pageids (needed to fix the absolute jumps in the answers)
-            $newpageid[backup_todb($page_info['#']['PAGEID']['0']['#'])] = $newid; 
-            
+            $newpageid[backup_todb($page_info['#']['PAGEID']['0']['#'])] = $newid;
+
             // fix the forwards link of the previous page
             if ($prevpageid) {
                 if (!set_field("lesson_pages", "nextpageid", $newid, "id", $prevpageid)) {
                 }
             }
             $prevpageid = $newid;
-            
+
             //Do some output
             if (($i+1) % 10 == 0) {
                 echo ".";
                 $status = false;
             }
         }
-        
+
         // we've restored all the pages and answers, we now need to fix the jumps in the
         // answer records if they are absolute
         if ($answers = get_records("lesson_answers", "lessonid", $lessonid)) {
             foreach ($answers as $answer) {
                 if ($answer->jumpto > 0) {
                     // change the absolute page id
-                    if (!set_field("lesson_answers", "jumpto", $newpageid[$answer->jumpto], "id", 
+                    if (!set_field("lesson_answers", "jumpto", $newpageid[$answer->jumpto], "id",
                                 $answer->id)) {
                         error("Lesson restorelib: unable to reset jump");
                     }
                 //traverse_xmlize($grade_info);                         //Debug
                 //print_object ($GLOBALS['traverse_array']);            //Debug
                 //$GLOBALS['traverse_array']="";                        //Debug
-        
+
                 //We'll need this later!!
                 $olduserid = backup_todb($grade_info['#']['USERID']['0']['#']);
 
     //This function returns a log record with all the necessay transformations
     //done. It's used by restore_log_module() to restore modules log.
     function lesson_restore_logs($restore,$log) {
-                
+
         $status = false;
-            
+
         //Depending of the action, we recode different things
         switch ($log->action) {
         case "add":
                 //Get the new_id of the page (to recode the url field)
                 $pag = backup_getid($restore->backup_unique_code,"lesson_pages",$log->info);
                 if ($pag) {
-                    $log->url = "view.php?id=".$log->cmid."&amp;action=navigation&amp;pageid=".$pag->new_id;
+                    $log->url = "view.php?id=".$log->cmid."&action=navigation&pageid=".$pag->new_id;
                     $log->info = $pag->new_id;
                     $status = true;
                 }
index bdf3f46805aa7dd9ec184224c8e520ac3e33e6e6..1d703757ffefc72235d2c9e3f3afe76504683f7a 100644 (file)
@@ -2,13 +2,13 @@
 /// Extended by Michael Schneider
 /// This page prints a particular instance of wiki
 
-    
+
     require_once("../../config.php");
     require_once("lib.php");
-    
+
 
     require_login($course->id);
-    
+
 
     optional_variable($id);    // Course Module ID, or
     optional_variable($page, false);    // Pagename
@@ -16,7 +16,7 @@
     optional_variable($action,"");    // Admin Action
     optional_variable($userid, 0);     // User wiki.
     optional_variable($groupid, 0);    // Group wiki.
-        
+
     if ($id) {
         if (! $cm = get_record("course_modules", "id", $id)) {
             error("Course Module ID was incorrect");
@@ -41,7 +41,7 @@
             error("Course Module ID was incorrect");
         }
     }
-    
+
     /// Build the ewsiki script constant
     $ewbase = 'view.php?id='.$id;
     if (isset($userid) && $userid!=0) $ewbase .= '&amp;userid='.$userid;
     define("EWIKI_SCRIPT", $ewscript);
     if($wiki->ewikiacceptbinary) {
       define("EWIKI_UPLOAD_MAXSIZE", get_max_upload_file_size());
-      define("EWIKI_SCRIPT_BINARY", $ewbase."&amp;binary=");
+      define("EWIKI_SCRIPT_BINARY", $ewbase."&binary=");
     }
-    
-    
+
+
     /// Add the course module 'groupmode' to the wiki object, for easy access.
     $wiki->groupmode = $cm->groupmode;
 
     if(!$action) {
       error(get_string("noadministrationaction","wiki"));
     }
-    
+
     /// Correct Action ?
     if(!in_array($action, array("setpageflags", "removepages", "strippages", "checklinks", "revertpages"))) {
       error("Unknown action '$action'","wiki");
     }
-    
-    
+
+
     /// May the User administrate it ?
     if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false || wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course) === false) {
       error(get_string("notadministratewiki","wiki"));
       if(!($wiki->wtype=="student" || isteacher($course->id))) {
         add_to_log($course->id, "wiki", "hack", "", $wiki->name.": Tried to trick admin.php with action=$action.");
         error("Hack attack detected !");
-      }          
+      }
     }
-            
+
     # Database and Binary Handler
     include_once($CFG->dirroot."/mod/wiki/ewikimoodlelib.php");
     include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php");
-    
+
     /// The wiki_entry->pagename is set to the specified value of the wiki,
     /// or the default value in the 'lang' file if the specified value was empty.
     define("EWIKI_PAGE_INDEX",$wiki_entry->pagename);
 
     /// Validate Form
     if ($form = data_submitted()) {
-      switch($action) {          
+      switch($action) {
         case "revertpages":
               if(!$form->deleteversions || 0 > $form->deleteversions || $form->deleteversions > 1000) {
                 $focus="form.deleteversions";
                 $err->deleteversions=get_string("deleteversionserror","wiki");
-              } 
+              }
               if(!$form->changesfield || 0 > $form->changesfield || $form->changesfield > 100000) {
                 $focus="form.changesfield";
                 $err->changesfield=get_string("changesfielderror","wiki");
-              } 
+              }
               if($form->authorfieldpattern=="") {
                 $focus="form.authorfieldpattern";
                 $err->authorfieldpattern=get_string("authorfieldpatternerror","wiki");
-              } 
+              }
           break;
           default: break;
        }
-    }    
-    
+    }
+
     print_header_simple("$wiki_entry->pagename", "",
                 "<A HREF=\"index.php?id=$course->id\">$strwikis</A> -> <A HREF=\"view.php?id=$id\">$wiki->name</a> ->".
                 get_string("administration","wiki"),
                 $focus, "", true, update_module_button($cm->id, $course->id, $strwiki),
                 navmenu($course, $cm));
 
-    
+
     ////////////////////////////////////////////////////////////
     /// Check if the Form has been submitted and display confirmation
     ////////////////////////////////////////////////////////////
       /// Get additional info
       $addloginfo="";
       switch($action) {
-        case "removepages": 
+        case "removepages":
           $addloginfo=@join(", ", $form->pagestodelete);
-        break; 
+        break;
         case "strippages":
           $addloginfo=@join(", ", $form->pagestostrip);
         break;
         break;
       }
       add_to_log($course->id, "wiki", $action, "admin.php?action=$action&amp;userid=$userid&amp;groupid=$groupid&amp;id=$id", $wiki->name.($addloginfo?": ".$addloginfo:""));
-      $link="admin.php?action=$action".($userid?"&amp;userid=".$userid:"").($groupid?"&amp;groupid=".$groupid:"")."&amp;id=$id&amp;page=$page";            
+      $link="admin.php?action=$action".($userid?"&amp;userid=".$userid:"").($groupid?"&amp;groupid=".$groupid:"")."&amp;id=$id&amp;page=$page";
       switch($action) {
-        case "removepages": 
-            if($form->proceed) {            
+        case "removepages":
+            if($form->proceed) {
               if(!$confirm && $form->pagestodelete) {
                 notice_yesno(get_string("removepagecheck", "wiki")."<br />".join(", ", $form->pagestodelete),
-                  $link."&amp;confirm=".urlencode(join(" ",$form->pagestodelete)), $link);       
+                  $link."&amp;confirm=".urlencode(join(" ",$form->pagestodelete)), $link);
                 print_footer($course);
                 exit;
               }
             }
           break;
         case "strippages":
-            if($form->proceed) {                            
+            if($form->proceed) {
               if(!$confirm && $form->pagestostrip) {
                 $err=array();
                 $strippages=wiki_admin_strip_versions($form->pagestostrip,$form->version, $err);
                 }
                 if(count($err)==0) {
                   notice_yesno(get_string("strippagecheck", "wiki")."<br />".join(", ", $form->pagestostrip),
-                      $link.$confirm, $link);       
+                      $link.$confirm, $link);
                   print_footer($course);
                   exit;
                 }
               }
             }
-            break;            
+            break;
         case "checklinks":
-            if($form->proceed) {              
+            if($form->proceed) {
               if(!$confirm && $form->pagetocheck) {
                 $confirm="&amp;confirm=".$form->pagetocheck;
                 notice_yesno(get_string("checklinkscheck", "wiki").$form->pagetocheck,
-                    $link.$confirm, $link);       
+                    $link.$confirm, $link);
                 print_footer($course);
                 exit;
               }
             }
-            break;            
+            break;
         case "setpageflags":
             // pageflagstatus is used in setpageflags.html
             $pageflagstatus=wiki_admin_setpageflags($form->flags);
-            break;            
-        case "revertpages":              
+            break;
+        case "revertpages":
               if(!$err) {
                 if(!$confirm) {
                   $confirm="&confirm[changesfield]=".urlencode($form->changesfield).
                   $revertedpages=wiki_admin_revert("", $form->authorfieldpattern, $form->changesfield, $form->howtooperate, $form->deleteversions);
                   if($revertedpages) {
                     notice_yesno(get_string("revertpagescheck", "wiki")."<br />".$revertedpages,
-                      $link.$confirm, $link);       
+                      $link.$confirm, $link);
                     print_footer($course);
-                    exit;                
+                    exit;
                   } else {
                     $err->remark=get_string("nochangestorevert","wiki");
                   }
                 }
               }
-            break;            
+            break;
         default: error("No such Wiki-Admin action: $action");
           break;
       }
-    } 
-    
+    }
+
     /// Actions which need a confirmation. If confirmed, do the action
     $redirect="view.php?".($groupid?"&amp;groupid=".$groupid:"").($userid?"&amp;userid=".$userid:"")."&amp;id=$id&amp;page=$page";
     if($confirm && !$err) {
            } else {
              error($ret);
            }
-           exit;        
+           exit;
         case "checklinks":
            $ret=wiki_admin_checklinks($confirm);
            redirect($redirect, get_string("linkschecked","wiki")."<br />".$ret, 5);
-           exit;        
+           exit;
         case "revertpages":
            $revertedpages=wiki_admin_revert(1, $confirm["authorfieldpattern"], $confirm["changesfield"], $confirm["howtooperate"], $confirm["deleteversions"]);
            redirect($redirect, get_string("pagesreverted","wiki"), 1);
            # No confirmation needed
            break;
         default: error("No such action '$action' with confirmation");
-      }    
+      }
     }
-      
+
 
     /// The top row contains links to other wikis, if applicable.
     if ($wiki_list = wiki_get_other_wikis($wiki, $USER, $course, $wiki_entry->id)) {
         echo '<td class="sideblockheading" bgcolor="'.$THEME->cellheading.'" align="right">'
             .get_string('otherwikis', 'wiki').':&nbsp;&nbsp;';
         $script = 'self.location=document.otherwikis.wikiselect.options[document.otherwikis.wikiselect.selectedIndex].value';
-        
+
         /// Add Admin-Action
         reset($wiki_list);
         $wiki_admin_list=array();
           $wiki_admin_list[$key."&amp;action=$action"]=$val;
         }
         choose_from_menu($wiki_admin_list, "wikiselect", $selected, "choose", $script);
-        echo '</td>';        
+        echo '</td>';
         echo '</tr></table>';
         echo '</form>';
 
 
     if ($wiki_entry) {
 
-    
+
         /// Page Actions
         echo '<table border="0" width="100%">';
         echo '<tr>';
 #        echo '<tr><td align="center">';
 #        $specialpages=array("SearchPages", "PageIndex","NewestPages","MostVisitedPages","MostOftenChangedPages","UpdatedPages","FileDownload","FileUpload","OrphanedPages","WantedPages");
 #        wiki_print_page_actions($cm->id, $specialpages, $ewiki_id, $ewiki_action, $wiki->ewikiacceptbinary, $canedit);
-#        echo '</td>';    
+#        echo '</td>';
 
         /// Searchform
-        echo '<td align="center">';    
+        echo '<td align="center">';
         wiki_print_search_form($cm->id, $q, $userid, $groupid, false);
         echo '</td>';
-    
+
         /// Internal Wikilinks
-        
+
         /// TODO: DOES NOT WORK !!!!
         echo '<td align="center">';
         wiki_print_wikilinks_block($cm->id,  $wiki->ewikiacceptbinary);
         echo '</td>';
-    
-        /// Administrative Links       
-        echo '<td align="center">';          
+
+        /// Administrative Links
+        echo '<td align="center">';
         wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $page, $wiki->htmlmode!=2, $course);
         echo '</td>';
-        
+
 #        if($wiki->htmlmode!=2) {
-#          echo '<td align="center">';          
+#          echo '<td align="center">';
 #          helpbutton('formattingrules', get_string('formattingrules', 'wiki'), 'wiki');
 #          echo get_string("formattingrules","wiki");
 #          echo '</td>';
 #        }
-        
+
         echo '</tr></table>';
     }
 
     // The wiki Contents
     print_simple_box_start( "center", "100%", "$THEME->cellcontent", "20");
-    // Do the Action  
+    // Do the Action
     # "setpageflags", "removepages", "strippages", "checklinks", "revertpages"
     print_heading_with_help(get_string($action,"wiki"), $action, "wiki");
-    include $action.".html";    
+    include $action.".html";
     print_simple_box_end();
 
 /// Finish the page
     print_footer($course);
     exit;
-    
+
 ?> 
\ No newline at end of file
index ae5a7270ed6bbaf6ba61fa5a300fcbac4bc48023..1a9931788ae61485759e09d08f093fe0c6402f16 100644 (file)
@@ -12,9 +12,9 @@ $WIKI_TYPES = array ('teacher' =>   get_string('defaultcourseteacher'),
 define("EWIKI_ESCAPE_AT", 0);       # For the algebraic filter
 
 function wiki_add_instance($wiki) {
-/// Given an object containing all the necessary data, 
-/// (defined by the form in mod.html) this function 
-/// will create a new instance and return the id number 
+/// Given an object containing all the necessary data,
+/// (defined by the form in mod.html) this function
+/// will create a new instance and return the id number
 /// of the new instance.
 
     $wiki->timemodified = time();
@@ -36,8 +36,8 @@ function wiki_add_instance($wiki) {
 
 
 function wiki_update_instance($wiki) {
-/// Given an object containing all the necessary data, 
-/// (defined by the form in mod.html) this function 
+/// Given an object containing all the necessary data,
+/// (defined by the form in mod.html) this function
 /// will update an existing instance with new data.
 
     /// Determine the pagename for this wiki.
@@ -60,9 +60,9 @@ function wiki_rmdir($basedir) {
   $handle = @opendir($basedir);
   if($handle) {
     while (false!==($folder = readdir($handle))) {
-       if($folder != "." && $folder != ".." && $Folder != "CVS") { 
+       if($folder != "." && $folder != ".." && $Folder != "CVS") {
           wiki_rmdir("$basedir/$folder");  // recursive
-       } 
+       }
     }
     closedir($handle);
   }
@@ -71,10 +71,10 @@ function wiki_rmdir($basedir) {
 
 function wiki_delete_instance($id) {
 /// Given an ID of an instance of this module,
-/// this function will permanently delete the instance 
-/// and any data that depends on it.  
+/// this function will permanently delete the instance
+/// and any data that depends on it.
     global $CFG;
-    
+
     if (! $wiki = get_record("wiki", "id", $id)) {
         return false;
     }
@@ -94,11 +94,11 @@ function wiki_delete_instance($id) {
               }
           }
           #if (!$exception) {  // Delete directory as well, if empty
-              wiki_rmdir("$basedir");          
+              wiki_rmdir("$basedir");
           #}
-      }      
+      }
     }
-    
+
     # Delete any dependent records here #
     if (! delete_records("wiki", "id", $wiki->id)) {
         $result = false;
@@ -115,7 +115,7 @@ function wiki_delete_instance($id) {
             }
         }
     }
-    
+
     return $result;
 }
 
@@ -137,19 +137,19 @@ function wiki_user_complete($course, $user, $mod, $wiki) {
 }
 
 function wiki_print_recent_activity($course, $isteacher, $timestart) {
-/// Given a course and a time, this module should find recent activity 
-/// that has occurred in wiki activities and print it out. 
+/// Given a course and a time, this module should find recent activity
+/// that has occurred in wiki activities and print it out.
 /// Return true if there was output, or false is there was none.
 
     global $CFG;
 
-    return false;  //  True if anything was printed, otherwise false 
+    return false;  //  True if anything was printed, otherwise false
 }
 
 function wiki_cron () {
 /// Function to be run periodically according to the moodle cron
-/// This function searches for things that need to be done, such 
-/// as sending out mail, toggling flags etc ... 
+/// This function searches for things that need to be done, such
+/// as sending out mail, toggling flags etc ...
 
     global $CFG;
 
@@ -157,7 +157,7 @@ function wiki_cron () {
 }
 
 function wiki_grades($wikiid) {
-/// Must return an array of grades for a given instance of this module, 
+/// Must return an array of grades for a given instance of this module,
 /// indexed by user.  It also returns a maximum allowed grade.
 
     return NULL;
@@ -173,7 +173,7 @@ function wiki_get_participants($wikiid) {
 }
 
 //////////////////////////////////////////////////////////////////////////////////////
-/// Any other wiki functions go here.  Each of them must have a name that 
+/// Any other wiki functions go here.  Each of them must have a name that
 /// starts with wiki_
 
 function wiki_wiki_name($wikiname) {
@@ -202,7 +202,7 @@ function wiki_wiki_name($wikiname) {
 function wiki_is_wiki_name($wikiname) {
 /// Check for correct wikiname syntax and return true or false.
 
-    /// If there are spaces between the words, incorrect format. 
+    /// If there are spaces between the words, incorrect format.
     if (preg_match_all('/\w+/', $wikiname, $out) > 1) {
         return false;
     }
@@ -211,7 +211,7 @@ function wiki_is_wiki_name($wikiname) {
     else if (preg_match_all('/[A-Z]+[a-z_]+/', $wikiname, $out) > 1) {
         return true;
     }
-    else { 
+    else {
         return false;
     }
 }
@@ -278,11 +278,11 @@ function wiki_get_entries(&$wiki, $byindex=NULL) {
 /// Valid values for $byindex are 'student', 'group'.
 
     if ($byindex == 'student') {
-        return get_records('wiki_entries', 'wikiid', $wiki->id, '', 
+        return get_records('wiki_entries', 'wikiid', $wiki->id, '',
                            'userid,id,wikiid,course,groupid,pagename,timemodified');
     }
     else if ($byindex == 'group') {
-        return get_records('wiki_entries', 'wikiid', $wiki->id, '', 
+        return get_records('wiki_entries', 'wikiid', $wiki->id, '',
                            'groupid,id,wikiid,course,userid,pagename,timemodified');
     }
     else {
@@ -433,7 +433,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
                             $pagename = $defpagename;
                         }
 
-                        $key = $ME.'?id='.$id.'&amp;userid='.$student->id.'&amp;page='.$pagename;
+                        $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
                         $wikis[$key] = fullname($student).':'.$pagename;
                     }
                 }
@@ -451,13 +451,13 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
                             $pagename = $defpagename;
                         }
 
-                        $key = $ME.'?id='.$id.'&amp;userid='.$student->id.'&amp;page='.$pagename;
+                        $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
                         $wikis[$key] = fullname($student).':'.$pagename;
                     }
                 }
             }
             else if ($groupmode == VISIBLEGROUPS) {
-                /// Get all students in your group.         
+                /// Get all students in your group.
                 if ($students = get_group_students($mygroupid)) {
                     $defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
                     foreach ($students as $student) {
@@ -468,7 +468,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
                         else {
                             $pagename = $defpagename;
                         }
-                        $key = $ME.'?id='.$id.'&amp;userid='.$student->id.'&amp;page='.$pagename;
+                        $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
                         $wikis[$key] = fullname($student).':'.$pagename;
                     }
                 }
@@ -480,13 +480,13 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
                 $wiki_entries = get_records_sql($sql);
                 $wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
                 foreach ($wiki_entries as $wiki_entry) {
-                    $key = $ME.'?id='.$id.'&amp;userid='.$wiki_entry->userid.'&amp;page='.$wiki_entry->pagename;
+                    $key = $ME.'?id='.$id.'&userid='.$wiki_entry->userid.'&page='.$wiki_entry->pagename;
                     $wikis[$key] = fullname($wiki_entry).':'.$wiki_entry->pagename;
                     if ($currentid == $wiki_entry->id) {
                         $wikis['selected'] = $key;
                     }
                 }
-            } 
+            }
         }
         else {
             /// A user can see other student wikis if they are a member of the same
@@ -512,7 +512,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
                 $wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
                 foreach ($wiki_entries as $wiki_entry) {
                     if (($viewall === true) or ismember($viewall, $wiki_entry->userid)) {
-                        $key = $ME.'?id='.$id.'&amp;userid='.$wiki_entry->userid.'&amp;page='.$wiki_entry->pagename;
+                        $key = $ME.'?id='.$id.'&userid='.$wiki_entry->userid.'&page='.$wiki_entry->pagename;
                         $wikis[$key] = fullname($wiki_entry).':'.$wiki_entry->pagename;
                         if ($currentid == $wiki_entry->id) {
                             $wikis['selected'] = $key;
@@ -543,7 +543,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
                         $pagename = $defpagename;
                     }
 
-                    $key = $ME.'?id='.$id.($group->id?"&amp;groupid=".$group->id:"").'&amp;page='.$pagename;
+                    $key = $ME.'?id='.$id.($group->id?"&groupid=".$group->id:"").'&page='.$pagename;
                     $wikis[$key] = $group->name.':'.$pagename;
                 }
             }
@@ -557,7 +557,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
             $wiki_entries = get_records_sql($sql);
             $wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
             foreach ($wiki_entries as $wiki_entry) {
-                $key = $ME.'?id='.$id.($wiki_entry->groupid?"&amp;groupid=".$wiki_entry->groupid:"").'&amp;page='.$wiki_entry->pagename;
+                $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
                 $wikis[$key] = $wiki_entry->gname.':'.$wiki_entry->pagename;
                 if ($currentid == $wiki_entry->id) {
                     $wikis['selected'] = $key;
@@ -573,7 +573,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
             if ($groupmode and ($isteacheredit or ($isteacher and !$mygroupid))) {
                 if ($groups = get_groups($course->id)) {
                     $defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
-    
+
                     foreach ($groups as $group) {
                         /// If this group already has an entry, use its pagename.
                         if ($wiki_entries[$group->id]) {
@@ -583,7 +583,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
                             $pagename = $defpagename;
                         }
 
-                        $key = $ME.'?id='.$id.($group->id?"&amp;groupid=".$group->id:"").'&amp;page='.$pagename;
+                        $key = $ME.'?id='.$id.($group->id?"&groupid=".$group->id:"").'&page='.$pagename;
                         $wikis[$key] = $group->name.':'.$pagename;
                     }
                 }
@@ -597,7 +597,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
                 $wiki_entries = get_records_sql($sql);
                 $wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
                 foreach ($wiki_entries as $wiki_entry) {
-                    $key = $ME.'?id='.$id.($wiki_entry->groupid?"&amp;groupid=".$wiki_entry->groupid:"").'&amp;page='.$wiki_entry->pagename;
+                    $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
                     $wikis[$key] = $wiki_entry->gname.':'.$wiki_entry->pagename;
                     if ($currentid == $wiki_entry->id) {
                         $wikis['selected'] = $key;
@@ -626,7 +626,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
                 $wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
                 foreach ($wiki_entries as $wiki_entry) {
                     if (($viewall === true) or $viewall == $wiki_entry->groupid) {
-                        $key = $ME.'?id='.$id.($wiki_entry->groupid?"&amp;groupid=".$wiki_entry->groupid:"").'&amp;page='.$wiki_entry->pagename;
+                        $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
                         $wikis[$key] = $wiki_entry->gname.':'.$wiki_entry->pagename;
                         if ($currentid == $wiki_entry->id) {
                             $wikis['selected'] = $key;
@@ -637,7 +637,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
         }
         break;
     }
-    
+
     return $wikis;
 }
 
@@ -732,7 +732,7 @@ function wiki_can_add_entry(&$wiki, &$user, &$course, $userid=0, $groupid=0) {
         }
         /// If not requesting a group, must be a member of a group.
         else if ($groupid == 0) {
-            return ($mygroupid != 0); 
+            return ($mygroupid != 0);
         }
         /// If requesting a group, must be an editing teacher, a non-editing teacher with no assigned group,
         /// or a non-editing teacher requesting their group.
@@ -749,12 +749,12 @@ function wiki_can_add_entry(&$wiki, &$user, &$course, $userid=0, $groupid=0) {
         }
         /// If not requesting a group, must be a member of a group.
         else if ($groupid == 0) {
-            return ($mygroupid != 0 and isteacher($course->id)); 
+            return ($mygroupid != 0 and isteacher($course->id));
         }
-        /// If there is a group mode, non-editing teachers with an assigned group, can only create wikis 
+        /// If there is a group mode, non-editing teachers with an assigned group, can only create wikis
         /// in their group. Non-editing teachers with no assigned group and editing teachers can create any wiki.
         else {
-            return (isteacheredit($course->id) or 
+            return (isteacheredit($course->id) or
                     (isteacher($course->id) and ($mygroupid == 0 or $mygroupid == $groupid)));
         }
         break;
@@ -770,7 +770,7 @@ function wiki_can_edit_entry(&$wiki_entry, &$wiki, &$user, &$course) {
     $groupmode = groupmode($course, $wiki);
     $mygroupid = mygroupid($course->id);
 
-    /// Editing teacher's and admins can edit all wikis, non-editing teachers can edit wikis in their groups, 
+    /// Editing teacher's and admins can edit all wikis, non-editing teachers can edit wikis in their groups,
     /// or all wikis if group mode is 'no groups' or they don't belong to a group.
     if (isadmin($user->id) or isteacheredit($course->id, $user->id) or
         ((!$groupmode or $mygroupid == 0) and isteacher($course->id, $user->id))) {
@@ -834,7 +834,7 @@ function wiki_user_can_access_student_wiki(&$wiki, $userid, &$course) {
     ///     - they are a non-editing teacher and group mode is NOGROUPS.
     ///     - they are an administrator (mostly for site-level wikis).
     if (($userid and ($USER->id == $userid)) or ($groupmode == VISIBLEGROUPS) or
-        (($groupmode == SEPARATEGROUPS) and ismember($usersgroup, $userid)) or 
+        (($groupmode == SEPARATEGROUPS) and ismember($usersgroup, $userid)) or
         (isteacheredit($course->id, $USER->id)) or
         (isteacher($course->id, $USER->id) and (!$usersgroup or ($groupmode == NOGROUPS))) or
         (isadmin())) {
@@ -860,8 +860,8 @@ function wiki_user_can_access_group_wiki(&$wiki, $groupid, &$course) {
     ///     - group mode is SEPARATEGROUPS, and they are a member of the requested group,
     ///     - they are an editing teacher or administrator,
     ///     - they are a non-editing teacher not assigned to a specific group.
-    if (($groupmode == NOGROUPS) or ($groupmode == VISIBLEGROUPS) or 
-        (($groupmode == SEPARATEGROUPS) and ($usersgroup == $groupid)) or 
+    if (($groupmode == NOGROUPS) or ($groupmode == VISIBLEGROUPS) or
+        (($groupmode == SEPARATEGROUPS) and ($usersgroup == $groupid)) or
         (isteacheredit($course->id, $USER->id)) or
         (isteacher($course->id, $USER->id) and !$usersgroup)) {
         $can_access = true;
@@ -883,7 +883,7 @@ function wiki_user_can_access_teacher_wiki(&$wiki, $groupid, &$course) {
     ///     - group mode is VISIBLEGROUPS,
     ///     - group mode is SEPARATEGROUPS, and they are a member of the requested group,
     ///     - they are a teacher or administrator,
-    if (($groupmode == NOGROUPS) or ($groupmode == VISIBLEGROUPS) or 
+    if (($groupmode == NOGROUPS) or ($groupmode == VISIBLEGROUPS) or
         (($groupmode == SEPARATEGROUPS) and (mygroupid($course->id) == $groupid)) or
         (isteacher($course->id, $USER->id))){
         $can_access = true;
@@ -951,7 +951,7 @@ function wiki_print_wikilinks_block($cmid, $binary=false, $return=false) {
    if($binary) {
      $links["FileDownload"]=get_string("filedownload", "wiki");
    }
-   popup_form(EWIKI_SCRIPT, $links, "wikilinks", "", get_string("choosewikilinks", "wiki"), "", "", $return);   
+   popup_form(EWIKI_SCRIPT, $links, "wikilinks", "", get_string("choosewikilinks", "wiki"), "", "", $return);
 }
 
 function wiki_print_page_actions($cmid, $specialpages, $page, $action, $binary=false, $canedit=true) {
@@ -961,7 +961,7 @@ function wiki_print_page_actions($cmid, $specialpages, $page, $action, $binary=f
 
   // Edit this Page
   if (in_array($action, array("edit", "links", "info", "attachments"))) {
-    $page["view/$page"]=get_string("viewpage","wiki");   
+    $page["view/$page"]=get_string("viewpage","wiki");
   }
   if ($canedit && !in_array($page, $specialpages) && $action != "edit") {
     $page["edit/$page"]=get_string("editthispage","wiki");
@@ -976,15 +976,15 @@ function wiki_print_page_actions($cmid, $specialpages, $page, $action, $binary=f
     $page["attachments/$page"]=get_string("attachments","wiki");
   }
 
-  popup_form(EWIKI_SCRIPT, $page, "wikiactions", "", get_string("action", "wiki"), "", "", false);   
+  popup_form(EWIKI_SCRIPT, $page, "wikiactions", "", get_string("action", "wiki"), "", "", false);
 }
 
 function wiki_print_administration_actions($wiki, $cmid, $userid, $groupid, $page, $noeditor, $course) {
 /// Displays actions which can be performed on the page
-  global $ME;        
+  global $ME;
 
-    
-  /// Create the URL        
+
+  /// Create the URL
   $ewscript = 'admin.php?id='.$cmid;
   if (isset($userid) && $userid!=0) $ewscript .= '&amp;userid='.$userid;
   if (isset($groupid) && $groupid!=0) $ewscript .= '&amp;groupid='.$groupid;
@@ -1012,7 +1012,7 @@ function wiki_print_administration_actions($wiki, $cmid, $userid, $groupid, $pag
   if($noeditor) {
     $action["checklinks"]=get_string("checklinks", "wiki");
   }
-  popup_form($ewscript, $action, "wikiadministration", "", get_string("chooseadministration", "wiki"), "", "", false);   
+  popup_form($ewscript, $action, "wikiadministration", "", get_string("chooseadministration", "wiki"), "", "", false);
 }
 
 function wiki_admin_get_flagarray() {
@@ -1024,18 +1024,18 @@ function wiki_admin_get_flagarray() {
      EWIKI_DB_F_READONLY => get_string("flagro","wiki"),
      EWIKI_DB_F_WRITEABLE => get_string("flagwr","wiki"),
   );
-  
+
   return $ret;
 }
 
 ///////// Ewiki Administration. Mostly taken from the ewiki/tools folder and changed
 function wiki_admin_setpageflags_list($pageflagstatus) {
-  $FD = wiki_admin_get_flagarray();    
+  $FD = wiki_admin_get_flagarray();
   $table->head = array(get_string("pagename","wiki"), get_string("flags","wiki"));
   if($pageflagstatus) {
     $table->head[]=get_string("status","wiki");
   }
-  
+
   $result = ewiki_database("GETALL", array("version", "flags"));
   while ($row = $result->get()) {
     $id = $row["id"];
@@ -1049,7 +1049,7 @@ function wiki_admin_setpageflags_list($pageflagstatus) {
         $cell_pagename .= '<A HREF="' . EWIKI_SCRIPT_BINARY . $id . '">';
     }
     $cell_pagename .= htmlentities($id) . '</A> / '.get_string("version","wiki").": ".$row["version"];
-    
+
     foreach ($FD as $n=>$str) {
         $cell_flags .='<INPUT TYPE="checkbox" NAME="flags['. rawurlencode($id)
             . '][' . $n . ']" VALUE="1" '
@@ -1067,9 +1067,9 @@ function wiki_admin_setpageflags_list($pageflagstatus) {
 
 function wiki_admin_setpageflags($pageflags) {
   $FD = wiki_admin_get_flagarray();
-   
+
   $status=array();
-  if($pageflags) {  
+  if($pageflags) {
      foreach($pageflags as $page=>$fa) {
 
         $page = rawurldecode($page);
@@ -1096,14 +1096,14 @@ function wiki_admin_setpageflags($pageflags) {
         }
      }
   }
-  return $status;  
+  return $status;
 }
 
 
 function wiki_admin_remove_list($listall="") {
   /// Table header
   $table->head = array("&nbsp;", get_string("pagename","wiki"), get_string("errororreason","wiki"));
-  
+
   /// Get all pages
   $result = ewiki_database("GETALL", array("version"));
   $selected = array();
@@ -1114,16 +1114,16 @@ function wiki_admin_remove_list($listall="") {
       $selected[$row["id"]] = get_string("listall","wiki")."<br />";
     }
   }
-  while ($page = $result->get()) {            
+  while ($page = $result->get()) {
     $id = $page["id"];
     $page = ewiki_database("GET", array("id"=>$id));
     $flags = $page["flags"];
-    #print "$id ".strlen(trim(($page["content"])))."<br />";           
+    #print "$id ".strlen(trim(($page["content"])))."<br />";
 
     if (!strlen(trim(($page["content"]))) && !($flags & EWIKI_DB_F_BINARY)) {
         @$selected[$id] .= get_string("emptypage","wiki")."<br />";
     }
-    
+
     // Check for orphaned pages
     $result2 = ewiki_database("SEARCH", array("content" => $id));
     $orphanedpage=true;
@@ -1131,7 +1131,7 @@ function wiki_admin_remove_list($listall="") {
         while ($row = $result2->get()) {
           $checkcontent = ewiki_database("GET", array("id"=>$row["id"]));
           $checkcontent = strtolower($checkcontent["content"]);
-          
+
           if(strpos($checkcontent, strtolower($id)) !== false) {
             $orphanedpage=false;
           }
@@ -1140,7 +1140,7 @@ function wiki_admin_remove_list($listall="") {
         }
     }
 
-    /// Some more reasons for Deletion...    
+    /// Some more reasons for Deletion...
     if ($orphanedpage && $id!=EWIKI_PAGE_INDEX &&!($flags & EWIKI_DB_F_BINARY)) {
         @$selected[$id] .= get_string("orphanedpage","wiki")."<br />";
     }
@@ -1177,8 +1177,8 @@ function wiki_admin_remove_list($listall="") {
         @$selected[$id] .= get_string("deletemewikiwordfound","wiki",get_string("deletemewikiword","wiki"))."<br />";
     }
   }
-  
-  foreach ($selected as $id => $reason) {    
+
+  foreach ($selected as $id => $reason) {
     $table_checkbox='<INPUT TYPE="checkbox" VALUE="'.rawurlencode($id).'" NAME="pagestodelete[]" />';
 
     #-- link & id
@@ -1191,16 +1191,16 @@ function wiki_admin_remove_list($listall="") {
 
     #-- print reason
     $table_reason=$reason;
-    
+
     $table->data[]=array($table_checkbox, $table_page, $table_reason);
-  }        
-  
-  return $table;        
+  }
+
+  return $table;
 }
 
 /// This function actually removes the pages
 function wiki_admin_remove($pagestodelete, $course, $wiki, $userid, $groupid) {
-  $ret="";  
+  $ret="";
   foreach ($pagestodelete as $id) {
 
     $id = rawurldecode($id);
@@ -1213,7 +1213,7 @@ function wiki_admin_remove($pagestodelete, $course, $wiki, $userid, $groupid) {
           @unlink("$filepath");
         }
     }
-    
+
   }
   return $ret;
 }
@@ -1221,7 +1221,7 @@ function wiki_admin_remove($pagestodelete, $course, $wiki, $userid, $groupid) {
 function wiki_admin_strip_list($pagestostrip="",$version="",$err="") {
   /// Table header
   $table->head = array("&nbsp;", get_string("pagename","wiki"), get_string("deleteversions","wiki"));
-  
+
   $vc=ewiki_database("COUNTVERSIONS", array());
   $result = ewiki_database("GETALL",array());
   $i=0;
@@ -1231,7 +1231,7 @@ function wiki_admin_strip_list($pagestostrip="",$version="",$err="") {
         $error="";
         if($err[$id]) {
           $error=" ".join(", ",$err[$id]);
-        }        
+        }
         $checked="";
         if($pagestostrip=="" || $pagestostrip[$i]) {
           $checked=" CHECKED";
@@ -1241,10 +1241,10 @@ function wiki_admin_strip_list($pagestostrip="",$version="",$err="") {
         } else {
           $versiondefault=$version[$i];
         }
-        $table->data[]=array('<input type="checkbox" value="'.rawurlencode($id).'" name="pagestostrip['.$i.']" '.$checked.' />', 
+        $table->data[]=array('<input type="checkbox" value="'.rawurlencode($id).'" name="pagestostrip['.$i.']" '.$checked.' />',
                         '<A HREF="'.EWIKI_SCRIPT.$id.'">'.htmlentities($id).'</A> / '.get_string("version","wiki").": ".$row["version"],
                         '<input name="version['.$i.']" value="'.$versiondefault.'" size="7" />'.$error);
-        
+
       }
       $i++;
   }
@@ -1254,16 +1254,16 @@ function wiki_admin_strip_list($pagestostrip="",$version="",$err="") {
 function wiki_admin_strip_versions($pagestostrip, $version, &$err) {
   $ret=array();
   foreach ($pagestostrip as $key => $id_ue) {
-    
+
     $id = rawurldecode($id_ue);
     if (preg_match('/^(\d+)[-\s._:]+(\d+)$/', trim($version[$key]), $uu)) {
       $versA = $uu[1];
       $versZ = $uu[2];
-      
+
       // Let the last Version in the database
       $checkdata = ewiki_database("GET", array("id" => $id));
       if($versZ>=$checkdata["version"]) {
-            $err[$id][] = get_string("versionrangetoobig","wiki");                                
+            $err[$id][] = get_string("versionrangetoobig","wiki");
       } else {
         if($versA<=$versZ) {
           for ($v=$versA; $v<=$versZ; $v++) {
@@ -1280,7 +1280,7 @@ function wiki_admin_strip_versions($pagestostrip, $version, &$err) {
   }
   return $ret;
 }
-  
+
 function wiki_admin_strip($pagestostrip) {
   /// Purges old page-versions
   foreach($pagestostrip as $id => $versions) {
@@ -1288,7 +1288,7 @@ function wiki_admin_strip($pagestostrip) {
       ewiki_database("DELETE", array("id"=>$id, "version"=>$version));
     }
   }
-}  
+}
 
 function wiki_admin_checklinks_list() {
   $ret=array();
@@ -1308,7 +1308,7 @@ function wiki_admin_checklinks($pagetocheck) {
   if($pagetocheck) {
      $get = ewiki_database("GET", array("id" => $pagetocheck));
      $content = $get["content"];
-     
+
      preg_match_all('_(http.?://[^\s"\'<>#,;]+[^\s"\'<>#,;.])_', $content, $links);
      $badlinks = array();
      if(!$links[1]) {
@@ -1316,7 +1316,7 @@ function wiki_admin_checklinks($pagetocheck) {
      } else {
        foreach ($links[1] as $href) {
           #print "[ $href ]";
-          #$d = @implode("", @file($href));        
+          #$d = @implode("", @file($href));
           $d="";
           if($checkfd = @fopen($href, 'r')) {
             fclose($checkfd);
@@ -1328,9 +1328,9 @@ function wiki_admin_checklinks($pagetocheck) {
           } else {
              $ret.="[".get_string("linkok","wiki")."] $href <br />\n";
           }
-       }     
+       }
      }
-     
+
      /// Remove old Notices
      $content = eregi_replace(' µµ__~\['.get_string("offline","wiki").'\]__µµ ','', $content);
 
@@ -1358,7 +1358,7 @@ function wiki_admin_revert($proceed, $authorfieldpattern, $changesfield, $howtoo
   $m_time = $changesfield * 3600;
   $depth = $deleteversions - 1;
   $depth = ($depth>0?$depth:0);
-  
+
   #-- walk through
   $result = ewiki_database("GETALL", array("id", "author", "lastmodified"));
   while ($row = $result->get()) {
@@ -1370,7 +1370,7 @@ function wiki_admin_revert($proceed, $authorfieldpattern, $changesfield, $howtoo
     }
     else {
       $verA = $verZ-$depth;
-      if ($verA <= 0) { 
+      if ($verA <= 0) {
           $verA = 1;
       }
     }
index 45977916acc49df86b6feb67730c7463877862d5..e276d669e90505312b414ef27678372b3197cead 100644 (file)
@@ -81,8 +81,8 @@
         global $ewiki_title;
 
 ///     #-- predefine some of the configuration constants
-        
-        
+
+
         /// EWIKI_NAME is defined in ewikimoodlelibs, so that also admin.php can use this
         #define("EWIKI_NAME", $wiki_entry->pagename);
 
@@ -90,7 +90,7 @@
         if($ewiki_title=="SearchPages") {
             $qArgument="&amp;q=".urlencode($q);
         }
+
         /// Build the ewsiki script constant
         /// ewbase will also be needed by EWIKI_SCRIPT_BINARY
         $ewbase = $ME.'?id='.$moodleID;
         # Binary Handling
         if($wiki->ewikiacceptbinary) {
             define("EWIKI_UPLOAD_MAXSIZE", get_max_upload_file_size());
-            define("EWIKI_SCRIPT_BINARY", $ewbase."&amp;binary=");
+            define("EWIKI_SCRIPT_BINARY", $ewbase."&binary=");
             define("EWIKI_ALLOW_BINARY",1);
             define("EWIKI_IMAGE_CACHING",1);
             #define("EWIKI_AUTOVIEW",1);
         # The mighty Wiki itself
         include_once($CFG->dirroot."/mod/wiki/ewiki/ewiki.php");
 
-        if($canceledit) {          
+        if($canceledit) {
           if ($delim = strpos($page, EWIKI_ACTION_SEP_CHAR)) {
             @$page = substr($page, $delim + 1);
           } else {
             $moodle_format=FORMAT_HTML;
         }
         if($wiki->htmlmode == 2) {
-            # HTML Only 
+            # HTML Only
             $moodle_format=FORMAT_HTML;
             $ewiki_use_editor=1;
             $ewiki_config["htmlentities"]=array(); // HTML is allowed
     if(!isset($ewiki_title)) {
           $ewiki_title="";
     }
-        
+
 /// Moodle Log
     add_to_log($course->id, "wiki", $ewiki_action, "view.php?id=$cm->id&amp;groupid=$groupid&amp;userid=$userid&amp;page=$page", $wiki->name." ".$ewiki_title);
 
             .get_string('otherwikis', 'wiki').':&nbsp;&nbsp;';
         $script = 'self.location=document.otherwikis.wikiselect.options[document.otherwikis.wikiselect.selectedIndex].value';
         choose_from_menu($wiki_list, "wikiselect", $selected, "choose", $script);
-        echo '</td>';        
+        echo '</td>';
         echo '</tr></table>';
         echo '</form>';
 
     /// Page Actions
         echo '<table border="0" width="100%">';
         echo '<tr>';
-        
+
         /// Searchform
-        echo '<td align="center">';    
+        echo '<td align="center">';
         wiki_print_search_form($cm->id, $q, $userid, $groupid, false);
         echo '</td>';
-    
+
         /// Internal Wikilinks
         echo '<td align="center">';
         wiki_print_wikilinks_block($cm->id,  $wiki->ewikiacceptbinary);
         echo '</td>';
-    
+
         /// Administrative Links
         if($canedit) {
-          echo '<td align="center">';          
+          echo '<td align="center">';
           wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $ewiki_title, $wiki->htmlmode!=2, $course);
           echo '</td>';
         }
-        
+
         /// Formatting Rules
-        echo '<td align="right">';          
+        echo '<td align="right">';
         helpbutton('howtowiki', get_string('howtowiki', 'wiki'), 'wiki');
         echo '</td>';
-        
+
         echo '</tr></table>';
     }
 
           print "<br />";
       }
     }
-    
+
     // The wiki Contents
 
     if (!empty($canedit)) {   /// Print tabs with commands for this page
         }
         foreach ($tabs as $tab) {
             $tabname = get_string("tab$tab", 'wiki');
-            if ($ewiki_action != "$tab" && !in_array($page, $specialpages)) {          
+            if ($ewiki_action != "$tab" && !in_array($page, $specialpages)) {
                 echo '<td class="generaltab" '.$tabstyle.' bgcolor="'.$THEME->cellheading.'">';
                 echo '<a href="'.$ewbase.'&amp;page='.$tab.'/'.$ewiki_id.'">'.$tabname.'</a>';
                 echo '</td>';
index f55aa79ba19cc4c61bb6ca4908f121667bcce5ba..ab6122275bbe4a621291cc50fc0af4c050458b7e 100644 (file)
@@ -6,7 +6,7 @@
     require_variable($id);       // user id
     require_variable($course);   // course id
 
-    
+
 
     if (! $user = get_record("user", "id", $id)) {
         error("User ID was incorrect");
@@ -17,7 +17,7 @@
     }
 
     if ($user->confirmed and user_not_fully_set_up($user)) {
-        // Special case which can only occur when a new account 
+        // Special case which can only occur when a new account
         // has just been created by EXTERNAL authentication
         // This is the only page in Moodle that has the exception
         // so that users can set up their accounts
@@ -91,7 +91,7 @@
 
         } else {
             $timenow = time();
-            
+
             if (!$usernew->picture = save_profile_image($user->id,$um,'users')) {
                 if (!empty($usernew->deletepicture)) {
                     set_field('user', 'picture', 0, 'id', $user->id);  /// Delete picture
                     $usernew->picture = $user->picture;
                 }
             }
-            
+
             $usernew->timemodified = time();
-            
+
             if (isadmin()) {
                 if (!empty($usernew->newpassword)) {
                     $usernew->password = md5($usernew->newpassword);
                         unset($USER->newadminuser);
                         redirect("$CFG->wwwroot/", get_string("changessaved"));
                     }
-                    redirect("$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id", get_string("changessaved"));
+                    redirect("$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id", get_string("changessaved"));
                 } else {
                     redirect("$CFG->wwwroot/$CFG->admin/user.php", get_string("changessaved"));
                 }
             }
         }
     }
-    
+
 /// Otherwise fill and print the form.
 
     $streditmyprofile = get_string("editmyprofile");
         }
         if ($course->category) {
             print_header("$course->shortname: $streditmyprofile", "$course->fullname: $streditmyprofile",
-                        "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> 
+                        "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
                         -> <a href=\"index.php?id=$course->id\">$strparticipants</a>
-                        -> <a href=\"view.php?id=$user->id&amp;course=$course->id\">$userfullname</a> 
+                        -> <a href=\"view.php?id=$user->id&amp;course=$course->id\">$userfullname</a>
                         -> $streditmyprofile", "");
         } else {
             if (isset($USER->newadminuser)) {
                 print_header();
             } else {
                 print_header("$course->shortname: $streditmyprofile", "$course->fullname",
-                             "<a href=\"view.php?id=$user->id&amp;course=$course->id\">$userfullname</a> 
+                             "<a href=\"view.php?id=$user->id&amp;course=$course->id\">$userfullname</a>
                               -> $streditmyprofile", "");
             }
         }
@@ -280,7 +280,7 @@ function find_form_errors(&$user, &$usernew, &$err, &$um) {
             $err["email"] = get_string("emailexists");
         }
     }
-    
+
     if (empty($err["email"]) and !isadmin()) {
         if ($error = email_is_not_allowed($usernew->email)) {
             $err["email"] = $error;
index ef402d95c9b65e1820674c4f92062742e55a7eea..0abf0433e51eeed40afaf0a8e4e7fee9ed3f9b76 100644 (file)
         echo "<center><p align=\"center\">";
         echo get_string("firstname")." : ";
         if ($firstinitial) {
-            echo " <a href=\"index.php?id=$course->id&amp;sort=firstname&amp;dir=ASC&".
+            echo " <a href=\"index.php?id=$course->id&amp;sort=firstname&amp;dir=ASC&amp;".
                    "perpage=$perpage&amp;lastinitial=$lastinitial\">$strall</a> ";
         } else {
             echo " <b>$strall</b> ";
             if ($letter == $firstinitial) {
                 echo " <b>$letter</b> ";
             } else {
-                echo " <a href=\"index.php?id=$course->id&amp;sort=firstname&amp;dir=ASC&".
+                echo " <a href=\"index.php?id=$course->id&amp;sort=firstname&amp;dir=ASC&amp;".
                        "perpage=$perpage&amp;lastinitial=$lastinitial&amp;firstinitial=$letter\">$letter</a> ";
             }
         }
 
         echo get_string("lastname")." : ";
         if ($lastinitial) {
-            echo " <a href=\"index.php?id=$course->id&amp;sort=lastname&amp;dir=ASC&".
+            echo " <a href=\"index.php?id=$course->id&amp;sort=lastname&amp;dir=ASC&amp;".
                    "perpage=$perpage&amp;firstinitial=$firstinitial\">$strall</a> ";
         } else {
             echo " <b>$strall</b> ";
             if ($letter == $lastinitial) {
                 echo " <b>$letter</b> ";
             } else {
-                echo " <a href=\"index.php?id=$course->id&amp;sort=lastname&amp;dir=ASC&".
+                echo " <a href=\"index.php?id=$course->id&amp;sort=lastname&amp;dir=ASC&amp;".
                        "perpage=$perpage&amp;firstinitial=$firstinitial&amp;lastinitial=$letter\">$letter</a> ";
             }
         }
         echo "</center>";
 
         print_paging_bar($matchcount, $page, $perpage,
-                         "index.php?id=$course->id&amp;sort=$sort&amp;dir=$dir&amp;perpage=$perpage&amp;firstinitial=$firstinitial&amp;lastinitial=$lastinitial&");
+                         "index.php?id=$course->id&amp;sort=$sort&amp;dir=$dir&amp;perpage=$perpage&amp;firstinitial=$firstinitial&amp;lastinitial=$lastinitial");
 
     }
 
     } else if ($matchcount > 0) {
         print_user_table($students, $isteacher);
         print_paging_bar($matchcount, $page, $perpage,
-                         "index.php?id=$course->id&amp;sort=$sort&amp;dir=$dir&amp;perpage=$perpage&amp;firstinitial=$firstinitial&amp;lastinitial=$lastinitial&");
+                         "index.php?id=$course->id&amp;sort=$sort&amp;dir=$dir&amp;perpage=$perpage&amp;firstinitial=$firstinitial&amp;lastinitial=$lastinitial");
 
         if ($perpage < $totalcount) {
             echo "<center><p>";
index a2db5b9bdaa152b585f8e66587f2f03eb75b5c30..8c249a25d942a91cae215cf641213732fb7bbb6c 100644 (file)
@@ -28,7 +28,7 @@
         require_login();
     }
 
-    add_to_log($course->id, "user", "view", "view.php?id=$user->id&amp;course=$course->id", "$user->id");
+    add_to_log($course->id, "user", "view", "view.php?id=$user->id&course=$course->id", "$user->id");
 
     if ($student = get_record("user_students", "userid", $user->id, "course", $course->id)) {
         $user->lastaccess = $student->timeaccess;