Merge branch 'w33_MDL-28554_m22_yui' of github.com:skodak/moodle
authorPetr Skoda <commits@skodak.org>
Wed, 24 Aug 2011 13:01:50 +0000 (15:01 +0200)
committerPetr Skoda <commits@skodak.org>
Wed, 24 Aug 2011 13:01:50 +0000 (15:01 +0200)
152 files changed:
admin/langimport.php
admin/report/capability/index.php
admin/report/customlang/edit.php
admin/report/unittest/dbtest.php
blocks/html/block_html.php
calendar/renderer.php
enrol/database/cli/sync.php
enrol/database/lib.php
enrol/imsenterprise/lib.php
enrol/manual/lib.php
enrol/self/lib.php
group/index.php
install.php
lang/en/webservice.php
lib/adminlib.php
lib/ajax/section_classes.js
lib/completion/completion_criteria_activity.php
lib/completion/completion_criteria_duration.php
lib/db/install.xml
lib/db/upgrade.php
lib/filelib.php
lib/formslib.php
lib/moodlelib.php
lib/outputrenderers.php
lib/outputrequirementslib.php
lib/questionlib.php
lib/setup.php
lib/simpletest/testmoodlelib.php
lib/upgradelib.php
lib/uploadlib.php
login/forgot_password.php
mod/choice/report.php
mod/choice/view.php
mod/data/field/checkbox/field.class.php
mod/data/field/multimenu/field.class.php
mod/forum/lib.php
mod/quiz/attempt.php
mod/quiz/locallib.php
mod/quiz/processattempt.php
mod/quiz/renderer.php
mod/quiz/report/grading/report.php
mod/quiz/report/overview/report.php
mod/quiz/report/responses/report.php
mod/quiz/review.php
mod/scorm/lang/en/scorm.php
mod/scorm/player.php
mod/scorm/report/basic/report.php
mod/scorm/userreport.php
mod/upgrade.txt
question/engine/upgrade/behaviourconverters.php
question/engine/upgrade/upgradelib.php
question/qengine.js
question/type/calculated/question.php
question/type/calculated/simpletest/helper.php
question/type/calculated/simpletest/testquestion.php
question/type/calculatedmulti/question.php
question/type/match/styles.css [new file with mode: 0644]
question/type/multianswer/edit_multianswer_form.php
question/type/multianswer/questiontype.php
question/type/multianswer/simpletest/testquestiontype.php
question/type/multichoice/db/upgradelib.php
question/type/multichoice/questiontype.php
question/type/multichoice/simpletest/testquestiontype.php
repository/filepicker.php
repository/lib.php
repository/repository_ajax.php
repository/upload/lib.php
tag/manage.php
theme/afterburner/layout/default.php
theme/afterburner/layout/embedded.php
theme/afterburner/version.php [new file with mode: 0644]
theme/anomaly/layout/general.php
theme/anomaly/layout/report.php
theme/anomaly/version.php [new file with mode: 0644]
theme/arialist/layout/frontpage.php
theme/arialist/layout/general.php
theme/arialist/layout/report.php
theme/arialist/version.php [new file with mode: 0644]
theme/base/layout/embedded.php
theme/base/layout/frontpage.php
theme/base/layout/general.php
theme/base/layout/report.php
theme/base/version.php [new file with mode: 0644]
theme/binarius/layout/frontpage.php
theme/binarius/layout/general.php
theme/binarius/layout/report.php
theme/binarius/version.php [new file with mode: 0644]
theme/boxxie/layout/embedded.php
theme/boxxie/layout/frontpage.php
theme/boxxie/layout/general.php
theme/boxxie/version.php [new file with mode: 0644]
theme/brick/layout/frontpage.php
theme/brick/layout/general.php
theme/brick/version.php [new file with mode: 0644]
theme/canvas/layout/embedded.php
theme/canvas/layout/frontpage.php
theme/canvas/layout/general.php
theme/canvas/layout/report.php
theme/canvas/version.php [new file with mode: 0644]
theme/formal_white/layout/embedded.php
theme/formal_white/layout/frontpage.php
theme/formal_white/layout/general.php
theme/formal_white/version.php
theme/formfactor/layout/embedded.php
theme/formfactor/layout/frontpage.php
theme/formfactor/layout/general.php
theme/formfactor/version.php [new file with mode: 0644]
theme/fusion/layout/frontpage.php
theme/fusion/layout/general.php
theme/fusion/version.php [new file with mode: 0644]
theme/image.php
theme/javascript.php
theme/leatherbound/layout/frontpage.php
theme/leatherbound/layout/general.php
theme/leatherbound/layout/report.php
theme/leatherbound/version.php [new file with mode: 0644]
theme/magazine/layout/embedded.php
theme/magazine/layout/frontpage.php
theme/magazine/layout/general.php
theme/magazine/version.php [new file with mode: 0644]
theme/nimble/layout/frontpage.php
theme/nimble/layout/general.php
theme/nimble/version.php [new file with mode: 0644]
theme/nonzero/layout/frontpage.php
theme/nonzero/layout/general.php
theme/nonzero/version.php [new file with mode: 0644]
theme/overlay/layout/frontpage.php
theme/overlay/layout/general.php
theme/overlay/version.php [new file with mode: 0644]
theme/serenity/layout/embedded.php
theme/serenity/layout/frontpage.php
theme/serenity/layout/general.php
theme/serenity/version.php [new file with mode: 0644]
theme/sky_high/layout/frontpage.php
theme/sky_high/layout/general.php
theme/sky_high/layout/report.php
theme/sky_high/version.php [new file with mode: 0644]
theme/splash/layout/general.php
theme/splash/layout/report.php
theme/splash/version.php [new file with mode: 0644]
theme/standard/version.php [new file with mode: 0644]
theme/standardold/layout/embedded.php
theme/standardold/layout/frontpage.php
theme/standardold/layout/general.php
theme/standardold/version.php [new file with mode: 0644]
theme/styles.php
theme/yui_combo.php
user/addnote.php
user/groupaddnote.php
user/selector/lib.php
version.php
webservice/lib.php

index 4aa614b..713f608 100644 (file)
@@ -43,7 +43,7 @@ if (!empty($CFG->skiplangupgrade)) {
 }
 
 $mode          = optional_param('mode', 0, PARAM_INT);              // action
-$pack          = optional_param('pack', array(), PARAM_SAFEDIR);    // pack to install
+$pack          = optional_param_array('pack', array(), PARAM_SAFEDIR);    // pack to install
 $uninstalllang = optional_param('uninstalllang', '', PARAM_LANG);   // installed pack to uninstall
 $confirm       = optional_param('confirm', 0, PARAM_BOOL);          // uninstallation confirmation
 
index c6afaf3..71ba109 100644 (file)
@@ -18,7 +18,7 @@ require_capability('moodle/role:manage', $systemcontext);
 
 // Get URL parameters.
 $capability = optional_param('capability', '', PARAM_CAPABILITY);
-$roleids = optional_param('roles', array('0'), PARAM_INTEGER);
+$roleids = optional_param_array('roles', array('0'), PARAM_INTEGER);
 
 // Clean the passed in list of role ids. If 'All' selected as an option, or
 // if none were selected, do all roles.
index 6e9a7f2..99c2ed9 100644 (file)
@@ -59,8 +59,8 @@ if ($filter->is_cancelled()) {
 }
 
 if ($translatorsubmitted) {
-    $strings = optional_param('cust', array(), PARAM_RAW);
-    $updates = optional_param('updates', array(), PARAM_INT);
+    $strings = optional_param_array('cust', array(), PARAM_RAW);
+    $updates = optional_param_array('updates', array(), PARAM_INT);
     $checkin = optional_param('savecheckin', false, PARAM_RAW);
 
     if ($checkin === false) {
index 63060a1..ae57bcf 100644 (file)
@@ -14,7 +14,7 @@ require_once('ex_reporter.php');
 
 $showpasses   = optional_param('showpasses', false, PARAM_BOOL);
 $codecoverage = optional_param('codecoverage', false, PARAM_BOOL);
-$selected     = optional_param('selected', array(), PARAM_INT);
+$selected     = optional_param_array('selected', array(), PARAM_INT);
 
 // Print the header and check access.
 admin_externalpage_setup('reportdbtest');
index cab89ac..bead128 100644 (file)
@@ -62,7 +62,14 @@ class block_html extends block_base {
         if (isset($this->config->text)) {
             // rewrite url
             $this->config->text = file_rewrite_pluginfile_urls($this->config->text, 'pluginfile.php', $this->context->id, 'block_html', 'content', NULL);
-            $this->content->text = format_text($this->config->text, $this->config->format, $filteropt);
+            // Default to FORMAT_HTML which is what will have been used before the
+            // editor was properly implemented for the block.
+            $format = FORMAT_HTML;
+            // Check to see if the format has been properly set on the config
+            if (isset($this->config->format)) {
+                $format = $this->config->format;
+            }
+            $this->content->text = format_text($this->config->text, $format, $filteropt);
         } else {
             $this->content->text = '';
         }
index 50a3090..e9ba82d 100644 (file)
@@ -432,7 +432,29 @@ class core_calendar_renderer extends plugin_renderer_base {
         $week = 1;
         $dayweek = $startwday;
 
+        // Create an array of all the week days.
+        $wdays = array(0 => '<strong>'. get_string('sunday', 'calendar'). '</strong>',
+                       1 => '<strong>'. get_string('monday', 'calendar'). '</strong>',
+                       2 => '<strong>'. get_string('tuesday', 'calendar'). '</strong>',
+                       3 => '<strong>'. get_string('wednesday', 'calendar'). '</strong>',
+                       4 => '<strong>'. get_string('thursday', 'calendar'). '</strong>',
+                       5 => '<strong>'. get_string('friday', 'calendar'). '</strong>',
+                       6 => '<strong>'. get_string('saturday', 'calendar'). '</strong>');
+
+        // Loop only if the day offset is greater than 0.
+        // This loop involves shifting the days around until the desired start day
+        // is at the start of the array.
+        $daycount = 0;
+        while ($display->minwday > $daycount++) {
+            $wdays_end = array_shift($wdays);
+            array_push($wdays, $wdays_end);
+        }
+
+        // Now we set the (modified) array to the table header to be displayed.
+        $table->head = $wdays;
+
         $row = new html_table_row(array());
+
         // Paddding (the first week may have blank days in the beginning)
         for($i = $display->minwday; $i < $startwday; ++$i) {
             $cell = new html_table_cell('&nbsp;');
index 79af47d..0054c0a 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
 define('CLI_SCRIPT', true);
 
 require(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
+require_once($CFG->libdir.'/clilib.php');
 
-if (!enrol_is_enabled('database')) {
-     die('enrol_database plugin is disabled, sync is disabled');
+// now get cli options
+list($options, $unrecognized) = cli_get_params(array('verbose'=>false, 'help'=>false), array('v'=>'verbose', 'h'=>'help'));
+
+if ($unrecognized) {
+    $unrecognized = implode("\n  ", $unrecognized);
+    cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
 }
 
+if ($options['help']) {
+    $help =
+"Execute enrol sync with external database.
+The enrol_database plugin must be enabled and properly configured.
+
+Options:
+-v, --verbose         Print verbose progess information
+-h, --help            Print out this help
 
+Example:
+\$sudo -u www-data /usr/bin/php enrol/database/cli/sync.php
+
+Sample cron entry:
+# 5 minutes past 4am
+5 4 * * * \$sudo -u www-data /usr/bin/php /var/www/moodle/enrol/database/cli/sync.php
+";
+
+    echo $help;
+    die;
+}
+
+if (!enrol_is_enabled('database')) {
+    echo('enrol_database plugin is disabled, sync is disabled'."\n");
+    exit(1);
+}
+
+$verbose = !empty($options['verbose']);
 $enrol = enrol_get_plugin('database');
-$enrol->sync_courses();
-$enrol->sync_enrolments();
+$result = 0;
+
+$result = $result | $enrol->sync_courses($verbose);
+$result = $result | $enrol->sync_enrolments($verbose);
+
+exit($result);
\ No newline at end of file
index 987e0e7..814e723 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
@@ -103,7 +102,10 @@ class enrol_database_plugin extends enrol_plugin {
         $enrols = array();
         $instances = array();
 
-        $extdb = $this->db_init();
+        if (!$extdb = $this->db_init()) {
+            // can not connect to database, sorry
+            return;
+        }
 
         // read remote enrols and create instances
         $sql = $this->db_get_sql($table, array($userfield=>$user->$localuserfield), array(), false);
@@ -242,22 +244,33 @@ class enrol_database_plugin extends enrol_plugin {
     /**
      * Forces synchronisation of all enrolments with external database.
      *
-     * @return void
+     * @param bool $verbose
+     * @return int 0 means success, 1 db connect failure, 2 db read failure
      */
-    public function sync_enrolments() {
+    public function sync_enrolments($verbose = false) {
         global $CFG, $DB;
 
         // we do not create courses here intentionally because it requires full sync and is slow
         if (!$this->get_config('dbtype') or !$this->get_config('dbhost') or !$this->get_config('remoteenroltable') or !$this->get_config('remotecoursefield') or !$this->get_config('remoteuserfield')) {
-            return;
+            if ($verbose) {
+                mtrace('User enrolment synchronisation skipped.');
+            }
+            return 0;
+        }
+
+        if ($verbose) {
+            mtrace('Starting user enrolment synchronisation...');
+        }
+
+        if (!$extdb = $this->db_init()) {
+            mtrace('Error while communicating with external enrolment database');
+            return 1;
         }
 
         // we may need a lot of memory here
         @set_time_limit(0);
         raise_memory_limit(MEMORY_HUGE);
 
-        $extdb = $this->db_init();
-
         // second step is to sync instances and users
         $table            = $this->get_config('remoteenroltable');
         $coursefield      = strtolower($this->get_config('remotecoursefield'));
@@ -298,18 +311,20 @@ class enrol_database_plugin extends enrol_plugin {
             }
             $rs->Close();
         } else {
-            debugging('Error while communicating with external enrolment database');
+            mtrace('Error reading data from the external enrolment table');
             $extdb->Close();
-            return;
+            return 2;
         }
         $preventfullunenrol = empty($externalcourses);
         if ($preventfullunenrol and $unenrolaction == ENROL_EXT_REMOVED_UNENROL) {
-            debugging('Preventing unenrolment of all current users, because it might result in major data loss, there has to be at least one record in external enrol table, sorry.');
+            if ($verbose) {
+                mtrace('  Preventing unenrolment of all current users, because it might result in major data loss, there has to be at least one record in external enrol table, sorry.');
+            }
         }
 
         // first find all existing courses with enrol instance
         $existing = array();
-        $sql = "SELECT c.id, c.visible, c.$localcoursefield AS mapping, e.id AS enrolid
+        $sql = "SELECT c.id, c.visible, c.$localcoursefield AS mapping, e.id AS enrolid, c.shortname
                   FROM {course} c
                   JOIN {enrol} e ON (e.courseid = c.id AND e.enrol = 'database')";
         $rs = $DB->get_recordset_sql($sql); // watch out for idnumber duplicates
@@ -328,7 +343,7 @@ class enrol_database_plugin extends enrol_plugin {
             $localnotempty =  "AND c.$localcoursefield <> :lcfe";
             $params['lcfe'] = $DB->sql_empty();
         }
-        $sql = "SELECT c.id, c.visible, c.$localcoursefield AS mapping
+        $sql = "SELECT c.id, c.visible, c.$localcoursefield AS mapping, c.shortname
                   FROM {course} c
              LEFT JOIN {enrol} e ON (e.courseid = c.id AND e.enrol = 'database')
                  WHERE e.id IS NULL $localnotempty";
@@ -430,7 +445,7 @@ class enrol_database_plugin extends enrol_plugin {
                 }
                 $rs->Close();
             } else {
-                debugging('Error while communicating with external enrolment database');
+                mtrace('Error while communicating with external enrolment database');
                 $extdb->Close();
                 return;
             }
@@ -443,6 +458,9 @@ class enrol_database_plugin extends enrol_plugin {
                         $this->enrol_user($instance, $userid, $roleid);
                         $current_roles[$userid][$roleid] = $roleid;
                         $current_status[$userid] = ENROL_USER_ACTIVE;
+                        if ($verbose) {
+                            mtrace("  enrolling: $userid ==> $course->shortname as ".$allroles[$roleid]->shortname);
+                        }
                     }
                 }
 
@@ -451,12 +469,18 @@ class enrol_database_plugin extends enrol_plugin {
                     if (empty($userroles[$cr])) {
                         role_unassign($cr, $userid, $context->id, 'enrol_database', $instance->id);
                         unset($current_roles[$userid][$cr]);
+                        if ($verbose) {
+                            mtrace("  unsassigning roles: $userid ==> $course->shortname");
+                        }
                     }
                 }
 
                 // reenable enrolment when previously disable enrolment refreshed
                 if ($current_status[$userid] == ENROL_USER_SUSPENDED) {
                     $DB->set_field('user_enrolments', 'status', ENROL_USER_ACTIVE, array('enrolid'=>$instance->id, 'userid'=>$userid));
+                    if ($verbose) {
+                        mtrace("  unsuspending: $userid ==> $course->shortname");
+                    }
                 }
             }
 
@@ -469,6 +493,9 @@ class enrol_database_plugin extends enrol_plugin {
                             continue;
                         }
                         $this->unenrol_user($instance, $userid);
+                        if ($verbose) {
+                            mtrace("  unenrolling: $userid ==> $course->shortname");
+                        }
                     }
                 }
 
@@ -483,9 +510,15 @@ class enrol_database_plugin extends enrol_plugin {
                     }
                     if ($status != ENROL_USER_SUSPENDED) {
                         $DB->set_field('user_enrolments', 'status', ENROL_USER_SUSPENDED, array('enrolid'=>$instance->id, 'userid'=>$userid));
+                        if ($verbose) {
+                            mtrace("  suspending: $userid ==> $course->shortname");
+                        }
                     }
                     if ($unenrolaction == ENROL_EXT_REMOVED_SUSPENDNOROLES) {
                         role_unassign_all(array('contextid'=>$context->id, 'userid'=>$userid, 'component'=>'enrol_database', 'itemid'=>$instance->id));
+                        if ($verbose) {
+                            mtrace("  unsassigning all roles: $userid ==> $course->shortname");
+                        }
                     }
                 }
             }
@@ -493,6 +526,12 @@ class enrol_database_plugin extends enrol_plugin {
 
         // close db connection
         $extdb->Close();
+
+        if ($verbose) {
+            mtrace('...user enrolment synchronisation finished.');
+        }
+
+        return 0;
     }
 
     /**
@@ -500,21 +539,33 @@ class enrol_database_plugin extends enrol_plugin {
      *
      * First it creates new courses if necessary, then
      * enrols and unenrols users.
-     * @return void
+     *
+     * @param bool $verbose
+     * @return int 0 means success, 1 db connect failure, 4 db read failure
      */
-    public function sync_courses() {
+    public function sync_courses($verbose = false) {
         global $CFG, $DB;
 
         // make sure we sync either enrolments or courses
         if (!$this->get_config('dbtype') or !$this->get_config('dbhost') or !$this->get_config('newcoursetable') or !$this->get_config('newcoursefullname') or !$this->get_config('newcourseshortname')) {
-            return;
+            if ($verbose) {
+                mtrace('Course synchronisation skipped.');
+            }
+            return 0;
+        }
+
+        if ($verbose) {
+            mtrace('Starting course synchronisation...');
         }
 
         // we may need a lot of memory here
         @set_time_limit(0);
         raise_memory_limit(MEMORY_HUGE);
 
-        $extdb = $this->db_init();
+        if (!$extdb = $this->db_init()) {
+            mtrace('Error while communicating with external enrolment database');
+            return 1;
+        }
 
         // first create new courses
         $table     = $this->get_config('newcoursetable');
@@ -534,24 +585,30 @@ class enrol_database_plugin extends enrol_plugin {
         $createcourses = array();
         if ($rs = $extdb->Execute($sql)) {
             if (!$rs->EOF) {
-                $courselist = array();
                 while ($fields = $rs->FetchRow()) {
                     $fields = array_change_key_case($fields, CASE_LOWER);
+                    $fields = $this->db_decode($fields);
                     if (empty($fields[$shortname]) or empty($fields[$fullname])) {
-                        //invalid record - these two are mandatory
+                        if ($verbose) {
+                            mtrace('  error: invalid external course record, shortname and fullname are mandatory: ' . json_encode($fields)); // hopefully every geek can read JS, right?
+                        }
                         continue;
                     }
-                    $fields = $this->db_decode($fields);
                     if ($DB->record_exists('course', array('shortname'=>$fields[$shortname]))) {
                         // already exists
                         continue;
                     }
-                    if ($idnumber and $DB->record_exists('course', array('idnumber'=>$fields[$idnumber]))) {
-                        // idnumber duplicates are not allowed
+                    // allow empty idnumber but not duplicates
+                    if ($idnumber and $fields[$idnumber] !== '' and $fields[$idnumber] !== null and $DB->record_exists('course', array('idnumber'=>$fields[$idnumber]))) {
+                        if ($verbose) {
+                            mtrace('  error: duplicate idnumber, can not create course: '.$fields[$shortname].' ['.$fields[$idnumber].']');
+                        }
                         continue;
                     }
                     if ($category and !$DB->record_exists('course_categories', array('id'=>$fields[$category]))) {
-                        // invalid category id, better to skip
+                        if ($verbose) {
+                            mtrace('  error: invalid category id, can not create course: '.$fields[$shortname]);
+                        }
                         continue;
                     }
                     $course = new stdClass();
@@ -564,9 +621,9 @@ class enrol_database_plugin extends enrol_plugin {
             }
             $rs->Close();
         } else {
-            debugging('Error while communicating with external enrolment database');
+            mtrace('Error reading data from the external course table');
             $extdb->Close();
-            return;
+            return 4;
         }
         if ($createcourses) {
             require_once("$CFG->dirroot/course/lib.php");
@@ -599,7 +656,10 @@ class enrol_database_plugin extends enrol_plugin {
                 $newcourse->idnumber  = $fields->idnumber;
                 $newcourse->category  = $fields->category ? $fields->category : $defaultcategory;
 
-                create_course($newcourse);
+                $c = create_course($newcourse);
+                if ($verbose) {
+                    mtrace("  creating course: $c->id, $c->fullname, $c->shortname, $c->idnumber, $c->category");
+                }
             }
 
             unset($createcourses);
@@ -608,6 +668,12 @@ class enrol_database_plugin extends enrol_plugin {
 
         // close db connection
         $extdb->Close();
+
+        if ($verbose) {
+            mtrace('...course synchronisation finished.');
+        }
+
+        return 0;
     }
 
     protected function db_get_sql($table, array $conditions, array $fields, $distinct = false, $sort = "") {
@@ -631,6 +697,11 @@ class enrol_database_plugin extends enrol_plugin {
         return $sql;
     }
 
+    /**
+     * Tries to make connection to the external database.
+     *
+     * @return null|ADONewConnection
+     */
     protected function db_init() {
         global $CFG;
 
@@ -643,7 +714,11 @@ class enrol_database_plugin extends enrol_plugin {
             ob_start(); //start output buffer to allow later use of the page headers
         }
 
-        $extdb->Connect($this->get_config('dbhost'), $this->get_config('dbuser'), $this->get_config('dbpass'), $this->get_config('dbname'), true);
+        $result = $extdb->Connect($this->get_config('dbhost'), $this->get_config('dbuser'), $this->get_config('dbpass'), $this->get_config('dbname'), true);
+        if (!$result) {
+            return null;
+        }
+
         $extdb->SetFetchMode(ADODB_FETCH_ASSOC);
         if ($this->get_config('dbsetupsql')) {
             $extdb->Execute($this->get_config('dbsetupsql'));
index 5a6c098..a04d9d5 100644 (file)
@@ -645,7 +645,7 @@ function process_membership_tag($tagcontents){
                         if(isset($groupids[$member->groupname])) {
                             $member->groupid = $groupids[$member->groupname]; // Recall the group ID from cache if available
                         } else {
-                            if($groupid = $DB->get_field('groups', 'id', 'name', $member->groupname, array('courseid'=>$ship->courseid))){
+                            if($groupid = $DB->get_field('groups', 'id', array('courseid'=>$ship->courseid, 'name'=>$member->groupname))){
                                 $member->groupid = $groupid;
                                 $groupids[$member->groupname] = $groupid; // Store ID in cache
                             } else {
index f31e44f..206ee89 100644 (file)
@@ -198,7 +198,11 @@ class enrol_manual_plugin extends enrol_plugin {
             return false;
         }
 
-        $button = new enrol_user_button($this->get_manual_enrol_link($instance), get_string('enrolusers', 'enrol_manual'), 'get');
+        if (!$manuallink = $this->get_manual_enrol_link($instance)) {
+            return false;
+        }
+
+        $button = new enrol_user_button($manuallink, get_string('enrolusers', 'enrol_manual'), 'get');
         $button->class .= ' enrol_manual_plugin';
 
         $startdate = $manager->get_course()->startdate;
index 4ca0beb..d86d0cb 100644 (file)
@@ -153,7 +153,7 @@ class enrol_self_plugin extends enrol_plugin {
     public function get_newinstance_link($courseid) {
         $context = get_context_instance(CONTEXT_COURSE, $courseid, MUST_EXIST);
 
-        if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/manual:config', $context)) {
+        if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/self:config', $context)) {
             return NULL;
         }
         // multiple instances supported - different roles with different password
index 0eeaf4d..3d8bfb0 100644 (file)
@@ -19,7 +19,7 @@ $action   = groups_param_action();
 if ($groupid) {
     $groupids = array($groupid);
 } else {
-    $groupids = optional_param('groups', array(), PARAM_INT);
+    $groupids = optional_param_array('groups', array(), PARAM_INT);
 }
 $singlegroup = (count($groupids) == 1);
 
index 14b0665..eb7189f 100644 (file)
@@ -169,7 +169,7 @@ $CFG->admin                = $config->admin;
 $CFG->docroot              = 'http://docs.moodle.org';
 $CFG->langotherroot        = $CFG->dataroot.'/lang';
 $CFG->langlocalroot        = $CFG->dataroot.'/lang';
-$CFG->directorypermissions = 00777;
+$CFG->directorypermissions = isset($distro->directorypermissions) ? $distro->directorypermissions : 00777; // let distros set dir permissions
 $CFG->running_installer    = true;
 $CFG->early_install_lang   = true;
 
index 5d0690e..dec65ad 100644 (file)
@@ -67,6 +67,7 @@ $string['editservice'] = 'Edit the service: {$a->name} (id: {$a->id})';
 $string['enabled'] = 'Enabled';
 $string['enabledocumentation'] = 'Enable developer documentation';
 $string['enabledocumentationdescription'] = 'Detailed web services documentation is available for enabled protocols.';
+$string['enablemobilewsoverview'] = 'Go to {$a->manageservicelink} administration page, check the "{$a->enablemobileservice}" setting and Save. Everything will be setup for you and all site\'s users will be able to use the offical Moodle app. Current status: {$a->wsmobilestatus}';
 $string['enableprotocols'] = 'Enable protocols';
 $string['enableprotocolsdescription'] = 'At least one protocol should be enabled. For security reasons, only protocols that are to be used should be enabled.';
 $string['enablews'] = 'Enable web services';
@@ -120,6 +121,8 @@ $string['missingcaps_help'] = 'List of required capabilities for the service whi
 $string['missingpassword'] = 'Missing password';
 $string['missingusername'] = 'Missing username';
 $string['missingversionfile'] = 'Coding error: version.php file is missing for the component {$a}';
+$string['mobilewsdisabled'] = 'Disabled';
+$string['mobilewsenabled'] = 'Enabled';
 $string['nofunctions'] = 'This service has no functions.';
 $string['norequiredcapability'] = 'No required capability';
 $string['notoken'] = 'The token list is empty.';
index cf21bcf..8e0a55c 100644 (file)
@@ -6259,7 +6259,7 @@ function db_replace($search, $replace) {
     // TODO: this is horrible hack, we should do whitelisting and each plugin should be responsible for proper replacing...
     $skiptables = array('config', 'config_plugins', 'config_log', 'upgrade_log',
                         'filter_config', 'sessions', 'events_queue', 'repository_instance_config',
-                        'block_instances', 'block_pinned_old', 'block_instance_old', '');
+                        'block_instances', '');
 
     // Turn off time limits, sometimes upgrades can be slow.
     @set_time_limit(0);
@@ -7059,10 +7059,25 @@ class admin_setting_webservicesoverview extends admin_setting {
         global $CFG, $OUTPUT;
 
         $return = "";
-
-        /// One system controlling Moodle with Token
         $brtag = html_writer::empty_tag('br');
 
+        // Enable mobile web service
+        $enablemobile = new admin_setting_enablemobileservice('enablemobilewebservice',
+                get_string('enablemobilewebservice', 'admin'),
+                get_string('configenablemobilewebservice',
+                        'admin', ''), 0); //we don't want to display it but to know the ws mobile status
+        $manageserviceurl = new moodle_url("/admin/settings.php?section=externalservices");
+        $wsmobileparam = new stdClass();
+        $wsmobileparam->enablemobileservice = get_string('enablemobilewebservice', 'admin');
+        $wsmobileparam->manageservicelink = html_writer::link($manageserviceurl,
+                get_string('externalservices', 'webservice'));
+        $mobilestatus = $enablemobile->get_setting()?get_string('mobilewsenabled', 'webservice'):get_string('mobilewsdisabled', 'webservice');
+        $wsmobileparam->wsmobilestatus = html_writer::tag('strong', $mobilestatus);
+        $return .= $OUTPUT->heading(get_string('enablemobilewebservice', 'admin'), 3, 'main');
+        $return .= $brtag . get_string('enablemobilewsoverview', 'webservice', $wsmobileparam)
+                . $brtag . $brtag;
+
+        /// One system controlling Moodle with Token
         $return .= $OUTPUT->heading(get_string('onesystemcontrolling', 'webservice'), 3, 'main');
         $table = new html_table();
         $table->head = array(get_string('step', 'webservice'), get_string('status'),
index 46420d2..0daf295 100644 (file)
@@ -566,7 +566,7 @@ resource_class.prototype.init_resource = function(id, group, config, parentObj)
 
     this.hidden = false;
     if (YAHOO.util.Dom.hasClass(this.getEl().getElementsByTagName('a')[0], 'dimmed') ||
-        YAHOO.util.Dom.hasClass(this.getEl().getElementsByTagName('div')[0], 'dimmed_text')) {
+        YAHOO.util.Dom.hasClass(this.getEl().getElementsByTagName('div')[1], 'dimmed_text')) {
         this.hidden = true;
     }
     this.hiddenStored = null;
index 6103731..096d157 100644 (file)
@@ -269,7 +269,7 @@ class completion_criteria_activity extends completion_criteria {
                 $details['requirement'][] = get_string('viewingactivity', 'completion', $this->module);
             }
 
-            if ($module->completiongradeitemnumber) {
+            if (!is_null($module->completiongradeitemnumber)) {
                 $details['requirement'][] = get_string('achievinggrade', 'completion');
             }
         }
index 6ce85e9..bc2c8a0 100644 (file)
@@ -90,7 +90,12 @@ class completion_criteria_duration extends completion_criteria {
     private function get_timeenrolled($completion) {
         global $DB;
 
-        return $DB->get_field('user_enrolments', 'timestart', array('courseid' => $this->course, 'userid' => $completion->userid));
+        return $DB->get_field_sql('
+            SELECT eu.timestart
+              FROM {user_enrolments} eu
+              JOIN {enrol} e ON eu.enrolid = e.id
+             WHERE e.courseid = ?
+               AND eu.userid = ?', array($this->course, $completion->userid));
     }
 
     /**
index 407c6f9..f72b59b 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20110627" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20110821" COMMENT="XMLDB file for core Moodle tables"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
 >
         <INDEX NAME="parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern" UNIQUE="false" FIELDS="parentcontextid, showinsubcontexts, pagetypepattern, subpagepattern"/>
       </INDEXES>
     </TABLE>
-    <TABLE NAME="block_positions" COMMENT="Stores the position of a sticky block_instance on a another page than the one where it was added." PREVIOUS="block_instances" NEXT="block_pinned_old">
+    <TABLE NAME="block_positions" COMMENT="Stores the position of a sticky block_instance on a another page than the one where it was added." PREVIOUS="block_instances" NEXT="comments">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="blockinstanceid"/>
         <FIELD NAME="blockinstanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The block_instance this position relates to." PREVIOUS="id" NEXT="contextid"/>
         <INDEX NAME="blockinstanceid-contextid-pagetype-subpage" UNIQUE="true" FIELDS="blockinstanceid, contextid, pagetype, subpage"/>
       </INDEXES>
     </TABLE>
-    <TABLE NAME="block_pinned_old" COMMENT="backup of 1.9 pinned blocks - to be deleted" PREVIOUS="block_positions" NEXT="block_instance_old">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="blockid"/>
-        <FIELD NAME="blockid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="pagetype"/>
-        <FIELD NAME="pagetype" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" PREVIOUS="blockid" NEXT="position"/>
-        <FIELD NAME="position" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="pagetype" NEXT="weight"/>
-        <FIELD NAME="weight" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="position" NEXT="visible"/>
-        <FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="weight" NEXT="configdata"/>
-        <FIELD NAME="configdata" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="visible"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="blockid"/>
-        <KEY NAME="blockid" TYPE="foreign" FIELDS="blockid" REFTABLE="block" REFFIELDS="id" PREVIOUS="primary"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="pagetype" UNIQUE="false" FIELDS="pagetype"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="block_instance_old" COMMENT="backup of 1.9 block instances - to be deleted" PREVIOUS="block_pinned_old" NEXT="comments">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="oldid"/>
-        <FIELD NAME="oldid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="blockid"/>
-        <FIELD NAME="blockid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="oldid" NEXT="pageid"/>
-        <FIELD NAME="pageid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="blockid" NEXT="pagetype"/>
-        <FIELD NAME="pagetype" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" PREVIOUS="pageid" NEXT="position"/>
-        <FIELD NAME="position" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="pagetype" NEXT="weight"/>
-        <FIELD NAME="weight" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="position" NEXT="visible"/>
-        <FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="weight" NEXT="configdata"/>
-        <FIELD NAME="configdata" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="visible"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="blockid"/>
-        <KEY NAME="blockid" TYPE="foreign" FIELDS="blockid" REFTABLE="block" REFFIELDS="id" PREVIOUS="primary"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="pageid" UNIQUE="false" FIELDS="pageid" NEXT="pagetype"/>
-        <INDEX NAME="pagetype" UNIQUE="false" FIELDS="pagetype" PREVIOUS="pageid"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="comments" COMMENT="moodle comments module" PREVIOUS="block_instance_old" NEXT="external_services">
+    <TABLE NAME="comments" COMMENT="moodle comments module" PREVIOUS="block_positions" NEXT="external_services">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="contextid"/>
         <FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="commentarea"/>
index b80caa2..742faa8 100644 (file)
@@ -6651,12 +6651,33 @@ FROM
         upgrade_main_savepoint(true, 2011071300.01);
     }
 
+    if ($oldversion < 2011081700.01) {
+        // Remove category_sortorder index that was supposed to be removed long time ago
+        $table = new xmldb_table('course');
+        $index = new xmldb_index('category_sortorder', XMLDB_INDEX_UNIQUE, array('category', 'sortorder'));
+
+        if ($dbman->index_exists($table, $index)) {
+            $dbman->drop_index($table, $index);
+        }
+        upgrade_main_savepoint(true, 2011081700.01);
+    }
+
+    if ($oldversion < 2011081700.02) {
+        // remove safety block backup from 2.0 upgrade
+        $table = new xmldb_table('block_pinned_old');
+        if ($dbman->table_exists($table)) {
+            $dbman->drop_table($table);
+        }
+        $table = new xmldb_table('block_instance_old');
+        if ($dbman->table_exists($table)) {
+            $dbman->drop_table($table);
+        }
+        upgrade_main_savepoint(true, 2011081700.02);
+    }
+
 
     return true;
 }
 
-//TODO: Cleanup before the 2.0 release - we do not want to drag along these dev machine fixes forever
-// 1/ drop block_pinned_old table here and in install.xml
-// 2/ drop block_instance_old table here and in install.xml
 
 //TODO: AFTER 2.0 remove the column user->emailstop and the user preference "message_showmessagewindow"
index 5cc33d0..4f7ec4d 100644 (file)
@@ -588,18 +588,27 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
  * @return integer the itemid, or 0 if there is not one yet.
  */
 function file_get_submitted_draft_itemid($elname) {
-    $param = optional_param($elname, 0, PARAM_INT);
-    if ($param) {
-        require_sesskey();
+    // this is a nasty hack, ideally all new elements should use arrays here or there should be a new parameter
+    if (!isset($_REQUEST[$elname])) {
+        return 0;
     }
-    if (is_array($param)) {
+    if (is_array($_REQUEST[$elname])) {
+        $param = optional_param_array($elname, 0, PARAM_INT);
         if (!empty($param['itemid'])) {
             $param = $param['itemid'];
         } else {
             debugging('Missing itemid, maybe caused by unset maxfiles option', DEBUG_DEVELOPER);
             return false;
         }
+
+    } else {
+        $param = optional_param($elname, 0, PARAM_INT);
     }
+
+    if ($param) {
+        require_sesskey();
+    }
+
     return $param;
 }
 
@@ -1725,8 +1734,20 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss
     }
 */
 
-    //try to disable automatic sid rewrite in cookieless mode
-    @ini_set("session.use_trans_sid", "false");
+    if ($lifetime > 0 && !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+        // get unixtime of request header; clip extra junk off first
+        $since = strtotime(preg_replace('/;.*$/','',$_SERVER["HTTP_IF_MODIFIED_SINCE"]));
+        if ($since && $since >= $lastmodified) {
+            header('HTTP/1.1 304 Not Modified');
+            header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
+            header('Cache-Control: max-age='.$lifetime);
+            header('Content-Type: '.$mimetype);
+            if ($dontdie) {
+                return;
+            }
+            die;
+        }
+    }
 
     //do not put '@' before the next header to detect incorrect moodle configurations,
     //error should be better than "weird" empty lines for admins/users
@@ -1925,12 +1946,23 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl
     $lastmodified = $stored_file->get_timemodified();
     $filesize     = $stored_file->get_filesize();
 
-    //try to disable automatic sid rewrite in cookieless mode
-    @ini_set("session.use_trans_sid", "false");
+    if ($lifetime > 0 && !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+        // get unixtime of request header; clip extra junk off first
+        $since = strtotime(preg_replace('/;.*$/','',$_SERVER["HTTP_IF_MODIFIED_SINCE"]));
+        if ($since && $since >= $lastmodified) {
+            header('HTTP/1.1 304 Not Modified');
+            header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
+            header('Cache-Control: max-age='.$lifetime);
+            header('Content-Type: '.$mimetype);
+            if ($dontdie) {
+                return;
+            }
+            die;
+        }
+    }
 
     //do not put '@' before the next header to detect incorrect moodle configurations,
     //error should be better than "weird" empty lines for admins/users
-    //TODO: should we remove all those @ before the header()? Are all of the values supported on all servers?
     header('Last-Modified: '. gmdate('D, d M Y H:i:s', $lastmodified) .' GMT');
 
     // if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup
@@ -2002,7 +2034,6 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl
     }
 
     if (empty($filter)) {
-        $filtered = false;
         if ($mimetype == 'text/plain') {
             header('Content-Type: Text/plain; charset=utf-8'); //add encoding
         } else {
@@ -2015,11 +2046,7 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl
         prepare_file_content_sending();
 
         // send the contents
-        if ($filtered) {
-            echo $text;
-        } else {
-            $stored_file->readfile();
-        }
+        $stored_file->readfile();
 
     } else {     // Try to put the file through filters
         if ($mimetype == 'text/html') {
index b829205..4b02f70 100644 (file)
@@ -1384,9 +1384,14 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
         } else {
             foreach ($submission as $key=>$s) {
                 if (array_key_exists($key, $this->_types)) {
-                    $submission[$key] = clean_param($s, $this->_types[$key]);
+                    $type = $this->_types[$key];
                 } else {
-                    $submission[$key] = clean_param($s, PARAM_RAW);
+                    $type = PARAM_RAW;
+                }
+                if (is_array($s)) {
+                    $submission[$key] = clean_param_array($s, $type, true);
+                } else {
+                    $submission[$key] = clean_param($s, $type);
                 }
             }
             $this->_submitValues = $submission;
index e797bf6..c61c479 100644 (file)
@@ -448,17 +448,15 @@ define('MOODLE_OFFICIAL_MOBILE_SERVICE', 'moodle_mobile_app');
  * used like this:
  *    $id = required_param('id', PARAM_INT);
  *
- * Please note the $type parameter is now required,
- * for now PARAM_CLEAN is used for backwards compatibility only.
+ * Please note the $type parameter is now required and the value can not be array.
  *
  * @param string $parname the name of the page parameter we want
  * @param string $type expected type of parameter
  * @return mixed
  */
 function required_param($parname, $type) {
-    if (!isset($type)) {
-        debugging('required_param() requires $type to be specified.');
-        $type = PARAM_CLEAN; // for now let's use this deprecated type
+    if (func_num_args() != 2 or empty($parname) or empty($type)) {
+        throw new coding_exception('required_param() requires $parname and $type to be specified (parameter: '.$parname.')');
     }
     if (isset($_POST[$parname])) {       // POST has precedence
         $param = $_POST[$parname];
@@ -468,9 +466,59 @@ function required_param($parname, $type) {
         print_error('missingparam', '', '', $parname);
     }
 
+    if (is_array($param)) {
+        debugging('Invalid array parameter detected in required_param(): '.$parname);
+        // TODO: switch to fatal error in Moodle 2.3
+        //print_error('missingparam', '', '', $parname);
+        return required_param_array($parname, $type);
+    }
+
     return clean_param($param, $type);
 }
 
+/**
+ * Returns a particular array value for the named variable, taken from
+ * POST or GET.  If the parameter doesn't exist then an error is
+ * thrown because we require this variable.
+ *
+ * This function should be used to initialise all required values
+ * in a script that are based on parameters.  Usually it will be
+ * used like this:
+ *    $ids = required_param_array('ids', PARAM_INT);
+ *
+ *  Note: arrays of arrays are not supported, only alphanumeric keys with _ and - are supported
+ *
+ * @param string $parname the name of the page parameter we want
+ * @param string $type expected type of parameter
+ * @return array
+ */
+function required_param_array($parname, $type) {
+    if (func_num_args() != 2 or empty($parname) or empty($type)) {
+        throw new coding_exception('required_param_array() requires $parname and $type to be specified (parameter: '.$parname.')');
+    }
+    if (isset($_POST[$parname])) {       // POST has precedence
+        $param = $_POST[$parname];
+    } else if (isset($_GET[$parname])) {
+        $param = $_GET[$parname];
+    } else {
+        print_error('missingparam', '', '', $parname);
+    }
+    if (!is_array($param)) {
+        print_error('missingparam', '', '', $parname);
+    }
+
+    $result = array();
+    foreach($param as $key=>$value) {
+        if (!preg_match('/^[a-z0-9_-]+$/i', $key)) {
+            debugging('Invalid key name in required_param_array() detected: '.$key.', parameter: '.$parname);
+            continue;
+        }
+        $result[$key] = clean_param($value, $type);
+    }
+
+    return $result;
+}
+
 /**
  * Returns a particular value for the named variable, taken from
  * POST or GET, otherwise returning a given default.
@@ -480,8 +528,7 @@ function required_param($parname, $type) {
  * used like this:
  *    $name = optional_param('name', 'Fred', PARAM_TEXT);
  *
- * Please note $default and $type parameters are now required,
- * for now PARAM_CLEAN is used for backwards compatibility only.
+ * Please note the $type parameter is now required and the value can not be array.
  *
  * @param string $parname the name of the page parameter we want
  * @param mixed  $default the default value to return if nothing is found
@@ -489,9 +536,8 @@ function required_param($parname, $type) {
  * @return mixed
  */
 function optional_param($parname, $default, $type) {
-    if (!isset($type)) {
-        debugging('optional_param() requires $default and $type to be specified.');
-        $type = PARAM_CLEAN; // for now let's use this deprecated type
+    if (func_num_args() != 3 or empty($parname) or empty($type)) {
+        throw new coding_exception('optional_param() requires $parname, $default and $type to be specified (parameter: '.$parname.')');
     }
     if (!isset($default)) {
         $default = null;
@@ -505,9 +551,61 @@ function optional_param($parname, $default, $type) {
         return $default;
     }
 
+    if (is_array($param)) {
+        debugging('Invalid array parameter detected in required_param(): '.$parname);
+        // TODO: switch to $default in Moodle 2.3
+        //return $default;
+        return optional_param_array($parname, $default, $type);
+    }
+
     return clean_param($param, $type);
 }
 
+/**
+ * Returns a particular array value for the named variable, taken from
+ * POST or GET, otherwise returning a given default.
+ *
+ * This function should be used to initialise all optional values
+ * in a script that are based on parameters.  Usually it will be
+ * used like this:
+ *    $ids = optional_param('id', array(), PARAM_INT);
+ *
+ *  Note: arrays of arrays are not supported, only alphanumeric keys with _ and - are supported
+ *
+ * @param string $parname the name of the page parameter we want
+ * @param mixed  $default the default value to return if nothing is found
+ * @param string $type expected type of parameter
+ * @return array
+ */
+function optional_param_array($parname, $default, $type) {
+    if (func_num_args() != 3 or empty($parname) or empty($type)) {
+        throw new coding_exception('optional_param_array() requires $parname, $default and $type to be specified (parameter: '.$parname.')');
+    }
+
+    if (isset($_POST[$parname])) {       // POST has precedence
+        $param = $_POST[$parname];
+    } else if (isset($_GET[$parname])) {
+        $param = $_GET[$parname];
+    } else {
+        return $default;
+    }
+    if (!is_array($param)) {
+        debugging('optional_param_array() expects array parameters only: '.$parname);
+        return $default;
+    }
+
+    $result = array();
+    foreach($param as $key=>$value) {
+        if (!preg_match('/^[a-z0-9_-]+$/i', $key)) {
+            debugging('Invalid key name in optional_param_array() detected: '.$key.', parameter: '.$parname);
+            continue;
+        }
+        $result[$key] = clean_param($value, $type);
+    }
+
+    return $result;
+}
+
 /**
  * Strict validation of parameter values, the values are only converted
  * to requested PHP type. Internally it is using clean_param, the values
@@ -516,7 +614,7 @@ function optional_param($parname, $default, $type) {
  * Objects and classes are not accepted.
  *
  * @param mixed $param
- * @param int $type PARAM_ constant
+ * @param string $type PARAM_ constant
  * @param bool $allownull are nulls valid value?
  * @param string $debuginfo optional debug information
  * @return mixed the $param value converted to PHP type or invalid_parameter_exception
@@ -542,6 +640,34 @@ function validate_param($param, $type, $allownull=NULL_NOT_ALLOWED, $debuginfo='
     return $cleaned;
 }
 
+/**
+ * Makes sure array contains only the allowed types,
+ * this function does not validate array key names!
+ * <code>
+ * $options = clean_param($options, PARAM_INT);
+ * </code>
+ *
+ * @param array $param the variable array we are cleaning
+ * @param string $type expected format of param after cleaning.
+ * @param bool $recursive clean recursive arrays
+ * @return array
+ */
+function clean_param_array(array $param = null, $type, $recursive = false) {
+    $param = (array)$param; // convert null to empty array
+    foreach ($param as $key => $value) {
+        if (is_array($value)) {
+            if ($recursive) {
+                $param[$key] = clean_param_array($value, $type, true);
+            } else {
+                throw new coding_exception('clean_param_array() can not process multidimensional arrays when $recursive is false.');
+            }
+        } else {
+            $param[$key] = clean_param($value, $type);
+        }
+    }
+    return $param;
+}
+
 /**
  * Used by {@link optional_param()} and {@link required_param()} to
  * clean the variables and/or cast to specific types, based on
@@ -552,19 +678,15 @@ function validate_param($param, $type, $allownull=NULL_NOT_ALLOWED, $debuginfo='
  * </code>
  *
  * @param mixed $param the variable we are cleaning
- * @param int $type expected format of param after cleaning.
+ * @param string $type expected format of param after cleaning.
  * @return mixed
  */
 function clean_param($param, $type) {
 
     global $CFG;
 
-    if (is_array($param)) {              // Let's loop
-        $newparam = array();
-        foreach ($param as $key => $value) {
-            $newparam[$key] = clean_param($value, $type);
-        }
-        return $newparam;
+    if (is_object($param) or is_array($param)) {
+        throw new coding_exception('clean_param() can not process objects or arrays, please use clean_param_array() instead.');
     }
 
     switch ($type) {
@@ -9368,9 +9490,10 @@ WHERE m.useridto = :userid AND p.name='popup'";
             $smallmessage = null;
             if (!empty($message_users->smallmessage)) {
                 //display the first 200 chars of the message in the popup
+                $textlib = textlib_get_instance();
                 $smallmessage = null;
-                if (strlen($message_users->smallmessage>200)) {
-                    $smallmessage = substr($message_users->smallmessage,0,200).'...';
+                if ($textlib->strlen($message_users->smallmessage) > 200) {
+                    $smallmessage = $textlib->substr($message_users->smallmessage,0,200).'...';
                 } else {
                     $smallmessage = $message_users->smallmessage;
                 }
index b832df4..b475d8c 100644 (file)
@@ -202,16 +202,38 @@ class plugin_renderer_base extends renderer_base {
  * @since     Moodle 2.0
  */
 class core_renderer extends renderer_base {
-    /** @var string used in {@link header()}. */
-    const PERFORMANCE_INFO_TOKEN = '%%PERFORMANCEINFO%%';
-    /** @var string used in {@link header()}. */
-    const END_HTML_TOKEN = '%%ENDHTML%%';
-    /** @var string used in {@link header()}. */
+    /**
+     * Do NOT use, please use <?php echo $OUTPUT->main_content() ?>
+     * in layout files instead.
+     * @var string used in {@link header()}.
+     * @deprecated
+     */
     const MAIN_CONTENT_TOKEN = '[MAIN CONTENT GOES HERE]';
     /** @var string used to pass information from {@link doctype()} to {@link standard_head_html()}. */
     protected $contenttype;
     /** @var string used by {@link redirect_message()} method to communicate with {@link header()}. */
     protected $metarefreshtag = '';
+    /** @var string unique token */
+    protected $unique_end_html_token;
+    /** @var string unique token */
+    protected $unique_performance_info_token;
+    /** @var string unique token */
+    protected $unique_main_content_token;
+
+    /**
+     * Constructor
+     * @param moodle_page $page the page we are doing output for.
+     * @param string $target one of rendering target constants
+     */
+    public function __construct(moodle_page $page, $target) {
+        $this->opencontainers = $page->opencontainers;
+        $this->page = $page;
+        $this->target = $target;
+
+        $this->unique_end_html_token = '%%ENDHTML-'.sesskey().'%%';
+        $this->unique_performance_info_token = '%%PERFORMANCEINFO-'.sesskey().'%%';
+        $this->unique_main_content_token = '[MAIN CONTENT GOES HERE - '.sesskey().']';
+    }
 
     /**
      * Get the DOCTYPE declaration that should be used with this page. Designed to
@@ -355,7 +377,7 @@ class core_renderer extends renderer_base {
         // This function is normally called from a layout.php file in {@link header()}
         // but some of the content won't be known until later, so we return a placeholder
         // for now. This will be replaced with the real content in {@link footer()}.
-        $output = self::PERFORMANCE_INFO_TOKEN;
+        $output = $this->unique_performance_info_token;
         if ($this->page->devicetypeinuse == 'legacy') {
             // The legacy theme is in use print the notification
             $output .= html_writer::tag('div', get_string('legacythemeinuse'), array('class'=>'legacythemeinuse'));
@@ -391,6 +413,15 @@ class core_renderer extends renderer_base {
         return $output;
     }
 
+    /**
+     * Returns standard main content placeholder.
+     * Designed to be called in theme layout.php files.
+     * @return string HTML fragment.
+     */
+    public function main_content() {
+        return $this->unique_main_content_token;
+    }
+
     /**
      * The standard tags (typically script tags that are not needed earlier) that
      * should be output after everything else, . Designed to be called in theme layout.php files.
@@ -400,7 +431,7 @@ class core_renderer extends renderer_base {
         // This function is normally called from a layout.php file in {@link header()}
         // but some of the content won't be known until later, so we return a placeholder
         // for now. This will be replaced with the real content in {@link footer()}.
-        return self::END_HTML_TOKEN;
+        return $this->unique_end_html_token;
     }
 
     /**
@@ -606,13 +637,19 @@ class core_renderer extends renderer_base {
         $rendered = $this->render_page_layout($layoutfile);
 
         // Slice the rendered output into header and footer.
-        $cutpos = strpos($rendered, self::MAIN_CONTENT_TOKEN);
+        $cutpos = strpos($rendered, $this->unique_main_content_token);
+        if ($cutpos === false) {
+            $cutpos = strpos($rendered, self::MAIN_CONTENT_TOKEN);
+            $token = self::MAIN_CONTENT_TOKEN;
+        } else {
+            $token = $this->unique_main_content_token;
+        }
+
         if ($cutpos === false) {
-            throw new coding_exception('page layout file ' . $layoutfile .
-                    ' does not contain the string "' . self::MAIN_CONTENT_TOKEN . '".');
+            throw new coding_exception('page layout file ' . $layoutfile . ' does not contain the main content placeholder, please include "<?php echo $OUTPUT->main_content() ?>" in theme layout file.');
         }
         $header = substr($rendered, 0, $cutpos);
-        $footer = substr($rendered, $cutpos + strlen(self::MAIN_CONTENT_TOKEN));
+        $footer = substr($rendered, $cutpos + strlen($token));
 
         if (empty($this->contenttype)) {
             debugging('The page layout file did not call $OUTPUT->doctype()');
@@ -677,9 +714,9 @@ class core_renderer extends renderer_base {
                 $performanceinfo = $perf['html'];
             }
         }
-        $footer = str_replace(self::PERFORMANCE_INFO_TOKEN, $performanceinfo, $footer);
+        $footer = str_replace($this->unique_performance_info_token, $performanceinfo, $footer);
 
-        $footer = str_replace(self::END_HTML_TOKEN, $this->page->requires->get_end_code(), $footer);
+        $footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);
 
         $this->page->set_state(moodle_page::STATE_DONE);
 
index 9522884..5b011b1 100644 (file)
@@ -125,8 +125,8 @@ class page_requirements_manager {
 
         // set up some loader options
         if (debugging('', DEBUG_DEVELOPER)) {
-            $this->yui3loader->filter = YUI_DEBUG; // alternatively we could use just YUI_RAW here
-            $this->yui2loader->filter = YUI_DEBUG; // alternatively we could use just YUI_RAW here
+            $this->yui3loader->filter = YUI_RAW; // for more detailed logging info use YUI_DEBUG here
+            $this->yui2loader->filter = YUI_RAW; // for more detailed logging info use YUI_DEBUG here
         } else {
             $this->yui3loader->filter = null;
             $this->yui2loader->filter = null;
index fe52dfe..446fa95 100644 (file)
@@ -1343,6 +1343,11 @@ function question_has_capability_on($question, $cap, $cachecat = -1) {
         }
         $question = $questions[$question];
     }
+    if (empty($question->category)) {
+        // This can happen when we have created a fake 'missingtype' question to
+        // take the place of a deleted question.
+        return false;
+    }
     if (!isset($categories[$question->category])) {
         if (!$categories[$question->category] = $DB->get_record('question_categories',
                 array('id'=>$question->category))) {
index 29ff496..de4ebdd 100644 (file)
@@ -183,6 +183,17 @@ if (file_exists("$CFG->dataroot/climaintenance.html")) {
     }
 }
 
+if (CLI_SCRIPT) {
+    // sometimes people use different PHP binary for web and CLI, make 100% sure they have the supported PHP version
+    if (version_compare(phpversion(), '5.3.2') < 0) {
+        $phpversion = phpversion();
+        // do NOT localise - lang strings would not work here and we CAN NOT move it to later place
+        echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n";
+        echo "Some servers may have multiple PHP versions installed, are you using the correct executable?\n";
+        exit(1);
+    }
+}
+
 // Detect ajax scripts - they are similar to CLI because we can not redirect, output html, etc.
 if (!defined('AJAX_SCRIPT')) {
     define('AJAX_SCRIPT', false);
index 702ecc1..34c547a 100644 (file)
@@ -318,15 +318,344 @@ class moodlelib_test extends UnitTestCase {
     }
 
     function test_optional_param() {
+        global $CFG;
+
         $_POST['username'] = 'post_user';
         $_GET['username'] = 'get_user';
-        $this->assertEqual(optional_param('username', 'default_user', PARAM_RAW), 'post_user');
+        $this->assertIdentical(optional_param('username', 'default_user', PARAM_RAW), $_POST['username']);
+
+        unset($_POST['username']);
+        $this->assertIdentical(optional_param('username', 'default_user', PARAM_RAW), $_GET['username']);
+
+        unset($_GET['username']);
+        $this->assertIdentical(optional_param('username', 'default_user', PARAM_RAW), 'default_user');
+
+        // make sure exception is triggered when some params are missing, hide error notices here - new in 2.2
+        $_POST['username'] = 'post_user';
+        try {
+            optional_param('username', 'default_user', null);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            @optional_param('username', 'default_user');
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            @optional_param('username');
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            optional_param('', 'default_user', PARAM_RAW);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+        // make sure warning is displayed if array submitted - TODO: throw exception in Moodle 2.3
+        $debugging = isset($CFG->debug) ? $CFG->debug : null;
+        $debugdisplay = isset($CFG->debugdisplay) ? $CFG->debugdisplay : null;
+        $CFG->debug = 38911;
+        $CFG->debugdisplay = true;
+
+        ob_start();
+        $this->assertIdentical(optional_param('username', 'default_user', PARAM_RAW), $_POST['username']);
+        $d = ob_end_clean();
+        $this->assertTrue($d !== '');
+
+        if ($debugging !== null) {
+            $CFG->debug = $debugging;
+        } else {
+            unset($CFG->debug);
+        }
+        if ($debugdisplay !== null) {
+            $CFG->debugdisplay = $debugdisplay;
+        } else {
+            unset($CFG->debugdisplay);
+        }
+    }
+
+    function test_optional_param_array() {
+        global $CFG;
+
+        $_POST['username'] = array('a'=>'post_user');
+        $_GET['username'] = array('a'=>'get_user');
+        $this->assertIdentical(optional_param_array('username', array('a'=>'default_user'), PARAM_RAW), $_POST['username']);
 
         unset($_POST['username']);
-        $this->assertEqual(optional_param('username', 'default_user', PARAM_RAW), 'get_user');
+        $this->assertIdentical(optional_param_array('username', array('a'=>'default_user'), PARAM_RAW), $_GET['username']);
 
         unset($_GET['username']);
-        $this->assertEqual(optional_param('username', 'default_user', PARAM_RAW), 'default_user');
+        $this->assertIdentical(optional_param_array('username', array('a'=>'default_user'), PARAM_RAW), array('a'=>'default_user'));
+
+        // make sure exception is triggered when some params are missing, hide error notices here - new in 2.2
+        $_POST['username'] = array('a'=>'post_user');
+        try {
+            optional_param_array('username', array('a'=>'default_user'), null);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            @optional_param_array('username', array('a'=>'default_user'));
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            @optional_param_array('username');
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            optional_param_array('', array('a'=>'default_user'), PARAM_RAW);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+        // do not allow nested arrays
+        try {
+            $_POST['username'] = array('a'=>array('b'=>'post_user'));
+            optional_param_array('username', array('a'=>'default_user'), PARAM_RAW);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+        // do not allow non-arrays
+        $debugging = isset($CFG->debug) ? $CFG->debug : null;
+        $debugdisplay = isset($CFG->debugdisplay) ? $CFG->debugdisplay : null;
+        $CFG->debug = 38911;
+        $CFG->debugdisplay = true;
+
+        ob_start();
+        $_POST['username'] = 'post_user';
+        $this->assertIdentical(optional_param_array('username', array('a'=>'default_user'), PARAM_RAW), array('a'=>'default_user'));
+        $d = ob_end_clean();
+        $this->assertTrue($d !== '');
+
+        // make sure array keys are sanitised
+        ob_start();
+        $_POST['username'] = array('abc123_;-/*-+ '=>'arrggh', 'a1_-'=>'post_user');
+        $this->assertIdentical(optional_param_array('username', array(), PARAM_RAW), array('a1_-'=>'post_user'));
+        $d = ob_end_clean();
+        $this->assertTrue($d !== '');
+
+        if ($debugging !== null) {
+            $CFG->debug = $debugging;
+        } else {
+            unset($CFG->debug);
+        }
+        if ($debugdisplay !== null) {
+            $CFG->debugdisplay = $debugdisplay;
+        } else {
+            unset($CFG->debugdisplay);
+        }
+    }
+
+    function test_required_param() {
+        global $CFG;
+
+        $_POST['username'] = 'post_user';
+        $_GET['username'] = 'get_user';
+        $this->assertIdentical(required_param('username', PARAM_RAW), 'post_user');
+
+        unset($_POST['username']);
+        $this->assertIdentical(required_param('username', PARAM_RAW), 'get_user');
+
+        unset($_GET['username']);
+        try {
+            $this->assertIdentical(required_param('username', PARAM_RAW), 'default_user');
+            $this->fail('moodle_exception expected');
+        } catch (moodle_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+        // make sure exception is triggered when some params are missing, hide error notices here - new in 2.2
+        $_POST['username'] = 'post_user';
+        try {
+            @required_param('username');
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            required_param('username', '');
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            required_param('', PARAM_RAW);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+        // make sure warning is displayed if array submitted - TODO: throw exception in Moodle 2.3
+        $debugging = isset($CFG->debug) ? $CFG->debug : null;
+        $debugdisplay = isset($CFG->debugdisplay) ? $CFG->debugdisplay : null;
+        $CFG->debug = 38911;
+        $CFG->debugdisplay = true;
+
+        ob_start();
+        $this->assertIdentical(required_param('username', PARAM_RAW), $_POST['username']);
+        $d = ob_end_clean();
+        $this->assertTrue($d !== '');
+
+        if ($debugging !== null) {
+            $CFG->debug = $debugging;
+        } else {
+            unset($CFG->debug);
+        }
+        if ($debugdisplay !== null) {
+            $CFG->debugdisplay = $debugdisplay;
+        } else {
+            unset($CFG->debugdisplay);
+        }
+    }
+
+    function test_required_param_array() {
+        global $CFG;
+
+        $_POST['username'] = array('a'=>'post_user');
+        $_GET['username'] = array('a'=>'get_user');
+        $this->assertIdentical(required_param_array('username', PARAM_RAW), $_POST['username']);
+
+        unset($_POST['username']);
+        $this->assertIdentical(required_param_array('username', PARAM_RAW), $_GET['username']);
+
+        // make sure exception is triggered when some params are missing, hide error notices here - new in 2.2
+        $_POST['username'] = array('a'=>'post_user');
+        try {
+            required_param_array('username', null);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            @required_param_array('username');
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            required_param_array('', PARAM_RAW);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+        // do not allow nested arrays
+        try {
+            $_POST['username'] = array('a'=>array('b'=>'post_user'));
+            required_param_array('username', PARAM_RAW);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+        // do not allow non-arrays
+        try {
+            $_POST['username'] = 'post_user';
+            required_param_array('username', PARAM_RAW);
+            $this->fail('moodle_exception expected');
+        } catch (moodle_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+        // do not allow non-arrays
+        $debugging = isset($CFG->debug) ? $CFG->debug : null;
+        $debugdisplay = isset($CFG->debugdisplay) ? $CFG->debugdisplay : null;
+        $CFG->debug = 38911;
+        $CFG->debugdisplay = true;
+
+        // make sure array keys are sanitised
+        ob_start();
+        $_POST['username'] = array('abc123_;-/*-+ '=>'arrggh', 'a1_-'=>'post_user');
+        $this->assertIdentical(required_param_array('username', PARAM_RAW), array('a1_-'=>'post_user'));
+        $d = ob_end_clean();
+        $this->assertTrue($d !== '');
+
+        if ($debugging !== null) {
+            $CFG->debug = $debugging;
+        } else {
+            unset($CFG->debug);
+        }
+        if ($debugdisplay !== null) {
+            $CFG->debugdisplay = $debugdisplay;
+        } else {
+            unset($CFG->debugdisplay);
+        }
+    }
+
+    function test_clean_param() {
+        // forbid objects and arrays
+        try {
+            clean_param(array('x', 'y'), PARAM_RAW);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            $param = new stdClass();
+            $param->id = 1;
+            clean_param($param, PARAM_RAW);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+        // require correct type
+        try {
+            clean_param('x', 'xxxxxx');
+            $this->fail('moodle_exception expected');
+        } catch (moodle_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            @clean_param('x');
+            $this->fail('moodle_exception expected');
+        } catch (moodle_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+    }
+
+    function test_clean_param_array() {
+        $this->assertIdentical(clean_param_array(null, PARAM_RAW), array());
+        $this->assertIdentical(clean_param_array(array('a', 'b'), PARAM_RAW), array('a', 'b'));
+        $this->assertIdentical(clean_param_array(array('a', array('b')), PARAM_RAW, true), array('a', array('b')));
+
+        // require correct type
+        try {
+            clean_param_array(array('x'), 'xxxxxx');
+            $this->fail('moodle_exception expected');
+        } catch (moodle_exception $ex) {
+            $this->assertTrue(true);
+        }
+        try {
+            @clean_param_array(array('x'));
+            $this->fail('moodle_exception expected');
+        } catch (moodle_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+        try {
+            clean_param_array(array('x', array('y')), PARAM_RAW);
+            $this->fail('coding_exception expected');
+        } catch (coding_exception $ex) {
+            $this->assertTrue(true);
+        }
+
+        // test recursive
     }
 
     function test_clean_param_raw() {
index f6e6c74..6a93f6e 100644 (file)
@@ -114,6 +114,12 @@ class plugin_defective_exception extends moodle_exception {
 function upgrade_main_savepoint($result, $version, $allowabort=true) {
     global $CFG;
 
+    //sanity check to avoid confusion with upgrade_mod_savepoint usage.
+    if (!is_bool($allowabort)) {
+        $errormessage = 'Parameter type mismatch. Are you mixing up upgrade_main_savepoint() and upgrade_mod_savepoint()?';
+        throw new coding_exception($errormessage);
+    }
+
     if (!$result) {
         throw new upgrade_exception(null, $version);
     }
index 5129c81..f81efba 100644 (file)
@@ -697,7 +697,8 @@ function clam_message_admins($notice) {
     $admins = get_admins();
     foreach ($admins as $admin) {
         $eventdata = new stdClass();
-        $eventdata->modulename        = 'moodle';
+        $eventdata->component         = 'moodle';
+        $eventdata->name              = 'errors';
         $eventdata->userfrom          = get_admin();
         $eventdata->userto            = $admin;
         $eventdata->subject           = $subject;
index 0608d76..f5fc673 100644 (file)
@@ -65,7 +65,13 @@ if ($p_secret !== false) {
 
     update_login_count();
 
-    $user = get_complete_user_data('username', $p_username);
+    $user = $DB->get_record('user', array('username'=>$p_username, 'mnethostid'=>$CFG->mnet_localhost_id, 'deleted'=>0, 'suspended'=>0));
+
+    if ($user and ($user->auth === 'nologin' or !is_enabled_auth($user->auth))) {
+        // bad luck - user is not able to login, do not let them reset password
+        $user = false;
+    }
+
     if (!empty($user) and $user->secret === '') {
         echo $OUTPUT->header();
         print_error('secretalreadyused');
@@ -120,10 +126,17 @@ if ($mform->is_cancelled()) {
 
     // first try the username
     if (!empty($data->username)) {
-        $user = get_complete_user_data('username', $data->username);
+        $username = textlib_get_instance()->strtolower($data->username); // mimic the login page process, if they forget username they need to use email for reset
+        $user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id, 'deleted'=>0, 'suspended'=>0));
+
     } else {
+        // this is tricky because
+        // 1/ the email is not guaranteed to be unique - TODO: send email with all usernames to select the correct account for pw reset
+        // 2/ mailbox may be case sensitive, the email domain is case insensitive - let's pretend it is all case-insensitive
 
-        $user = get_complete_user_data('email', $data->email);
+        $select = $DB->sql_like('email', ':email', false, true, false, '|'). " AND mnethostid = :mnethostid AND deleted=0 AND suspended=0";
+        $params = array('email'=>$DB->sql_like_escape($data->email, '|'), 'mnethostid'=>$CFG->mnet_localhost_id);
+        $user = $DB->get_record_select('user', $select, $params, '*', IGNORE_MULTIPLE);
     }
 
     if ($user and !empty($user->confirmed)) {
index bbd673b..b9ef145 100644 (file)
@@ -7,7 +7,7 @@
     $format     = optional_param('format', CHOICE_PUBLISH_NAMES, PARAM_INT);
     $download   = optional_param('download', '', PARAM_ALPHA);
     $action     = optional_param('action', '', PARAM_ALPHA);
-    $attemptids = optional_param('attemptid', array(), PARAM_INT); //get array of responses to delete.
+    $attemptids = optional_param_array('attemptid', array(), PARAM_INT); //get array of responses to delete.
 
     $url = new moodle_url('/mod/choice/report.php', array('id'=>$id));
     if ($format !== CHOICE_PUBLISH_NAMES) {
     $results = prepare_choice_show_results($choice, $course, $cm, $users);
     $renderer = $PAGE->get_renderer('mod_choice');
     echo $renderer->display_result($results, has_capability('mod/choice:readresponses', $context));
-    
+
    //now give links for downloading spreadsheets.
     if (!empty($users) && has_capability('mod/choice:downloadresponses',$context)) {
         $downloadoptions = array();
index 2e11c5e..b35e017 100644 (file)
@@ -6,7 +6,7 @@
 
     $id         = required_param('id', PARAM_INT);                 // Course Module ID
     $action     = optional_param('action', '', PARAM_ALPHA);
-    $attemptids = optional_param('attemptid', array(), PARAM_INT); // array of attempt ids for delete action
+    $attemptids = optional_param_array('attemptid', array(), PARAM_INT); // array of attempt ids for delete action
 
     $url = new moodle_url('/mod/choice/view.php', array('id'=>$id));
     if ($action !== '') {
index 8b5c898..7571d07 100644 (file)
@@ -96,7 +96,7 @@ class data_field_checkbox extends data_field_base {
     }
 
     function parse_search_field() {
-        $selected    = optional_param('f_'.$this->field->id, array(), PARAM_NOTAGS);
+        $selected    = optional_param_array('f_'.$this->field->id, array(), PARAM_NOTAGS);
         $allrequired = optional_param('f_'.$this->field->id.'_allreq', 0, PARAM_BOOL);
         if (empty($selected)) {
             // no searching
index 170af17..f3fe90b 100644 (file)
@@ -122,7 +122,7 @@ class data_field_multimenu extends data_field_base {
     }
 
     function parse_search_field() {
-        $selected    = optional_param('f_'.$this->field->id, array(), PARAM_NOTAGS);
+        $selected    = optional_param_array('f_'.$this->field->id, array(), PARAM_NOTAGS);
         $allrequired = optional_param('f_'.$this->field->id.'_allreq', 0, PARAM_BOOL);
         if (empty($selected)) {
             // no searching
index 7c25e0c..8d0e7ec 100644 (file)
@@ -1060,7 +1060,7 @@ function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfro
     }
 
     if (!isset($userto->canpost[$discussion->id])) {
-        $canreply = forum_user_can_post($forum, $discussion, $userto);
+        $canreply = forum_user_can_post($forum, $discussion, $userto, $cm, $course);
     } else {
         $canreply = $userto->canpost[$discussion->id];
     }
index 0bbd37f..5cc2f89 100644 (file)
@@ -42,7 +42,7 @@ $attemptid = required_param('attempt', PARAM_INT);
 $page = optional_param('page', 0, PARAM_INT);
 
 $attemptobj = quiz_attempt::create($attemptid);
-$PAGE->set_url($attemptobj->attempt_url(0, $page));
+$PAGE->set_url($attemptobj->attempt_url(null, $page));
 
 // Check login.
 require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
index 7243170..0e1ea24 100644 (file)
@@ -544,25 +544,21 @@ function quiz_save_best_grade($quiz, $userid = null, $attempts = array()) {
 /**
  * Calculate the overall grade for a quiz given a number of attempts by a particular user.
  *
- * @return float          The overall grade
- * @param object $quiz    The quiz for which the best grade is to be calculated
- * @param array $attempts An array of all the attempts of the user at the quiz
+ * @param object $quiz    the quiz settings object.
+ * @param array $attempts an array of all the user's attempts at this quiz in order.
+ * @return float          the overall grade
  */
 function quiz_calculate_best_grade($quiz, $attempts) {
 
     switch ($quiz->grademethod) {
 
         case QUIZ_ATTEMPTFIRST:
-            foreach ($attempts as $attempt) {
-                return $attempt->sumgrades;
-            }
-            return $final;
+            $firstattempt = reset($attempts);
+            return $firstattempt->sumgrades;
 
         case QUIZ_ATTEMPTLAST:
-            foreach ($attempts as $attempt) {
-                $final = $attempt->sumgrades;
-            }
-            return $final;
+            $lastattempt = end($attempts);
+            return $lastattempt->sumgrades;
 
         case QUIZ_GRADEAVERAGE:
             $sum = 0;
@@ -578,8 +574,8 @@ function quiz_calculate_best_grade($quiz, $attempts) {
             }
             return $sum / $count;
 
-        default:
         case QUIZ_GRADEHIGHEST:
+        default:
             $max = null;
             foreach ($attempts as $attempt) {
                 if ($attempt->sumgrades > $max) {
index 79da301..7c25b7a 100644 (file)
@@ -57,7 +57,7 @@ if ($next) {
 if ($page == -1) {
     $nexturl = $attemptobj->summary_url();
 } else {
-    $nexturl = $attemptobj->attempt_url(0, $page);
+    $nexturl = $attemptobj->attempt_url(null, $page);
     if ($scrollpos !== '') {
         $nexturl->param('scrollpos', $scrollpos);
     }
@@ -96,7 +96,7 @@ if (!$finishattempt) {
         $attemptobj->process_all_actions($timenow);
     } catch (question_out_of_sequence_exception $e) {
         print_error('submissionoutofsequencefriendlymessage', 'question',
-                $attemptobj->attempt_url(0, $thispage));
+                $attemptobj->attempt_url(null, $thispage));
     }
     $transaction->allow_commit();
     redirect($nexturl);
index 49d2cb3..9709681 100644 (file)
@@ -417,8 +417,8 @@ class mod_quiz_renderer extends plugin_renderer_base {
 
         // Print all the questions
         foreach ($slots as $slot) {
-            $output .= $attemptobj->render_question($slot, false, $attemptobj->attempt_url($id,
-                    $page));
+            $output .= $attemptobj->render_question($slot, false,
+                    $attemptobj->attempt_url($slot, $page));
         }
 
         $output .= html_writer::start_tag('div', array('class' => 'submitbtns'));
@@ -761,8 +761,9 @@ class mod_quiz_renderer extends plugin_renderer_base {
             }
             $row[] = $datecompleted;
 
-            if ($viewobj->markcolumn && $attempt->timefinish > 0) {
-                if ($attemptoptions->marks >= question_display_options::MARK_AND_MAX) {
+            if ($viewobj->markcolumn) {
+                if ($attemptoptions->marks >= question_display_options::MARK_AND_MAX &&
+                        $attempt->timefinish > 0) {
                     $row[] = quiz_format_grade($quiz, $attempt->sumgrades);
                 } else {
                     $row[] = '';
index 44c420f..05affcd 100644 (file)
@@ -439,7 +439,7 @@ class quiz_grading_report extends quiz_default_report {
         if (!$qubaids) {
             return false;
         }
-        $qubaids = clean_param(explode(',', $qubaids), PARAM_INT);
+        $qubaids = clean_param_array(explode(',', $qubaids), PARAM_INT);
 
         $slots = optional_param('slots', '', PARAM_SEQUENCE);
         if (!$slots) {
@@ -471,7 +471,7 @@ class quiz_grading_report extends quiz_default_report {
             return;
         }
 
-        $qubaids = clean_param(explode(',', $qubaids), PARAM_INT);
+        $qubaids = clean_param_array(explode(',', $qubaids), PARAM_INT);
         $attempts = $this->load_attempts_by_usage_ids($qubaids);
 
         $transaction = $DB->start_delegated_transaction();
@@ -520,7 +520,7 @@ class quiz_grading_report extends quiz_default_report {
      */
     protected function get_usage_ids_where_question_in_state($summarystate, $slot,
             $questionid = null, $orderby = 'random', $page = 0, $pagesize = null) {
-        global $CFG;
+        global $CFG, $DB;
         $dm = new question_engine_data_mapper();
 
         if ($pagesize && $orderby != 'random') {
@@ -544,7 +544,7 @@ class quiz_grading_report extends quiz_default_report {
         } else if ($orderby == 'student' || $orderby == 'idnumber') {
             $qubaids->from .= " JOIN {user} u ON quiza.userid = u.id ";
             if ($orderby == 'student') {
-                $orderby = sql_fullname('u.firstname', 'u.lastname');
+                $orderby = $DB->sql_fullname('u.firstname', 'u.lastname');
             }
         }
 
index aec7809..58041fb 100644 (file)
@@ -133,14 +133,14 @@ class quiz_overview_report extends quiz_attempt_report {
         // Process actions.
         if (empty($currentgroup) || $groupstudents) {
             if (optional_param('delete', 0, PARAM_BOOL) && confirm_sesskey()) {
-                if ($attemptids = optional_param('attemptid', array(), PARAM_INT)) {
+                if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT)) {
                     require_capability('mod/quiz:deleteattempts', $this->context);
                     $this->delete_selected_attempts($quiz, $cm, $attemptids, $allowed);
                     redirect($reporturl->out(false, $displayoptions));
                 }
 
             } else if (optional_param('regrade', 0, PARAM_BOOL) && confirm_sesskey()) {
-                if ($attemptids = optional_param('attemptid', array(), PARAM_INT)) {
+                if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT)) {
                     require_capability('mod/quiz:regrade', $this->context);
                     $this->regrade_attempts($quiz, false, $groupstudents, $attemptids);
                     redirect($reporturl->out(false, $displayoptions));
index 5abf1e2..904ff58 100644 (file)
@@ -124,7 +124,7 @@ class quiz_responses_report extends quiz_attempt_report {
             $allowed = array();
         }
 
-        if ($attemptids = optional_param('attemptid', array(), PARAM_INT) && confirm_sesskey()) {
+        if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT) && confirm_sesskey()) {
             require_capability('mod/quiz:deleteattempts', $this->context);
             $this->delete_selected_attempts($quiz, $cm, $attemptids, $allowed);
             redirect($reporturl->out(false, $displayoptions));
index cd36bd9..b744e05 100644 (file)
@@ -57,7 +57,7 @@ $options = $attemptobj->get_display_options(true);
 // Check permissions.
 if ($attemptobj->is_own_attempt()) {
     if (!$attemptobj->is_finished()) {
-        redirect($attemptobj->attempt_url(0, $page));
+        redirect($attemptobj->attempt_url(null, $page));
     } else if (!$options->attempt) {
         $accessmanager->back_to_view_page($attemptobj->is_preview_user(),
                 $accessmanager->cannot_review_message($attemptobj->get_attempt_state()));
index b972a29..b0a55f0 100644 (file)
@@ -81,6 +81,7 @@ $string['displaysettings'] = 'Display Settings';
 $string['domxml'] = 'DOMXML external library';
 $string['duedate'] = 'Due date';
 $string['element'] = 'Element';
+$string['elementdefinition'] = 'Element Definition';
 $string['enter'] = 'Enter';
 $string['entercourse'] = 'Enter course';
 $string['errorlogs'] = 'Errors log';
@@ -145,6 +146,20 @@ $string['identifier'] = 'Question identifier';
 $string['incomplete'] = 'Incomplete';
 $string['info'] = 'Info';
 $string['interactions'] = 'Interactions';
+$string['interactionsid'] = 'Id of the element';
+$string['interactionscorrectcount'] = 'Number of correct results for the question';
+$string['interactionspattern'] = 'Pattern of correct response';
+$string['interactionslatency'] = 'Time elapsed between the time the interaction <br />was made available to the learner for response <br />and the time of the first response';
+$string['interactionsresponse'] = 'Student\'s Response';
+$string['interactionsresult'] = 'Result based on student\'s response and <br />correct result';
+$string['interactionsscoremin'] = 'Minimum value in the range for the raw score';
+$string['interactionsscoremax'] = 'Maximum value in the range for the raw score';
+$string['interactionsscoreraw'] = 'Number that reflects the performance of the learner<br /> relative to the range bounded by the values of min and max';
+$string['interactionssuspenddata'] = 'Provides space to store and retrieve data <br />between learner sessions';
+$string['interactionstime'] = 'Time at which the attempt was intiated';
+$string['interactionstype'] = 'Type of question';
+$string['interactionsweight'] = 'Weight assigned to the element';
+$string['interactionslearnerresponse'] = 'Learner\'s Response';
 $string['invalidactivity'] = 'Scorm activity is incorrect';
 $string['invalidmanifestresource'] = 'WARNING: The following resources were referenced in your manifest but couldn\'t be found:';
 $string['last'] = 'Last accessed on';
index 781e763..2381b39 100644 (file)
@@ -171,6 +171,7 @@ if (empty($scorm->popup) || $displaymode=='popup') {
     $PAGE->set_button($exitlink);
 }
 
+$PAGE->requires->yui2_lib('connection');
 $PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,
                                                       'cheight'=>$scorm->height,
                                                       'popupoptions' => $scorm->options), true);
index fc849a7..8f7c8be 100644 (file)
@@ -35,7 +35,7 @@ class scorm_basic_report extends scorm_default_report {
         global $CFG, $DB, $OUTPUT, $PAGE;
         $contextmodule= get_context_instance(CONTEXT_MODULE, $cm->id);
         $action = optional_param('action', '', PARAM_ALPHA);
-        $attemptids = optional_param('attemptid', array(), PARAM_RAW);
+        $attemptids = optional_param_array('attemptid', array(), PARAM_RAW);
 
         if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
             if (scorm_delete_responses($attemptids, $scorm)) { //delete responses.
index b1a415c..1ba0791 100644 (file)
 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
 
 /**
-* This page displays the user data from a single attempt
-*
-* @package mod
-* @subpackage scorm
-* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
-* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-*/
+ * This page displays the user data from a single attempt
+ *
+ * @package mod
+ * @subpackage scorm
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
 
 require_once("../../config.php");
 require_once($CFG->dirroot.'/mod/scorm/locallib.php');
@@ -289,7 +289,7 @@ if (!empty($b)) {
                 'cmi.objectives.'.$i.'.score.max');
         $row = array();
         foreach ($elements as $element) {
-           if (isset($trackdata->$element)) {
+            if (isset($trackdata->$element)) {
                 $row[] = s($trackdata->$element);
                 $printedelements[]=$element;
             } else {
@@ -306,7 +306,7 @@ if (!empty($b)) {
         echo html_writer::table($table);
     }
     $table = new html_table();
-    $table->head = array(get_string('element', 'scorm'), get_string('value', 'scorm'));
+    $table->head = array(get_string('element', 'scorm'), get_string('elementdefinition', 'scorm'), get_string('value', 'scorm'));
     $table->align = array('left', 'left');
     $table->wrap = array('nowrap', 'wrap');
     $table->width = '100%';
@@ -319,7 +319,42 @@ if (!empty($b)) {
             if (!(in_array ($element, $printedelements))) {
                 $existelements = true;
                 $row = array();
-                $row[] = get_string($element, 'scorm') != '[['.$element.']]' ? get_string($element, 'scorm') : $element;
+                $string=false;
+                if (stristr($element, '.id') !== false) {
+                    $string="interactionsid";
+                } else if (stristr($element, '.result') !== false) {
+                    $string="interactionsresult";
+                } else if (stristr($element, '.student_response') !== false) {
+                    $string="interactionsresponse";
+                } else if (stristr($element, '.type') !== false) {
+                    $string="interactionstype";
+                } else if (stristr($element, '.weighting') !== false) {
+                    $string="interactionsweight";
+                } else if (stristr($element, '.time') !== false) {
+                    $string="interactionstime";
+                } else if (stristr($element, '.correct_responses._count') !== false) {
+                    $string="interactionscorrectcount";
+                } else if (stristr($element, '.learner_response') !== false) {
+                    $string="interactionslearnerresponse";
+                } else if (stristr($element, '.score.min') !== false) {
+                    $string="interactionslscoremin";
+                } else if (stristr($element, '.score.max') !== false) {
+                    $string="interactionsscoremax";
+                } else if (stristr($element, '.score.raw') !== false) {
+                    $string="interactionsscoreraw";
+                } else if (stristr($element, '.latency') !== false) {
+                    $string="interactionslatency";
+                } else if (stristr($element, '.pattern') !== false) {
+                    $string="interactionspattern";
+                } else if (stristr($element, '.suspend_data') !== false) {
+                    $string="interactionssuspenddata";
+                }
+                $row[]=$element;
+                if (empty($string)) {
+                    $row[]=null;
+                } else {
+                    $row[] = get_string($string, 'scorm');
+                }
                 if (strpos($element, '_time') === false) {
                     $row[] = s($value);
                 } else {
index c7ecc4f..f948872 100644 (file)
@@ -52,3 +52,9 @@ optional - no changes needed in older code:
 * new ratings API
   (http://docs.moodle.org/dev/Ratings_2.0)
 
+
+=== 2.2 ===
+
+required changes in code:
+* fix missing parameter types in optional_param() and required_param()
+* use new optional_param_array(), required_param_array() or clean_param_array() when dealing with array parameters
\ No newline at end of file
index a502b8e..5807c02 100644 (file)
@@ -191,7 +191,7 @@ abstract class question_behaviour_attempt_updater {
                 $this->logger->log_assumption("Ignoring bogus state in attempt at question {$state->question}");
                 $this->sequencenumber = 0;
                 $this->qa->steps = array();
-            } else if ($state->answer == '') {
+            } else if ($this->qtypeupdater->is_blank_answer($state)) {
                 $this->logger->log_assumption("Ignoring second start state with blank answer in attempt at question {$state->question}");
                 return;
             } else {
index ed97f21..5ba8e1c 100644 (file)
@@ -568,6 +568,10 @@ abstract class question_qtype_attempt_updater {
         return $answer1 == $answer2;
     }
 
+    public function is_blank_answer($state) {
+        return $state->answer == '';
+    }
+
     public abstract function right_answer();
     public abstract function response_summary($state);
     public abstract function was_answered($state);
index 4dcc257..dec1769 100644 (file)
@@ -92,7 +92,7 @@ M.core_scroll_manager.scroll_to_saved_pos = function(Y) {
         // And the following horror is necessary to make it work in IE 8.
         // Note that the class ie8 on body is only there in Moodle 2.0 and OU Moodle.
         if (Y.one('body').hasClass('ie')) {
-            M.core_scroll_manager.force_ie_to_scroll(matches[1])
+            M.core_scroll_manager.force_ie_to_scroll(Y, matches[1])
         }
     }
 }
@@ -101,7 +101,7 @@ M.core_scroll_manager.scroll_to_saved_pos = function(Y) {
  * Beat IE into submission.
  * @param targetpos the target scroll position.
  */
-M.core_scroll_manager.force_ie_to_scroll = function(targetpos) {
+M.core_scroll_manager.force_ie_to_scroll = function(Y, targetpos) {
     var hackcount = 25;
     function do_scroll() {
         window.scrollTo(0, targetpos);
index bb59e1e..3ecbc9d 100644 (file)
@@ -80,7 +80,7 @@ class qtype_calculated_question extends qtype_numerical_question
 
     public function get_variants_selection_seed() {
         if (!empty($this->synchronised) &&
-                $this->datasetloader->datasets_are_synchronised($question->category)) {
+                $this->datasetloader->datasets_are_synchronised($this->category)) {
             return 'category' . $this->category;
         } else {
             return parent::get_variants_selection_seed();
index f4a1dca..6b93bd1 100644 (file)
@@ -68,6 +68,7 @@ class qtype_calculated_test_helper extends question_test_helper {
         $q->unitgradingtype = 0;
         $q->unitpenalty = 0;
         $q->ap = new qtype_numerical_answer_processor(array());
+        $q->synchronised = false;
 
         $q->datasetloader = new qtype_calculated_test_dataset_loader(0, array(
             array('a' => 1, 'b' => 5),
@@ -88,6 +89,7 @@ class qtype_calculated_test_helper extends question_test_helper {
  */
 class qtype_calculated_test_dataset_loader extends qtype_calculated_dataset_loader{
     protected $valuesets;
+    protected $aresynchronised = array();
 
     public function __construct($questionid, array $valuesets) {
         parent::__construct($questionid);
@@ -101,4 +103,17 @@ class qtype_calculated_test_dataset_loader extends qtype_calculated_dataset_load
     public function load_values($itemnumber) {
         return $this->valuesets[$itemnumber - 1];
     }
+
+    public function datasets_are_synchronised($category) {
+        return !empty($this->aresynchronised[$category]);
+    }
+
+    /**
+     * Allows the test to mock the return value of {@link datasets_are_synchronised()}.
+     * @param int $category
+     * @param bool $aresychronised
+     */
+    public function set_are_synchronised($category, $aresychronised) {
+        $this->aresynchronised[$category] = $aresychronised;
+    }
 }
index 6df2ca5..5678e9b 100644 (file)
@@ -108,4 +108,23 @@ class qtype_calculated_question_test extends UnitTestCase {
                 question_classified_response::no_response()),
                 $question->classify_response(array('answer' => '')));
     }
-}
\ No newline at end of file
+
+    public function test_get_variants_selection_seed_q_not_synchronised() {
+        $question = test_question_maker::make_question('calculated');
+        $this->assertEqual($question->stamp, $question->get_variants_selection_seed());
+    }
+
+    public function test_get_variants_selection_seed_q_synchronised_datasets_not() {
+        $question = test_question_maker::make_question('calculated');
+        $question->synchronised = true;
+        $this->assertEqual($question->stamp, $question->get_variants_selection_seed());
+    }
+
+    public function test_get_variants_selection_seed_q_synchronised() {
+        $question = test_question_maker::make_question('calculated');
+        $question->synchronised = true;
+        $question->datasetloader->set_are_synchronised($question->category, true);
+        $this->assertEqual('category' . $question->category,
+                $question->get_variants_selection_seed());
+    }
+}
index aa96ac2..35c9155 100644 (file)
@@ -72,7 +72,7 @@ class qtype_calculatedmulti_single_question extends qtype_multichoice_single_que
 
     public function get_variants_selection_seed() {
         if (!empty($this->synchronised) &&
-                $this->datasetloader->datasets_are_synchronised($question->category)) {
+                $this->datasetloader->datasets_are_synchronised($this->category)) {
             return 'category' . $this->category;
         } else {
             return parent::get_variants_selection_seed();
diff --git a/question/type/match/styles.css b/question/type/match/styles.css
new file mode 100644 (file)
index 0000000..0f79d8c
--- /dev/null
@@ -0,0 +1,3 @@
+.que.match .feedback .rightanswer * {
+    display: inline;
+}
index 34c0c4e..d12c581 100644 (file)
@@ -284,7 +284,11 @@ class qtype_multianswer_edit_form extends question_edit_form {
                         foreach ($wrapped->options->answers as $subanswer) {
                             $parsableanswerdef .= $separator
                                 . '%' . round(100*$subanswer->fraction) . '%';
-                            $parsableanswerdef .= $subanswer->answer;
+                            if (is_array($subanswer->answer)) {
+                                $parsableanswerdef .= $subanswer->answer['text'];
+                            } else {
+                                $parsableanswerdef .= $subanswer->answer;
+                            }
                             if (!empty($wrapped->options->tolerance)) {
                                 // Special for numerical answers:
                                 $parsableanswerdef .= ":{$wrapped->options->tolerance}";
@@ -361,6 +365,9 @@ class qtype_multianswer_edit_form extends question_edit_form {
                                 $default_values[$prefix.'tolerance['.$key.']'] =
                                         $subquestion->tolerance[0];
                             }
+                            if (is_array($answer)) {
+                                $answer = $answer['text'];
+                            }
                             $trimmedanswer = trim($answer);
                             if ($trimmedanswer !== '') {
                                 $answercount++;
@@ -438,6 +445,9 @@ class qtype_multianswer_edit_form extends question_edit_form {
                                 $this->savedquestiondisplay->options->questions[$sub]->qtype);
                     }
                     foreach ($subquestion->answer as $key => $answer) {
+                        if (is_array($answer)) {
+                            $answer = $answer['text'];
+                        }
                         $trimmedanswer = trim($answer);
                         if ($trimmedanswer !== '') {
                             $answercount++;
index 29d5214..2b04b58 100644 (file)
@@ -284,7 +284,7 @@ function qtype_multianswer_extract_question($text) {
     $question->qtype = 'multianswer';
     $question->questiontext = $text;
     $question->generalfeedback['text'] = '';
-    $question->generalfeedback['format'] = '1';
+    $question->generalfeedback['format'] = FORMAT_HTML;
     $question->generalfeedback['itemid'] = '';
 
     $question->options->questions = array();
@@ -295,7 +295,7 @@ function qtype_multianswer_extract_question($text) {
             ++$positionkey) {
         $wrapped = new stdClass();
         $wrapped->generalfeedback['text'] = '';
-        $wrapped->generalfeedback['format'] = '1';
+        $wrapped->generalfeedback['format'] = FORMAT_HTML;
         $wrapped->generalfeedback['itemid'] = '';
         if (isset($answerregs[ANSWER_REGEX_NORM])&& $answerregs[ANSWER_REGEX_NORM]!== '') {
             $wrapped->defaultmark = $answerregs[ANSWER_REGEX_NORM];
@@ -307,7 +307,7 @@ function qtype_multianswer_extract_question($text) {
             $wrapped->multiplier = array();
             $wrapped->units      = array();
             $wrapped->instructions['text'] = '';
-            $wrapped->instructions['format'] = '1';
+            $wrapped->instructions['format'] = FORMAT_HTML;
             $wrapped->instructions['itemid'] = '';
         } else if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_SHORTANSWER])) {
             $wrapped->qtype = 'shortanswer';
@@ -321,13 +321,13 @@ function qtype_multianswer_extract_question($text) {
             $wrapped->shuffleanswers = 1;
             $wrapped->answernumbering = 0;
             $wrapped->correctfeedback['text'] = '';
-            $wrapped->correctfeedback['format'] = '1';
+            $wrapped->correctfeedback['format'] = FORMAT_HTML;
             $wrapped->correctfeedback['itemid'] = '';
             $wrapped->partiallycorrectfeedback['text'] = '';
-            $wrapped->partiallycorrectfeedback['format'] = '1';
+            $wrapped->partiallycorrectfeedback['format'] = FORMAT_HTML;
             $wrapped->partiallycorrectfeedback['itemid'] = '';
             $wrapped->incorrectfeedback['text'] = '';
-            $wrapped->incorrectfeedback['format'] = '1';
+            $wrapped->incorrectfeedback['format'] = FORMAT_HTML;
             $wrapped->incorrectfeedback['itemid'] = '';
             $wrapped->layout = qtype_multichoice_base::LAYOUT_DROPDOWN;
         } else if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE_REGULAR])) {
@@ -336,13 +336,13 @@ function qtype_multianswer_extract_question($text) {
             $wrapped->shuffleanswers = 0;
             $wrapped->answernumbering = 0;
             $wrapped->correctfeedback['text'] = '';
-            $wrapped->correctfeedback['format'] = '1';
+            $wrapped->correctfeedback['format'] = FORMAT_HTML;
             $wrapped->correctfeedback['itemid'] = '';
             $wrapped->partiallycorrectfeedback['text'] = '';
-            $wrapped->partiallycorrectfeedback['format'] = '1';
+            $wrapped->partiallycorrectfeedback['format'] = FORMAT_HTML;
             $wrapped->partiallycorrectfeedback['itemid'] = '';
             $wrapped->incorrectfeedback['text'] = '';
-            $wrapped->incorrectfeedback['format'] = '1';
+            $wrapped->incorrectfeedback['format'] = FORMAT_HTML;
             $wrapped->incorrectfeedback['itemid'] = '';
             $wrapped->layout = qtype_multichoice_base::LAYOUT_VERTICAL;
         } else if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE_HORIZONTAL])) {
@@ -351,13 +351,13 @@ function qtype_multianswer_extract_question($text) {
             $wrapped->shuffleanswers = 0;
             $wrapped->answernumbering = 0;
             $wrapped->correctfeedback['text'] = '';
-            $wrapped->correctfeedback['format'] = '1';
+            $wrapped->correctfeedback['format'] = FORMAT_HTML;
             $wrapped->correctfeedback['itemid'] = '';
             $wrapped->partiallycorrectfeedback['text'] = '';
-            $wrapped->partiallycorrectfeedback['format'] = '1';
+            $wrapped->partiallycorrectfeedback['format'] = FORMAT_HTML;
             $wrapped->partiallycorrectfeedback['itemid'] = '';
             $wrapped->incorrectfeedback['text'] = '';
-            $wrapped->incorrectfeedback['format'] = '1';
+            $wrapped->incorrectfeedback['format'] = FORMAT_HTML;
             $wrapped->incorrectfeedback['itemid'] = '';
             $wrapped->layout = qtype_multichoice_base::LAYOUT_HORIZONTAL;
         } else {
@@ -372,7 +372,7 @@ function qtype_multianswer_extract_question($text) {
         $wrapped->fraction = array();
         $wrapped->feedback = array();
         $wrapped->questiontext['text'] = $answerregs[0];
-        $wrapped->questiontext['format'] = 0;
+        $wrapped->questiontext['format'] = FORMAT_HTML;
         $wrapped->questiontext['itemid'] = '';
         $answerindex = 0;
 
@@ -390,12 +390,12 @@ function qtype_multianswer_extract_question($text) {
                         $altregs[ANSWER_ALTERNATIVE_REGEX_FEEDBACK], ENT_QUOTES, 'UTF-8');
                 $feedback = str_replace('\}', '}', $feedback);
                 $wrapped->feedback["$answerindex"]['text'] = str_replace('\#', '#', $feedback);
-                $wrapped->feedback["$answerindex"]['format'] = '1';
+                $wrapped->feedback["$answerindex"]['format'] = FORMAT_HTML;
                 $wrapped->feedback["$answerindex"]['itemid'] = '';
             } else {
                 $wrapped->feedback["$answerindex"]['text'] = '';
-                $wrapped->feedback["$answerindex"]['format'] = '1';
-                $wrapped->feedback["$answerindex"]['itemid'] = '1';
+                $wrapped->feedback["$answerindex"]['format'] = FORMAT_HTML;
+                $wrapped->feedback["$answerindex"]['itemid'] = '';
 
             }
             if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL])
@@ -414,6 +414,12 @@ function qtype_multianswer_extract_question($text) {
                         $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], ENT_QUOTES, 'UTF-8');
                 $answer = str_replace('\}', '}', $answer);
                 $wrapped->answer["$answerindex"] = str_replace('\#', '#', $answer);
+                if ($wrapped->qtype == 'multichoice') {
+                    $wrapped->answer["$answerindex"] = array(
+                            'text' => $wrapped->answer["$answerindex"],
+                            'format' => FORMAT_HTML,
+                            'itemid' => '');
+                }
             }
             $tmp = explode($altregs[0], $remainingalts, 2);
             $remainingalts = $tmp[1];
@@ -425,6 +431,5 @@ function qtype_multianswer_extract_question($text) {
         $question->questiontext['text'] = implode("{#$positionkey}",
                     explode($answerregs[0], $question->questiontext['text'], 2));
     }
-    $question->questiontext = $question->questiontext;
     return $question;
 }
index add7a16..b8f8581 100644 (file)
@@ -77,7 +77,7 @@ class qtype_multianswer_test extends UnitTestCase {
         $sadata->id = 1;
         $sadata->qtype = 'shortanswer';
         $sadata->defaultmark = 1;
-        $sadata->options->single = true;
+        $sadata->options->usecase = true;
         $sadata->options->answers[1] = (object) array('answer' => 'Bow-wow', 'fraction' => 0);
         $sadata->options->answers[2] = (object) array('answer' => 'Wiggly worm', 'fraction' => 0);
         $sadata->options->answers[3] = (object) array('answer' => 'Pussy-cat', 'fraction' => 1);
@@ -86,7 +86,7 @@ class qtype_multianswer_test extends UnitTestCase {
         $mcdata->id = 1;
         $mcdata->qtype = 'multichoice';
         $mcdata->defaultmark = 1;
-        $mcdata->options->usecase = true;
+        $mcdata->options->single = true;
         $mcdata->options->answers[1] = (object) array('answer' => 'Dog', 'fraction' => 0);
         $mcdata->options->answers[2] = (object) array('answer' => 'Owl', 'fraction' => 1);
         $mcdata->options->answers[3] = (object) array('answer' => '*', 'fraction' => 0);
index 501a6d8..dd004a5 100644 (file)
@@ -39,6 +39,13 @@ defined('MOODLE_INTERNAL') || die();
 class qtype_multichoice_qe2_attempt_updater extends question_qtype_attempt_updater {
     protected $order;
 
+    public function is_blank_answer($state) {
+        // blank multichoice answers are not empty strings, they rather end in a colon
+        $a = $state->answer;
+        $empty = (substr($a, strlen($a) - 1) == ':');
+        return $empty;
+    }
+
     public function right_answer() {
         if ($this->question->options->single) {
             foreach ($this->question->options->answers as $ans) {
index 240bc4c..e155366 100644 (file)
@@ -182,6 +182,12 @@ class qtype_multichoice extends question_type {
     }
 
     public function get_random_guess_score($questiondata) {
+        if (!$questiondata->options->single) {
+            // Pretty much impossible to compute for _multi questions. Don't try.
+            return null;
+        }
+
+        // Single choice questions - average choice fraction.
         $totalfraction = 0;
         foreach ($questiondata->options->answers as $answer) {
             $totalfraction += $answer->fraction;
index 1afa124..8123972 100644 (file)
@@ -71,6 +71,12 @@ class qtype_multichoice_test extends UnitTestCase {
         $this->assertEqual(0.5, $this->qtype->get_random_guess_score($q));
     }
 
+    public function test_get_random_guess_score_multi() {
+        $q = $this->get_test_question_data();
+        $q->options->single = false;
+        $this->assertNull($this->qtype->get_random_guess_score($q));
+    }
+
     public function test_get_possible_responses_single() {
         $q = $this->get_test_question_data();
         $responses = $this->qtype->get_possible_responses($q);
index e35039f..b7b1a65 100644 (file)
@@ -113,8 +113,15 @@ switch ($action) {
 case 'upload':
     // The uploaded file has been processed in plugin construct function
     // redirect to default page
-    $repo->upload('', $maxbytes);
-    redirect($home_url, get_string('uploadsucc','repository'));
+    try {
+        $repo->upload('', $maxbytes);
+        redirect($home_url, get_string('uploadsucc','repository'));
+    } catch (moodle_exception $e) {
+        // inject target URL
+        $e->link = $PAGE->url->out();
+        echo $OUTPUT->header(); // hack: we need the embedded header here, standard error printing would not use it
+        throw $e;
+    }
     break;
 
 case 'search':
@@ -262,8 +269,15 @@ case 'download':
         $record->license  = '';
         $record->author   = '';
         $record->source   = $thefile['url'];
-        $info = repository::move_to_filepool($thefile['path'], $record);
-        redirect($home_url, get_string('downloadsucc', 'repository'));
+        try {
+            $info = repository::move_to_filepool($thefile['path'], $record);
+            redirect($home_url, get_string('downloadsucc', 'repository'));
+        } catch (moodle_exception $e) {
+            // inject target URL
+            $e->link = $PAGE->url->out();
+            echo $OUTPUT->header(); // hack: we need the embedded header here, standard error printing would not use it
+            throw $e;
+        }
     } else {
         print_error('cannotdownload', 'repository');
     }
index 5216e1f..965d9d8 100644 (file)
@@ -946,6 +946,76 @@ abstract class repository {
         return call_user_func_array(array('repository_' . $plugin, $function), $args);
     }
 
+    /**
+     * Scan file, throws exception in case of infected file.
+     *
+     * Please note that the scanning engine must be able to access the file,
+     * permissions of the file are not modified here!
+     *
+     * @static
+     * @param string $thefile
+     * @param string $filename name of the file
+     * @param bool $deleteinfected
+     * @return void
+     */
+    public static function antivir_scan_file($thefile, $filename, $deleteinfected) {
+        global $CFG;
+
+        if (!is_readable($thefile)) {
+            // this should not happen
+            return;
+        }
+
+        if (empty($CFG->runclamonupload) or empty($CFG->pathtoclam)) {
+            // clam not enabled
+            return;
+        }
+
+        $CFG->pathtoclam = trim($CFG->pathtoclam);
+
+        if (!file_exists($CFG->pathtoclam) or !is_executable($CFG->pathtoclam)) {
+            // misconfigured clam - use the old notification for now
+            require("$CFG->libdir/uploadlib.php");
+            $notice = get_string('clamlost', 'moodle', $CFG->pathtoclam);
+            clam_message_admins($notice);
+            return;
+        }
+
+        // do NOT mess with permissions here, the calling party is responsible for making
+        // sure the scanner engine can access the files!
+
+        // execute test
+        $cmd = escapeshellcmd($CFG->pathtoclam).' --stdout '.escapeshellarg($thefile);
+        exec($cmd, $output, $return);
+
+        if ($return == 0) {
+            // perfect, no problem found
+            return;
+
+        } else if ($return == 1) {
+            // infection found
+            if ($deleteinfected) {
+                unlink($thefile);
+            }
+            throw new moodle_exception('virusfounduser', 'moodle', '', array('filename'=>$filename));
+
+        } else {
+            //unknown problem
+            require("$CFG->libdir/uploadlib.php");
+            $notice = get_string('clamfailed', 'moodle', get_clam_error_code($return));
+            $notice .= "\n\n". implode("\n", $output);
+            clam_message_admins($notice);
+            if ($CFG->clamfailureonupload === 'actlikevirus') {
+                if ($deleteinfected) {
+                    unlink($thefile);
+                }
+                throw new moodle_exception('virusfounduser', 'moodle', '', array('filename'=>$filename));
+            } else {
+                return;
+            }
+        }
+    }
+
     /**
      * Move file from download folder to file pool using FILE API
      * @global object $DB
@@ -962,6 +1032,10 @@ abstract class repository {
      */
     public static function move_to_filepool($thefile, $record) {
         global $DB, $CFG, $USER, $OUTPUT;
+
+        // scan for viruses if possible, throws exception if problem found
+        self::antivir_scan_file($thefile, $record->filename, empty($CFG->repository_no_delete)); //TODO: MDL-28637 this repository_no_delete is a bloody hack!
+
         if ($record->filepath !== '/') {
             $record->filepath = trim($record->filepath, '/');
             $record->filepath = '/'.$record->filepath.'/';
@@ -1501,7 +1575,7 @@ abstract class repository {
 
     public function filter(&$value) {
         $pass = false;
-        $accepted_types = optional_param('accepted_types', '', PARAM_RAW);
+        $accepted_types = optional_param_array('accepted_types', '', PARAM_RAW);
         $ft = new filetype_parser;
         //$ext = $ft->get_extensions($this->supported_filetypes());
         if (isset($value['children'])) {
index 7f0e127..a954ee6 100644 (file)
@@ -46,7 +46,7 @@ $itemid    = optional_param('itemid', 0, PARAM_INT);            // Itemid
 $page      = optional_param('page', '', PARAM_RAW);             // Page
 $maxbytes  = optional_param('maxbytes', 0, PARAM_INT);          // Maxbytes
 $req_path  = optional_param('p', '', PARAM_RAW);                // Path
-$accepted_types  = optional_param('accepted_types', '*', PARAM_RAW);
+$accepted_types  = optional_param_array('accepted_types', '*', PARAM_RAW);
 $saveas_filename = optional_param('title', '', PARAM_FILE);     // save as file name
 $saveas_path   = optional_param('savepath', '/', PARAM_PATH);   // save as file path
 $search_text   = optional_param('s', '', PARAM_CLEANHTML);
@@ -249,17 +249,8 @@ switch ($action) {
         }
         break;
     case 'upload':
-        // handle exception here instead moodle default exception handler
-        // see MDL-23407
-        try {
-            // TODO: add file scanning MDL-19380 into each plugin
-            $result = $repo->upload($saveas_filename, $maxbytes);
-            echo json_encode($result);
-        } catch (Exception $e) {
-            $err->error = $e->getMessage();
-            echo json_encode($err);
-            die;
-        }
+        $result = $repo->upload($saveas_filename, $maxbytes);
+        echo json_encode($result);
         break;
 
     case 'overwrite':
index 8285042..823a68b 100644 (file)
@@ -44,7 +44,7 @@ class repository_upload extends repository {
     public function upload($saveas_filename, $maxbytes) {
         global $USER, $CFG;
 
-        $types = optional_param('accepted_types', '*', PARAM_RAW);
+        $types = optional_param_array('accepted_types', '*', PARAM_RAW);
         if ((is_array($types) and in_array('*', $types)) or $types == '*') {
             $this->mimetypes = '*';
         } else {
@@ -102,6 +102,13 @@ class repository_upload extends repository {
             }
         }
 
+        // scan the files, throws exception and deletes if virus found
+        // this is tricky because clamdscan daemon might not be able to access the files
+        $permissions = fileperms($_FILES[$elname]['tmp_name']);
+        @chmod($_FILES[$elname]['tmp_name'], $CFG->filepermissions);
+        self::antivir_scan_file($_FILES[$elname]['tmp_name'], $_FILES[$elname]['name'], true);
+        @chmod($_FILES[$elname]['tmp_name'], $permissions);
+
         if (empty($saveas_filename)) {
             $record->filename = clean_param($_FILES[$elname]['name'], PARAM_FILE);
         } else {
index c4fae4c..e0edeb9 100644 (file)
@@ -29,9 +29,9 @@ require_once('lib.php');
 define('SHOW_ALL_PAGE_SIZE', 50000);
 define('DEFAULT_PAGE_SIZE', 30);
 
-$tagschecked = optional_param('tagschecked', array(), PARAM_INT);
-$newnames    = optional_param('newname', array(), PARAM_TAG);
-$tagtypes    = optional_param('tagtypes', array(), PARAM_ALPHA);
+$tagschecked = optional_param_array('tagschecked', array(), PARAM_INT);
+$newnames    = optional_param_array('newname', array(), PARAM_TAG);
+$tagtypes    = optional_param_array('tagtypes', array(), PARAM_ALPHA);
 $action      = optional_param('action', '', PARAM_ALPHA);
 $perpage     = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT);
 
index 72ce60b..8c29b7c 100644 (file)
@@ -78,7 +78,7 @@ echo $OUTPUT->doctype() ?>
                  <div id="region-main-pad">
                    <div id="region-main">
                      <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                      </div>
                    </div>
                  </div>
index a5dd741..9d39e02 100644 (file)
@@ -13,7 +13,7 @@
 <!-- END OF HEADER -->
 
     <div id="content" class="clearfix">
-        <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+        <?php echo $OUTPUT->main_content() ?>
     </div>
 
 <!-- START OF FOOTER -->
diff --git a/theme/afterburner/version.php b/theme/afterburner/version.php
new file mode 100644 (file)
index 0000000..8f0c59c
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage afterburner
+ * @copyright  2011 Mary Evans
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_afterburner'; // Full name of the plugin (used for diagnostics)
index 7c5fa8c..0540994 100644 (file)
@@ -46,11 +46,11 @@ echo $OUTPUT->doctype() ?>
             }
             echo $PAGE->headingmenu
         ?></div><?php } ?>
-        
+
         <?php if ($hascustommenu) { ?>
        <div id="custommenu"><?php echo $custommenu; ?></div>
                <?php } ?>
-        
+
         <?php if ($hasnavbar) { ?>
             <div class="navbar clearfix">
                 <div class="breadcrumb"><?php echo $OUTPUT->navbar(); ?></div>
@@ -68,7 +68,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
index b7b3478..cde10e4 100644 (file)
@@ -40,11 +40,11 @@ echo $OUTPUT->doctype() ?>
             }
             echo $PAGE->headingmenu
         ?></div><?php } ?>
-        
+
         <?php if ($hascustommenu) { ?>
        <div id="custommenu"><?php echo $custommenu; ?></div>
                <?php } ?>
-        
+
         <?php if ($hasnavbar) { ?>
             <div class="navbar clearfix">
                 <div class="breadcrumb"><?php echo $OUTPUT->navbar(); ?></div>
@@ -58,7 +58,7 @@ echo $OUTPUT->doctype() ?>
     <div id="page-content" class="clearfix">
         <div id="report-main-content">
             <div class="region-content">
-                <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                <?php echo $OUTPUT->main_content() ?>
             </div>
         </div>
         <?php if ($hassidepre) { ?>
diff --git a/theme/anomaly/version.php b/theme/anomaly/version.php
new file mode 100644 (file)
index 0000000..b655752
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage anomaly
+ * @copyright  2010 Patrick Malley (http://newschoollearning.com/)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_anomaly'; // Full name of the plugin (used for diagnostics)
index 4a5156a..e3da3cc 100644 (file)
@@ -83,7 +83,7 @@ echo $OUTPUT->doctype() ?>
                         <div id="region-main-wrap">
                             <div id="region-main">
                                 <div class="region-content">
-                                    <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                    <?php echo $OUTPUT->main_content() ?>
                                 </div>
                             </div>
                         </div>
index 802ef55..7090f17 100644 (file)
@@ -81,7 +81,7 @@ echo $OUTPUT->doctype() ?>
                         <div id="region-main-wrap">
                             <div id="region-main">
                                 <div class="region-content">
-                                    <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                    <?php echo $OUTPUT->main_content() ?>
                                 </div>
                             </div>
                         </div>
index f254a5c..a23d0d8 100644 (file)
@@ -77,7 +77,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="page-content" class="clearfix">
                     <div id="report-main-content">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                     <?php if ($hassidepost) { ?>
diff --git a/theme/arialist/version.php b/theme/arialist/version.php
new file mode 100644 (file)
index 0000000..4cf67d8
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage arialist
+ * @copyright  2010 Patrick Malley (http://newschoollearning.com/)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_arialist'; // Full name of the plugin (used for diagnostics)
index a5dd741..9d39e02 100644 (file)
@@ -13,7 +13,7 @@
 <!-- END OF HEADER -->
 
     <div id="content" class="clearfix">
-        <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+        <?php echo $OUTPUT->main_content() ?>
     </div>
 
 <!-- START OF FOOTER -->
index 31faa98..4c09416 100644 (file)
@@ -53,7 +53,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
index 26f27fc..cfb761d 100644 (file)
@@ -68,7 +68,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
index 8afd061..e42b1cb 100644 (file)
@@ -58,7 +58,7 @@ echo $OUTPUT->doctype() ?>
     <div id="page-content" class="clearfix">
         <div id="report-main-content">
             <div class="region-content">
-                <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                <?php echo $OUTPUT->main_content() ?>
             </div>
         </div>
         <?php if ($hassidepre) { ?>
diff --git a/theme/base/version.php b/theme/base/version.php
new file mode 100644 (file)
index 0000000..a7e6855
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage base
+ * @copyright  2011 Petr Skoda  {@link http://skodak.org}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_base'; // Full name of the plugin (used for diagnostics)
index ab19302..dfb639a 100644 (file)
@@ -67,7 +67,7 @@ echo $OUTPUT->doctype() ?>
                         <div id="region-main-wrap">
                             <div id="region-main">
                                 <div class="region-content">
-                                    <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                    <?php echo $OUTPUT->main_content() ?>
                                 </div>
                             </div>
                         </div>
index e601ed0..8718236 100644 (file)
@@ -81,7 +81,7 @@ echo $OUTPUT->doctype() ?>
                         <div id="region-main-wrap">
                             <div id="region-main">
                                 <div class="region-content">
-                                    <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                    <?php echo $OUTPUT->main_content() ?>
                                 </div>
                             </div>
                         </div>
index 3225a5d..a6df3b1 100644 (file)
@@ -77,7 +77,7 @@ echo $OUTPUT->doctype() ?>
             <div id="page-content" class="clearfix">
                 <div id="report-main-content">
                     <div class="region-content">
-                        <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                        <?php echo $OUTPUT->main_content() ?>
                     </div>
                 </div>
                 <?php if ($hassidepost) { ?>
diff --git a/theme/binarius/version.php b/theme/binarius/version.php
new file mode 100644 (file)
index 0000000..10b54de
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage binarius
+ * @copyright  2010 Patrick Malley (http://newschoollearning.com/)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_binarius'; // Full name of the plugin (used for diagnostics)
index 41e141f..9b1f965 100644 (file)
@@ -14,7 +14,7 @@
 <!-- END OF HEADER -->
 
     <div id="content" class="clearfix">
-        <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+        <?php echo $OUTPUT->main_content() ?>
     </div>
 
 <!-- START OF FOOTER -->
index 98288f1..e12091f 100644 (file)
@@ -64,7 +64,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
index 495135c..7d63694 100644 (file)
@@ -73,7 +73,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
diff --git a/theme/boxxie/version.php b/theme/boxxie/version.php
new file mode 100644 (file)
index 0000000..f1c1bb2
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage boxxie
+ * @copyright  2010 Patrick Malley
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_boxxie'; // Full name of the plugin (used for diagnostics)
index 06d4a60..77dae8f 100644 (file)
@@ -83,7 +83,7 @@ echo $OUTPUT->doctype() ?>
                                <div id="region-main">
                                        <div class="region-content">
 
-                                       <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                       <?php echo $OUTPUT->main_content() ?>
                                                </div>
                                        </div>
                                </div>
index 813a6e9..cf460fe 100644 (file)
@@ -100,7 +100,7 @@ echo $OUTPUT->doctype() ?>
                                                                        </div>
                                                                        <?php } ?>
 
-                                       <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                       <?php echo $OUTPUT->main_content() ?>
 
                                                </div>
                                        </div>
diff --git a/theme/brick/version.php b/theme/brick/version.php
new file mode 100644 (file)
index 0000000..40cb4ab
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage brick
+ * @copyright  2010 John Stabinger (http://newschoollearning.com/)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_brick'; // Full name of the plugin (used for diagnostics)
index a5dd741..9d39e02 100644 (file)
@@ -13,7 +13,7 @@
 <!-- END OF HEADER -->
 
     <div id="content" class="clearfix">
-        <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+        <?php echo $OUTPUT->main_content() ?>
     </div>
 
 <!-- START OF FOOTER -->
index 812300c..a8b573d 100644 (file)
@@ -59,7 +59,7 @@ echo $OUTPUT->doctype() ?>
                            <div id="region-main-wrap">
                            <div id="region-main">
                                    <div class="region-content">
-                                   <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                   <?php echo $OUTPUT->main_content() ?>
                                        </div>
                                    </div>
                            </div>
index 4ffc0f6..cda6005 100644 (file)
@@ -70,7 +70,7 @@ echo $OUTPUT->doctype() ?>
                         <div id="region-main-wrap">
                             <div id="region-main">
                                 <div class="region-content">
-                                    <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                    <?php echo $OUTPUT->main_content() ?>
                                 </div>
                             </div>
                         </div>
index 7549a24..fce6e89 100644 (file)
@@ -67,7 +67,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="page-content">
                     <div id="report-main-content">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                     <?php if ($hassidepre) { ?>
diff --git a/theme/canvas/version.php b/theme/canvas/version.php
new file mode 100644 (file)
index 0000000..47f7d45
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage canvas
+ * @copyright  2010 Patrick Malley
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_canvas'; // Full name of the plugin (used for diagnostics)
index 1fc9be8..ab99794 100644 (file)
@@ -19,7 +19,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
index 35a82c3..2c0cd10 100644 (file)
@@ -109,7 +109,7 @@ if ($hasframe) { ?>
                         <div id="region-main-wrap">
                             <div id="region-main">
                                 <div class="region-content">
-                                    <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                    <?php echo $OUTPUT->main_content() ?>
                                 </div>
                             </div>
                         </div>
index 4b02095..6b62aee 100644 (file)
@@ -109,7 +109,7 @@ if ($hasframe) { ?>
                         <div id="region-main-wrap">
                             <div id="region-main">
                                 <div class="region-content">
-                                    <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                    <?php echo $OUTPUT->main_content() ?>
                                 </div>
                             </div>
                         </div>
index d403b14..1eecf35 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
@@ -26,7 +25,7 @@
 
 defined('MOODLE_INTERNAL') || die;
 
-$plugin->version  = 2011061301;  // The current module version (Date: YYYYMMDDXX)
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
 $plugin->component = 'theme_formal_white';
-$plugin->requires = 2010080300;  // Requires this Moodle version
 $plugin->maturity  = MATURITY_STABLE;
\ No newline at end of file
index a5dd741..9d39e02 100644 (file)
@@ -13,7 +13,7 @@
 <!-- END OF HEADER -->
 
     <div id="content" class="clearfix">
-        <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+        <?php echo $OUTPUT->main_content() ?>
     </div>
 
 <!-- START OF FOOTER -->
index b416319..76d88ae 100644 (file)
@@ -63,7 +63,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
index 57c57ba..7d4b519 100644 (file)
@@ -79,7 +79,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
diff --git a/theme/formfactor/version.php b/theme/formfactor/version.php
new file mode 100644 (file)
index 0000000..9004cd3
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage formfactor
+ * @copyright  2010 Patrick Malley
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_formfactor'; // Full name of the plugin (used for diagnostics)
index d403f80..4b499f3 100644 (file)
@@ -93,7 +93,7 @@ echo $OUTPUT->doctype() ?>
                                                                    <p class="tagline"><?php echo $tagline ?></p>
                                                                </div>
 
-                                           <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                           <?php echo $OUTPUT->main_content() ?>
 
                                        </div>
                                </div>
index e2ba6ef..a75c3d9 100644 (file)
@@ -106,7 +106,7 @@ echo $OUTPUT->doctype() ?>
                                                                    </div>
                                                                <?php } ?>
 
-                                   <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                   <?php echo $OUTPUT->main_content() ?>
                                        </div>
                                </div>
                            </div>
diff --git a/theme/fusion/version.php b/theme/fusion/version.php
new file mode 100644 (file)
index 0000000..5eb05ff
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage fusion
+ * @copyright  2010 Patrick Malley (http://newschoollearning.com/)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_fusion'; // Full name of the plugin (used for diagnostics)
index 350db3e..cac1765 100644 (file)
@@ -56,20 +56,30 @@ if ($rev > -1) {
     $cacheimage = false;
     if (file_exists("$candidatelocation/$image.gif")) {
         $cacheimage = "$candidatelocation/$image.gif";
+        $ext = 'gif';
     } else if (file_exists("$candidatelocation/$image.png")) {
         $cacheimage = "$candidatelocation/$image.png";
+        $ext = 'png';
     } else if (file_exists("$candidatelocation/$image.jpg")) {
         $cacheimage = "$candidatelocation/$image.jpg";
+        $ext = 'jpg';
     } else if (file_exists("$candidatelocation/$image.jpeg")) {
         $cacheimage = "$candidatelocation/$image.jpeg";
+        $ext = 'jpeg';
     } else if (file_exists("$candidatelocation/$image.ico")) {
         $cacheimage = "$candidatelocation/$image.ico";
+        $ext = 'ico';
     }
     if ($cacheimage) {
-        if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) {
+        if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
             // we do not actually need to verify the etag value because our files
             // never change in cache because we increment the rev parameter
+            $lifetime = 60*60*24*30; // 30 days
+            $mimetype = get_contenttype_from_ext($ext);
             header('HTTP/1.1 304 Not Modified');
+            header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
+            header('Cache-Control: max-age='.$lifetime);
+            header('Content-Type: '.$mimetype);
             die;
         }
         send_cached_image($cacheimage, $rev);
@@ -125,14 +135,7 @@ function send_cached_image($imagepath, $rev) {
     $pathinfo = pathinfo($imagepath);
     $imagename = $pathinfo['filename'].'.'.$pathinfo['extension'];
 
-    switch($pathinfo['extension']) {
-        case 'gif'  : $mimetype = 'image/gif'; break;
-        case 'png'  : $mimetype = 'image/png'; break;
-        case 'jpg'  : $mimetype = 'image/jpeg'; break;
-        case 'jpeg' : $mimetype = 'image/jpeg'; break;
-        case 'ico'  : $mimetype = 'image/vnd.microsoft.icon'; break;
-        default: $mimetype = 'document/unknown';
-    }
+    $mimetype = get_contenttype_from_ext($pathinfo['extension']);
 
     header('Etag: '.md5("$rev/$imagepath"));
     header('Content-Disposition: inline; filename="'.$imagename.'"');
@@ -154,14 +157,7 @@ function send_uncached_image($imagepath) {
     $pathinfo = pathinfo($imagepath);
     $imagename = $pathinfo['filename'].'.'.$pathinfo['extension'];
 
-    switch($pathinfo['extension']) {
-        case 'gif'  : $mimetype = 'image/gif'; break;
-        case 'png'  : $mimetype = 'image/png'; break;
-        case 'jpg'  : $mimetype = 'image/jpeg'; break;
-        case 'jpeg' : $mimetype = 'image/jpeg'; break;
-        case 'ico'  : $mimetype = 'image/vnd.microsoft.icon'; break;
-        default: $mimetype = 'document/unknown';
-    }
+    $mimetype = get_contenttype_from_ext($pathinfo['extension']);
 
     header('Content-Disposition: inline; filename="'.$imagename.'"');
     header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
@@ -178,4 +174,19 @@ function send_uncached_image($imagepath) {
 function image_not_found() {
     header('HTTP/1.0 404 not found');
     die('Image was not found, sorry.');
-}
\ No newline at end of file
+}
+
+function get_contenttype_from_ext($ext) {
+    switch ($ext) {
+        case 'gif':
+            return 'image/gif';
+        case 'png':
+            return 'image/png';
+        case 'jpg':
+        case 'jpeg':
+            return 'image/jpeg';
+        case 'ico':
+            return 'image/vnd.microsoft.icon';
+    }
+    return 'document/unknown';
+}
index 5b29b57..9b359a1 100644 (file)
@@ -49,10 +49,14 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
 $candidate = "$CFG->dataroot/cache/theme/$themename/javascript_$type.js";
 
 if ($rev > -1 and file_exists($candidate)) {
-    if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) {
+    if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
         // we do not actually need to verify the etag value because our files
         // never change in cache because we increment the rev parameter
+        $lifetime = 60*60*24*30; // 30 days
         header('HTTP/1.1 304 Not Modified');
+        header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
+        header('Cache-Control: max-age='.$lifetime);
+        header('Content-Type: application/javascript; charset=utf-8');
         die;
     }
     send_cached_js($candidate, $rev);
@@ -88,12 +92,13 @@ if ($rev > -1) {
 // parameters to get the best performance.
 
 function send_cached_js($jspath) {
-    $lifetime = 60*60*24*20;
+    $lifetime = 60*60*24*30; // 30 days
 
     header('Content-Disposition: inline; filename="javascript.php"');
     header('Last-Modified: '. gmdate('D, d M Y H:i:s', filemtime($jspath)) .' GMT');
     header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
     header('Pragma: ');
+    header('Cache-Control: max-age='.$lifetime);
     header('Accept-Ranges: none');
     header('Content-Type: application/javascript; charset=utf-8');
     if (!min_enable_zlib_compression()) {
index 5506126..b2b81ce 100644 (file)
@@ -72,7 +72,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
index b6d3957..c0f4daa 100644 (file)
@@ -71,7 +71,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
index 7f70c21..11baaf0 100644 (file)
@@ -68,7 +68,7 @@ echo $OUTPUT->doctype() ?>
     <div id="page-content">
         <div id="report-main-content">
             <div class="region-content">
-                <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                <?php echo $OUTPUT->main_content() ?>
             </div>
         </div>
         <?php if ($hassidepre) { ?>
diff --git a/theme/leatherbound/version.php b/theme/leatherbound/version.php
new file mode 100644 (file)
index 0000000..e88bc5a
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage leatherbound
+ * @copyright  2010 Patrick Malley
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_leatherbound'; // Full name of the plugin (used for diagnostics)
index c4825c5..53e94c8 100644 (file)
@@ -12,7 +12,7 @@
 <!-- END OF HEADER -->
 
     <div id="content" class="clearfix">
-        <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+        <?php echo $OUTPUT->main_content() ?>
     </div>
 
 <!-- START OF FOOTER -->
index bb8879d..f197cc4 100644 (file)
@@ -119,7 +119,7 @@ echo $OUTPUT->doctype() ?>
                                                <div id="region-main">
                                                        <div class="region-content">
 
-                                               <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                               <?php echo $OUTPUT->main_content() ?>
                                                        </div>
                                                </div>
                                                </div>
index 462d566..5fc452d 100644 (file)
@@ -120,7 +120,7 @@ echo $OUTPUT->doctype() ?>
                                                <div id="region-main">
                                                        <div class="region-content">
 
-                                               <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                               <?php echo $OUTPUT->main_content() ?>
                                                        </div>
                                                </div>
                                                </div>
diff --git a/theme/magazine/version.php b/theme/magazine/version.php
new file mode 100644 (file)
index 0000000..4a453f6
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage magazine
+ * @copyright  2010 John Stabinger (http://newschoollearning.com/)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_magazine'; // Full name of the plugin (used for diagnostics)
index f57e7d5..a917809 100644 (file)
@@ -95,7 +95,7 @@ echo $OUTPUT->doctype() ?>
                                                                    <p class="tagline"><?php echo $tagline ?></p>
                                                                </div>
 
-                                           <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                           <?php echo $OUTPUT->main_content() ?>
 
                                        </div>
                                </div>
index cae203a..7ea0d47 100644 (file)
@@ -107,7 +107,7 @@ echo $OUTPUT->doctype() ?>
                                                                    </div>
                                                                <?php } ?>
 
-                                   <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                   <?php echo $OUTPUT->main_content() ?>
                                        </div>
                                </div>
                            </div>
diff --git a/theme/nimble/version.php b/theme/nimble/version.php
new file mode 100644 (file)
index 0000000..fbb29a0
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage nimble
+ * @copyright  2010 Patrick Malley (http://newschoollearning.com/)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_nimble'; // Full name of the plugin (used for diagnostics)
index 9da35f2..a53c48a 100644 (file)
@@ -71,7 +71,7 @@ echo $OUTPUT->doctype() ?>
                    <div id="region-main-wrap">
                            <div id="region-main">
                            <div class="region-content">
-                                   <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                   <?php echo $OUTPUT->main_content() ?>
                                </div>
                        </div>
                        </div>
index 3f2013f..988a177 100644 (file)
@@ -72,7 +72,7 @@ echo $OUTPUT->doctype() ?>
                        <div id="region-main-wrap">
                        <div id="region-main">
                                <div class="region-content">
-                               <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                               <?php echo $OUTPUT->main_content() ?>
                                </div>
                        </div>
                        </div>
diff --git a/theme/nonzero/version.php b/theme/nonzero/version.php
new file mode 100644 (file)
index 0000000..d414272
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage nonzero
+ * @copyright  2010 Dietmar Wagner
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_nonzero'; // Full name of the plugin (used for diagnostics)
index 6adb5eb..cc6d726 100644 (file)
@@ -80,7 +80,7 @@ echo $OUTPUT->doctype() ?>
 
 
 
-                                   <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                   <?php echo $OUTPUT->main_content() ?>
                                </div>
                        </div>
                        </div>
index 1a78ca3..9e32977 100644 (file)
@@ -93,7 +93,7 @@ echo $OUTPUT->doctype() ?>
 
 
 
-                                   <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                   <?php echo $OUTPUT->main_content() ?>
                                </div>
                        </div>
                        </div>
diff --git a/theme/overlay/version.php b/theme/overlay/version.php
new file mode 100644 (file)
index 0000000..54e8bef
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage overlay
+ * @copyright  2008 NodeThirtyThree (http://nodethirtythree.com/)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_overlay'; // Full name of the plugin (used for diagnostics)
index a5dd741..9d39e02 100644 (file)
@@ -13,7 +13,7 @@
 <!-- END OF HEADER -->
 
     <div id="content" class="clearfix">
-        <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+        <?php echo $OUTPUT->main_content() ?>
     </div>
 
 <!-- START OF FOOTER -->
index fc54123..3c21eaa 100644 (file)
@@ -66,7 +66,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
index 11f205f..3c454f3 100644 (file)
@@ -52,7 +52,7 @@ echo $OUTPUT->doctype() ?>
                <?php } ?>
 
     </div>
-    
+
        <?php if ($hascustommenu) { ?>
        <div id="custommenu"><?php echo $custommenu; ?></div>
        <?php } ?>
@@ -76,7 +76,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
diff --git a/theme/serenity/version.php b/theme/serenity/version.php
new file mode 100644 (file)
index 0000000..c7c54c2
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage serenity
+ * @copyright  2010 Patrick Malley (http://newschoollearning.com/)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_serenity'; // Full name of the plugin (used for diagnostics)
index 7d2e3a7..f09862d 100644 (file)
@@ -85,7 +85,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
index d26b6fe..066e7c8 100644 (file)
@@ -96,7 +96,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
index 9c8427f..0744183 100644 (file)
@@ -90,7 +90,7 @@ echo $OUTPUT->doctype() ?>
                 <div id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </div>
diff --git a/theme/sky_high/version.php b/theme/sky_high/version.php
new file mode 100644 (file)
index 0000000..515dee9
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage sky_high
+ * @copyright  2010 John Stabinger (http://newschoollearning.com/)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_sky_high'; // Full name of the plugin (used for diagnostics)
index d17190e..47a457f 100644 (file)
@@ -117,7 +117,7 @@ echo $OUTPUT->doctype() ?>
                     <div id="region-main-wrap">
                         <div id="region-main">
                             <div class="region-content">
-                                <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                                <?php echo $OUTPUT->main_content() ?>
                             </div>
                         </div>
                     </div>
index ff92748..06d8c3c 100644 (file)
@@ -110,7 +110,7 @@ echo $OUTPUT->doctype() ?>
         <div id="page-content" class="clearfix">
             <div id="report-main-content">
                 <div class="region-content">
-                    <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                    <?php echo $OUTPUT->main_content() ?>
                 </div>
             </div>
             <?php if ($hassidepre) { ?>
diff --git a/theme/splash/version.php b/theme/splash/version.php
new file mode 100644 (file)
index 0000000..d7ea61d
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage splash
+ * @copyright  2010 Caroline Kennedy of Synergy Learning
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_splash'; // Full name of the plugin (used for diagnostics)
diff --git a/theme/standard/version.php b/theme/standard/version.php
new file mode 100644 (file)
index 0000000..8bd67ec
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage standard
+ * @copyright  2011 Petr Skoda  {@link http://skodak.org}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_standard'; // Full name of the plugin (used for diagnostics)
index a5dd741..9d39e02 100644 (file)
@@ -13,7 +13,7 @@
 <!-- END OF HEADER -->
 
     <div id="content" class="clearfix">
-        <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+        <?php echo $OUTPUT->main_content() ?>
     </div>
 
 <!-- START OF FOOTER -->
index 857f900..670b1f0 100644 (file)
@@ -58,7 +58,7 @@ echo $OUTPUT->doctype() ?>
                 <td id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </td>
index bac2689..d0df495 100644 (file)
@@ -71,7 +71,7 @@ echo $OUTPUT->doctype() ?>
                 <td id="region-main-wrap">
                     <div id="region-main">
                         <div class="region-content">
-                            <?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
+                            <?php echo $OUTPUT->main_content() ?>
                         </div>
                     </div>
                 </td>
diff --git a/theme/standardold/version.php b/theme/standardold/version.php
new file mode 100644 (file)
index 0000000..5da18d2
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Theme version info
+ *
+ * @package    theme
+ * @subpackage standardold
+ * @copyright  2011 Petr Skoda  {@link http://skodak.org}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version   = 2011082400; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires  = 2011081700; // Requires this Moodle version
+$plugin->component = 'theme_standardold'; // Full name of the plugin (used for diagnostics)
index 67420df..ce6ada0 100644 (file)
@@ -53,10 +53,14 @@ if ($type === 'ie') {
 $candidatesheet = "$CFG->dataroot/cache/theme/$themename/css/$type.css";
 
 if (file_exists($candidatesheet)) {
-    if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) {
+    if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
         // we do not actually need to verify the etag value because our files
         // never change in cache because we increment the rev parameter
+        $lifetime = 60*60*24*30; // 30 days
         header('HTTP/1.1 304 Not Modified');
+        header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
+        header('Cache-Control: max-age='.$lifetime);
+        header('Content-Type: text/css; charset=utf-8');
         die;
     }
     send_cached_css($candidatesheet, $rev);
@@ -116,7 +120,7 @@ function store_css(theme_config $theme, $csspath, $cssfiles) {
 }
 
 function send_ie_css($themename, $rev) {
-    $lifetime = 60*60*24*3;
+    $lifetime = 60*60*24*30; // 30 days
 
     $css = <<<EOF
 /** Unfortunately IE6/7 does not support more than 4096 selectors in one CSS file, which means we have to use some ugly hacks :-( **/
@@ -131,6 +135,7 @@ EOF;
     header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
     header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
     header('Pragma: ');
+    header('Cache-Control: max-age='.$lifetime);
     header('Accept-Ranges: none');
     header('Content-Type: text/css; charset=utf-8');
     header('Content-Length: '.strlen($css));
@@ -140,12 +145,13 @@ EOF;
 }
 
 function send_cached_css($csspath, $rev) {
-    $lifetime = 60*60*24*20;
+    $lifetime = 60*60*24*30; // 30 days
 
     header('Content-Disposition: inline; filename="styles.php"');
     header('Last-Modified: '. gmdate('D, d M Y H:i:s', filemtime($csspath)) .' GMT');
     header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
     header('Pragma: ');
+    header('Cache-Control: max-age='.$lifetime);
     header('Accept-Ranges: none');
     header('Content-Type: text/css; charset=utf-8');
     if (!min_enable_zlib_compression()) {
index 85c63b0..8d46a1d 100644 (file)
@@ -45,6 +45,18 @@ if (substr($parts, -3) === '.js') {
     combo_not_found();
 }
 
+// if they are requesting a revision that's not -1, and they have supplied an
+// If-Modified-Since header, we can send back a 304 Not Modified since the
+// content never changes (the rev number is increased any time the content changes)
+if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+    $lifetime = 60*60*24*30; // 30 days
+    header('HTTP/1.1 304 Not Modified');
+    header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
+    header('Cache-Control: max-age='.$lifetime);
+    header('Content-Type: '.$mimetype);
+    die;
+}
+
 $parts = explode('&', $parts);
 $cache = true;
 
@@ -124,13 +136,13 @@ if ($cache) {
  * @param string $mimetype
  */
 function combo_send_cached($content, $mimetype) {
-    $lifetime = 60*60*24*300; // 300 days === forever
+    $lifetime = 60*60*24*30; // 30 days
 
     header('Content-Disposition: inline; filename="combo"');
     header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
     header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
     header('Pragma: ');
-    header('Cache-Control: max-age=315360000');
+    header('Cache-Control: max-age='.$lifetime);
     header('Accept-Ranges: none');
     header('Content-Type: '.$mimetype);
     if (!min_enable_zlib_compression()) {
index 06cae6b..5a0d0a8 100644 (file)
@@ -27,9 +27,9 @@ require_once("../config.php");
 require_once($CFG->dirroot .'/notes/lib.php');
 
 $id    = required_param('id', PARAM_INT);              // course id
-$users = optional_param('userid', array(), PARAM_INT); // array of user id
-$contents = optional_param('contents', array(), PARAM_RAW); // array of user notes
-$states = optional_param('states', array(), PARAM_ALPHA); // array of notes states
+$users = optional_param_array('userid', array(), PARAM_INT); // array of user id
+$contents = optional_param_array('contents', array(), PARAM_RAW); // array of user notes
+$states = optional_param_array('states', array(), PARAM_ALPHA); // array of notes states
 
 $PAGE->set_url('/user/addnote.php', array('id'=>$id));
 
index 6d53875..90f1b3d 100644 (file)
@@ -27,7 +27,7 @@ require_once("../config.php");
 require_once($CFG->dirroot .'/notes/lib.php');
 
 $id    = required_param('id', PARAM_INT);              // course id
-$users = optional_param('userid', array(), PARAM_INT); // array of user id
+$users = optional_param_array('userid', array(), PARAM_INT); // array of user id
 $content = optional_param('content', '', PARAM_RAW); // note content
 $state = optional_param('state', '', PARAM_ALPHA); // note publish state
 
index f45686b..4ac03b0 100644 (file)
@@ -353,7 +353,7 @@ abstract class user_selector_base {
      */
     protected function load_selected_users() {
         // See if we got anything.
-        $userids = optional_param($this->name, array(), PARAM_INTEGER);
+        $userids = optional_param_array($this->name, array(), PARAM_INTEGER);
         if (empty($userids)) {
             return array();
         }
index f211fd4..242000e 100644 (file)
@@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
 
 
 
-$version  = 2011081700.00;              // YYYYMMDD      = weekly release date of this DEV branch
+$version  = 2011081700.03;              // YYYYMMDD      = weekly release date of this DEV branch
                                         //         RR    = release increments - 00 in DEV branches
                                         //           .XX = incremental changes
 
index 684a541..234bafd 100644 (file)
@@ -765,6 +765,9 @@ abstract class webservice_zend_server extends webservice_server {
         //log the web service request
         add_to_log(SITEID, 'webservice', '', '' , $this->zend_class." ".getremoteaddr() , 0, $this->userid);
 
+        //send headers
+        $this->send_headers();
+
         // execute and return response, this sends some headers too
         $response = $this->zend_server->handle();
 
@@ -772,7 +775,6 @@ abstract class webservice_zend_server extends webservice_server {
         $this->session_cleanup();
 
         //finally send the result
-        $this->send_headers();
         echo $response;
         die;
     }