Merge branch 'MDL-22351' of git://github.com/lazydaisy/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 11 Nov 2011 01:31:21 +0000 (02:31 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 11 Nov 2011 01:31:21 +0000 (02:31 +0100)
Conflicts:
theme/anomaly/style/general.css

Merged with some changes done with the introduction of
the new report plugins (MDL-29030)

338 files changed:
admin/enrol.php
admin/mnet/tabs.php
admin/qbehaviours.php
admin/qtypes.php
admin/renderer.php
admin/report/configlog/settings.php [deleted file]
admin/report/courseoverview/db/access.php [deleted file]
admin/report/courseoverview/index.php [deleted file]
admin/report/courseoverview/reportsgraph.php [deleted file]
admin/report/courseoverview/settings.php [deleted file]
admin/report/courseoverview/version.php [deleted file]
admin/report/log/settings.php [deleted file]
admin/report/questioninstances/db/access.php [deleted file]
admin/report/questioninstances/settings.php [deleted file]
admin/report/questioninstances/version.php [deleted file]
admin/report/security/db/access.php [deleted file]
admin/report/security/settings.php [deleted file]
admin/report/security/version.php [deleted file]
admin/report/stats/settings.php [deleted file]
admin/reports.php [new file with mode: 0644]
admin/settings/plugins.php
auth/mnet/auth.php
auth/upgrade.txt
backup/converter/moodle1/handlerlib.php
backup/moodle2/backup_plan_builder.class.php
backup/moodle2/backup_report_plugin.class.php [new file with mode: 0644]
backup/moodle2/backup_stepslib.php
backup/moodle2/restore_plan_builder.class.php
backup/moodle2/restore_report_plugin.class.php [new file with mode: 0644]
backup/moodle2/restore_stepslib.php
backup/restore.php
backup/util/ui/renderer.php
backup/util/ui/restore_ui.class.php
backup/util/ui/restore_ui_stage.class.php
backup/util/ui/yui/confirmcancel/confirmcancel.js
blocks/completionstatus/block_completionstatus.php
blocks/completionstatus/details.php
blocks/completionstatus/version.php
blocks/html/block_html.php
blocks/mnet_hosts/block_mnet_hosts.php
blocks/upgrade.txt
calendar/export.php
calendar/export_execute.php
calendar/lib.php
calendar/renderer.php
calendar/view.php
calendar/yui/eventmanager/eventmanager.js
course/lib.php
course/report/completion/db/access.php [deleted file]
course/report/completion/lang/en/coursereport_completion.php [deleted file]
course/report/completion/lib.php [deleted file]
course/report/completion/mod.php [deleted file]
course/report/completion/version.php [deleted file]
course/report/log/db/access.php [deleted file]
course/report/log/index.php [deleted file]
course/report/log/indexlive.php [deleted file]
course/report/log/live.php [deleted file]
course/report/log/mod.php [deleted file]
course/report/log/version.php [deleted file]
course/report/outline/db/access.php [deleted file]
course/report/outline/index.php [deleted file]
course/report/outline/lib.php [deleted file]
course/report/outline/mod.php [deleted file]
course/report/outline/version.php [deleted file]
course/report/participation/db/access.php [deleted file]
course/report/participation/index.php [deleted file]
course/report/participation/mod.php [deleted file]
course/report/participation/version.php [deleted file]
course/report/progress/db/access.php [deleted file]
course/report/progress/mod.php [deleted file]
course/report/progress/version.php [deleted file]
course/report/stats/index.php [deleted file]
course/report/stats/lib.php [deleted file]
course/report/stats/mod.php [deleted file]
course/report/stats/version.php [deleted file]
course/user.php
enrol/externallib.php
enrol/guest/addinstance.php
enrol/guest/lib.php
enrol/guest/locallib.php
enrol/guest/settings.php
enrol/guest/version.php
enrol/instances.php
enrol/manual/edit.php
enrol/paypal/edit.php
enrol/self/edit.php
enrol/upgrade.txt
lang/en/admin.php
lang/en/backup.php
lang/en/calendar.php
lang/en/mnet.php
lang/en/moodle.php
lang/en/pagetype.php
lang/en/plugin.php
lib/accesslib.php
lib/blocklib.php
lib/completion/completion_criteria_unenrol.php
lib/enrollib.php
lib/filestorage/file_types.mm
lib/form/form.js
lib/minify/lib/Minify/CSS/Compressor.php
lib/minify/readme_moodle.txt
lib/modinfolib.php
lib/moodlelib.php
lib/navigationlib.php
lib/outputrenderers.php
lib/pluginlib.php
lib/questionlib.php
lib/statslib.php
lib/upgrade.txt [new file with mode: 0644]
lib/webdavlib.php
login/token.php
mod/assignment/lib.php
mod/assignment/type/upload/assignment.class.php
mod/data/preset.php
mod/forum/db/access.php
mod/forum/lang/en/forum.php
mod/forum/lib.php
mod/forum/version.php
mod/lesson/lib.php
mod/lesson/pagetypes/truefalse.php
mod/quiz/locallib.php
mod/quiz/renderer.php
mod/scorm/aicc.php
mod/scorm/datamodels/aicclib.php
mod/scorm/db/install.xml
mod/scorm/db/upgrade.php
mod/scorm/lang/en/scorm.php
mod/scorm/lib.php
mod/scorm/loadSCO.php
mod/scorm/locallib.php
mod/scorm/mod_form.php
mod/scorm/module.js
mod/scorm/player.php
mod/scorm/report/interactions/lang/en/scormreport_interactions.php [new file with mode: 0644]
mod/scorm/report/interactions/report.php [new file with mode: 0644]
mod/scorm/report/interactions/responsessettings_form.php [new file with mode: 0644]
mod/scorm/report/interactions/version.php [new file with mode: 0644]
mod/scorm/report/reportlib.php
mod/scorm/settings.php
mod/scorm/version.php
mod/scorm/view.php
mod/upgrade.txt
mod/workshop/db/upgrade.php
mod/workshop/db/upgradelib.php
mod/workshop/version.php
question/behaviour/adaptive/version.php [moved from course/report/outline/lang/en/coursereport_outline.php with 62% similarity]
question/behaviour/adaptivenopenalty/behaviour.php
question/behaviour/adaptivenopenalty/version.php [new file with mode: 0644]
question/behaviour/behaviourbase.php
question/behaviour/deferredcbm/behaviour.php
question/behaviour/deferredcbm/version.php [new file with mode: 0644]
question/behaviour/deferredfeedback/version.php [new file with mode: 0644]
question/behaviour/immediatecbm/behaviour.php
question/behaviour/immediatecbm/version.php [new file with mode: 0644]
question/behaviour/immediatefeedback/version.php [new file with mode: 0644]
question/behaviour/informationitem/version.php [new file with mode: 0644]
question/behaviour/interactive/version.php [new file with mode: 0644]
question/behaviour/interactivecountback/behaviour.php
question/behaviour/interactivecountback/version.php [new file with mode: 0644]
question/behaviour/manualgraded/version.php [new file with mode: 0644]
question/behaviour/missing/version.php [new file with mode: 0644]
question/behaviour/upgrade.txt [new file with mode: 0644]
question/editlib.php
question/engine/lib.php
question/export_form.php
question/format/aiken/lang/en/qformat_aiken.php
question/format/aiken/version.php [new file with mode: 0644]
question/format/blackboard/format.php
question/format/blackboard/lang/en/qformat_blackboard.php
question/format/blackboard/version.php [new file with mode: 0644]
question/format/blackboard_six/lang/en/qformat_blackboard_six.php
question/format/blackboard_six/version.php [new file with mode: 0644]
question/format/examview/lang/en/qformat_examview.php
question/format/examview/version.php [new file with mode: 0644]
question/format/gift/lang/en/qformat_gift.php
question/format/gift/version.php [new file with mode: 0644]
question/format/learnwise/lang/en/qformat_learnwise.php
question/format/learnwise/version.php [new file with mode: 0644]
question/format/missingword/lang/en/qformat_missingword.php
question/format/missingword/version.php [new file with mode: 0644]
question/format/multianswer/lang/en/qformat_multianswer.php
question/format/multianswer/version.php [new file with mode: 0644]
question/format/upgrade.txt [new file with mode: 0644]
question/format/webct/lang/en/qformat_webct.php
question/format/webct/version.php [new file with mode: 0644]
question/format/xhtml/lang/en/qformat_xhtml.php
question/format/xhtml/version.php [new file with mode: 0644]
question/format/xml/format.php
question/format/xml/lang/en/qformat_xml.php
question/format/xml/simpletest/testxmlformat.php
question/format/xml/version.php [new file with mode: 0644]
question/import_form.php
question/preview.php
question/type/calculated/backup/moodle1/lib.php
question/type/calculated/lang/en/qtype_calculated.php
question/type/calculated/questiontype.php
question/type/calculated/version.php
question/type/calculatedmulti/lang/en/qtype_calculatedmulti.php
question/type/calculatedmulti/questiontype.php
question/type/calculatedmulti/version.php
question/type/calculatedsimple/lang/en/qtype_calculatedsimple.php
question/type/calculatedsimple/version.php
question/type/description/lang/en/qtype_description.php
question/type/description/version.php
question/type/essay/lang/en/qtype_essay.php
question/type/essay/version.php
question/type/match/lang/en/qtype_match.php
question/type/match/version.php
question/type/missingtype/lang/en/qtype_missingtype.php
question/type/missingtype/version.php
question/type/multianswer/lang/en/qtype_multianswer.php
question/type/multianswer/questiontype.php
question/type/multianswer/version.php
question/type/multichoice/lang/en/qtype_multichoice.php
question/type/multichoice/version.php
question/type/numerical/backup/moodle1/lib.php
question/type/numerical/db/install.xml
question/type/numerical/db/upgrade.php
question/type/numerical/lang/en/qtype_numerical.php
question/type/numerical/version.php
question/type/questiontypebase.php
question/type/random/lang/en/qtype_random.php
question/type/random/version.php
question/type/shortanswer/lang/en/qtype_shortanswer.php
question/type/shortanswer/version.php
question/type/truefalse/lang/en/qtype_truefalse.php
question/type/truefalse/version.php
question/type/upgrade.txt [new file with mode: 0755]
report/backups/index.php [moved from admin/report/backups/index.php with 98% similarity]
report/backups/lang/en/report_backups.php [new file with mode: 0644]
report/backups/settings.php [moved from admin/report/backups/settings.php with 87% similarity]
report/backups/version.php [new file with mode: 0644]
report/completion/db/access.php [new file with mode: 0644]
report/completion/db/install.php [new file with mode: 0644]
report/completion/index.php [moved from course/report/completion/index.php with 95% similarity]
report/completion/lang/en/report_completion.php [new file with mode: 0644]
report/completion/lib.php [new file with mode: 0644]
report/completion/textrotate.js [moved from course/report/completion/textrotate.js with 100% similarity]
report/completion/user.php [new file with mode: 0644]
report/completion/version.php [new file with mode: 0644]
report/configlog/index.php [moved from admin/report/configlog/index.php with 81% similarity]
report/configlog/lang/en/report_configlog.php [moved from admin/report/configlog/lang/en/report_configlog.php with 90% similarity]
report/configlog/settings.php [new file with mode: 0644]
report/configlog/version.php [new file with mode: 0644]
report/courseoverview/db/access.php [new file with mode: 0644]
report/courseoverview/index.php [new file with mode: 0644]
report/courseoverview/lang/en/report_courseoverview.php [moved from admin/report/courseoverview/lang/en/report_courseoverview.php with 71% similarity]
report/courseoverview/reportsgraph.php [new file with mode: 0644]
report/courseoverview/settings.php [new file with mode: 0644]
report/courseoverview/version.php [new file with mode: 0644]
report/log/db/access.php [new file with mode: 0644]
report/log/db/install.php [new file with mode: 0644]
report/log/graph.php [moved from course/report/log/graph.php with 71% similarity]
report/log/index.php [new file with mode: 0644]
report/log/lang/en/report_log.php [moved from course/report/log/lang/en/coursereport_log.php with 68% similarity]
report/log/lib.php [new file with mode: 0644]
report/log/locallib.php [moved from course/report/log/lib.php with 85% similarity]
report/log/settings.php [new file with mode: 0644]
report/log/styles.css [new file with mode: 0644]
report/log/user.php [new file with mode: 0644]
report/log/version.php [new file with mode: 0644]
report/loglive/db/access.php [new file with mode: 0644]
report/loglive/index.php [new file with mode: 0644]
report/loglive/lang/en/report_loglive.php [new file with mode: 0644]
report/loglive/lib.php [new file with mode: 0644]
report/loglive/settings.php [new file with mode: 0644]
report/loglive/styles.css [new file with mode: 0644]
report/loglive/version.php [new file with mode: 0644]
report/outline/db/access.php [new file with mode: 0644]
report/outline/db/install.php [new file with mode: 0644]
report/outline/index.php [new file with mode: 0644]
report/outline/lang/en/report_outline.php [new file with mode: 0644]
report/outline/lib.php [new file with mode: 0644]
report/outline/locallib.php [new file with mode: 0644]
report/outline/styles.css [new file with mode: 0644]
report/outline/user.php [new file with mode: 0644]
report/outline/version.php [new file with mode: 0644]
report/participation/db/access.php [new file with mode: 0644]
report/participation/db/install.php [new file with mode: 0644]
report/participation/index.php [new file with mode: 0644]
report/participation/lang/en/report_participation.php [moved from course/report/participation/lang/en/coursereport_participation.php with 69% similarity]
report/participation/lib.php [moved from course/report/participation/lib.php with 54% similarity]
report/participation/module.js [moved from course/report/participation/module.js with 93% similarity]
report/participation/styles.css [new file with mode: 0644]
report/participation/version.php [new file with mode: 0644]
report/progress/db/access.php [new file with mode: 0644]
report/progress/db/install.php [new file with mode: 0644]
report/progress/index.php [moved from course/report/progress/index.php with 82% similarity]
report/progress/lang/en/report_progress.php [moved from course/report/progress/lang/en/coursereport_progress.php with 68% similarity]
report/progress/lib.php [moved from course/report/progress/lib.php with 59% similarity]
report/progress/styles.css [new file with mode: 0644]
report/progress/textrotate.js [moved from course/report/progress/textrotate.js with 100% similarity]
report/progress/version.php [new file with mode: 0644]
report/questioninstances/db/access.php [new file with mode: 0644]
report/questioninstances/index.php [moved from admin/report/questioninstances/index.php with 85% similarity]
report/questioninstances/lang/en/report_questioninstances.php [moved from admin/report/questioninstances/lang/en/report_questioninstances.php with 83% similarity]
report/questioninstances/settings.php [new file with mode: 0644]
report/questioninstances/version.php [new file with mode: 0644]
report/security/db/access.php [new file with mode: 0644]
report/security/index.php [moved from admin/report/security/index.php with 67% similarity]
report/security/lang/en/report_security.php [moved from admin/report/security/lang/en/report_security.php with 98% similarity]
report/security/locallib.php [moved from admin/report/security/lib.php with 95% similarity]
report/security/settings.php [new file with mode: 0644]
report/security/version.php [new file with mode: 0644]
report/stats/db/access.php [moved from course/report/stats/db/access.php with 95% similarity]
report/stats/db/install.php [new file with mode: 0644]
report/stats/graph.php [moved from course/report/stats/graph.php with 78% similarity]
report/stats/index.php [new file with mode: 0644]
report/stats/lang/en/report_stats.php [moved from course/report/stats/lang/en/coursereport_stats.php with 64% similarity]
report/stats/lib.php [new file with mode: 0644]
report/stats/locallib.php [moved from course/report/stats/report.php with 70% similarity]
report/stats/settings.php [new file with mode: 0644]
report/stats/styles.css [new file with mode: 0644]
report/stats/user.php [new file with mode: 0644]
report/stats/version.php [new file with mode: 0644]
report/upgrade.txt [new file with mode: 0644]
repository/webdav/lib.php
theme/anomaly/style/general.css
theme/base/style/admin.css
theme/base/style/core.css
theme/base/style/course.css
theme/canvas/style/admin.css
theme/canvas/style/blocks.css
theme/canvas/style/core.css
theme/canvas/style/course.css
theme/canvas/style/editor.css
theme/canvas/style/mods.css
theme/canvas/style/pagelayout.css
theme/canvas/style/popups.css
theme/canvas/style/tables.css
theme/canvas/style/tabs.css
theme/canvas/style/text.css
theme/formal_white/style/course.css
theme/standard/style/admin.css
theme/standard/style/course.css
theme/standard/style/css3.css
theme/upgrade.txt

index efb4dc3..2d53db9 100644 (file)
@@ -41,10 +41,13 @@ $all     = enrol_get_plugins(false);
 
 $return = new moodle_url('/admin/settings.php', array('section'=>'manageenrols'));
 
+$syscontext = context_system::instance();
+
 switch ($action) {
     case 'disable':
         unset($enabled[$enrol]);
         set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
+        $syscontext->mark_dirty(); // resets all enrol caches
         break;
 
     case 'enable':
@@ -54,6 +57,7 @@ switch ($action) {
         $enabled = array_keys($enabled);
         $enabled[] = $enrol;
         set_config('enrol_plugins_enabled', implode(',', $enabled));
+        $syscontext->mark_dirty(); // resets all enrol caches
         break;
 
     case 'up':
@@ -106,6 +110,7 @@ switch ($action) {
 
         } else {  // Delete everything!!
             uninstall_plugin('enrol', $enrol);
+            $syscontext->mark_dirty(); // resets all enrol caches
 
             $a->plugin = $strplugin;
             $a->directory = "$CFG->dirroot/enrol/$enrol";
index c7c50a9..efc0118 100644 (file)
@@ -38,7 +38,7 @@ $strmnetlog        = get_string('mnetlog', 'mnet');
 $strmnetedithost   = get_string('reviewhostdetails', 'mnet');
 
 $logurl = $CFG->wwwroot.
-          '/course/report/log/index.php?chooselog=1&amp;showusers=1&amp;showcourses=1&amp;host_course='.$mnet_peer->id.
+          '/report/log/index.php?chooselog=1&amp;showusers=1&amp;showcourses=1&amp;host_course='.$mnet_peer->id.
           '%2F1&amp;user='.'0'.
           '&amp;date=0'.
           '&amp;modid=&amp;modaction=0&amp;logformat=showashtml';
index db76b95..5c6524b 100644 (file)
@@ -28,6 +28,7 @@
 require_once(dirname(__FILE__) . '/../config.php');
 require_once($CFG->libdir . '/questionlib.php');
 require_once($CFG->libdir . '/adminlib.php');
+require_once($CFG->libdir . '/pluginlib.php');
 require_once($CFG->libdir . '/tablelib.php');
 
 // Check permissions.
@@ -39,6 +40,7 @@ admin_externalpage_setup('manageqbehaviours');
 $thispageurl = new moodle_url('/admin/qbehaviours.php');
 
 $behaviours = get_plugin_list('qbehaviour');
+$pluginmanager = plugin_manager::instance();
 
 // Get some data we will need - question counts and which types are needed.
 $counts = $DB->get_records_sql_menu("
@@ -50,15 +52,11 @@ foreach ($behaviours as $behaviour => $notused) {
     if (!array_key_exists($behaviour, $counts)) {
         $counts[$behaviour] = 0;
     }
-    $needed[$behaviour] = $counts[$behaviour] > 0;
+    $needed[$behaviour] = ($counts[$behaviour] > 0) &&
+            $pluginmanager->other_plugins_that_require('qbehaviour_' . $behaviour);
     $archetypal[$behaviour] = question_engine::is_behaviour_archetypal($behaviour);
 }
 
-foreach ($behaviours as $behaviour => $notused) {
-    foreach (question_engine::get_behaviour_required_behaviours($behaviour) as $reqbehaviour) {
-        $needed[$reqbehaviour] = true;
-    }
-}
 foreach ($counts as $behaviour => $count) {
     if (!array_key_exists($behaviour, $behaviours)) {
         $counts['missingtype'] += $count;
@@ -238,13 +236,14 @@ foreach ($sortedbehaviours as $behaviour => $behaviourname) {
     }
 
     // Other question types required by this one.
-    $requiredbehaviours = question_engine::get_behaviour_required_behaviours($behaviour);
-    if (!empty($requiredbehaviours)) {
-        $strrequiredbehaviours = array();
-        foreach ($requiredbehaviours as $required) {
-            $strrequiredbehaviours[] = $sortedbehaviours[$required];
+    $plugin = $pluginmanager->get_plugin_info('qbehaviour_' . $behaviour);
+    $required = $plugin->get_other_required_plugins();
+    if (!empty($required)) {
+        $strrequired = array();
+        foreach ($required as $component => $notused) {
+            $strrequired[] = $pluginmanager->plugin_name($component);
         }
-        $row[] = implode(', ', $strrequiredbehaviours);
+        $row[] = implode(', ', $strrequired);
     } else {
         $row[] = '';
     }
index 05e7c75..88c84ed 100644 (file)
@@ -28,6 +28,7 @@
 require_once(dirname(__FILE__) . '/../config.php');
 require_once($CFG->libdir . '/questionlib.php');
 require_once($CFG->libdir . '/adminlib.php');
+require_once($CFG->libdir . '/pluginlib.php');
 require_once($CFG->libdir . '/tablelib.php');
 
 // Check permissions.
@@ -40,6 +41,7 @@ admin_externalpage_setup('manageqtypes');
 $thispageurl = new moodle_url('/admin/qtypes.php');
 
 $qtypes = question_bank::get_all_qtypes();
+$pluginmanager = plugin_manager::instance();
 
 // Get some data we will need - question counts and which types are needed.
 $counts = $DB->get_records_sql("
@@ -52,15 +54,11 @@ foreach ($qtypes as $qtypename => $qtype) {
         $counts[$qtypename]->numquestions = 0;
         $counts[$qtypename]->numhidden = 0;
     }
-    $needed[$qtypename] = $counts[$qtypename]->numquestions > 0;
+    $needed[$qtypename] = $counts[$qtypename]->numquestions > 0 &&
+            $pluginmanager->other_plugins_that_require($qtype->plugin_name());
     $counts[$qtypename]->numquestions -= $counts[$qtypename]->numhidden;
 }
 $needed['missingtype'] = true; // The system needs the missing question type.
-foreach ($qtypes as $qtypename => $qtype) {
-    foreach ($qtype->requires_qtypes() as $reqtype) {
-        $needed[$reqtype] = true;
-    }
-}
 foreach ($counts as $qtypename => $count) {
     if (!isset($qtypes[$qtypename])) {
         $counts['missingtype']->numquestions += $count->numquestions - $count->numhidden;
@@ -237,11 +235,12 @@ foreach ($sortedqtypes as $qtypename => $localname) {
     }
 
     // Other question types required by this one.
-    $requiredtypes = $qtype->requires_qtypes();
+    $plugin = $pluginmanager->get_plugin_info($qtype->plugin_name());
+    $requiredtypes = $plugin->get_other_required_plugins();
     $strtypes = array();
     if (!empty($requiredtypes)) {
-        foreach ($requiredtypes as $required) {
-            $strtypes[] = $qtypes[$required]->local_name();
+        foreach ($requiredtypes as $required => $notused) {
+            $strtypes[] = $pluginmanager->plugin_name($required);
         }
         $row[] = implode(', ', $strtypes);
     } else {
index be5780b..8c56d26 100644 (file)
@@ -725,8 +725,12 @@ class core_admin_renderer extends plugin_renderer_base {
                 }
 
                 $uninstallurl = $plugin->get_uninstall_url();
+                $requriedby = $pluginman->other_plugins_that_require($plugin->component);
                 if (is_null($uninstallurl)) {
                     $uninstall = new html_table_cell('');
+                } else if ($requriedby) {
+                    $uninstall = new html_table_cell(get_string('requiredby', 'core_plugin', implode(', ', $requriedby)));
+                    $uninstall->attributes['class'] = 'requiredby';
                 } else {
                     $uninstall = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'));
                     $uninstall = new html_table_cell($uninstall);
diff --git a/admin/report/configlog/settings.php b/admin/report/configlog/settings.php
deleted file mode 100644 (file)
index 21fe2f8..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-defined('MOODLE_INTERNAL') || die;
-
-$ADMIN->add('reports', new admin_externalpage('reportconfiglog', get_string('configlog', 'report_configlog'), "$CFG->wwwroot/$CFG->admin/report/configlog/index.php"));
diff --git a/admin/report/courseoverview/db/access.php b/admin/report/courseoverview/db/access.php
deleted file mode 100644 (file)
index 7cbd1ba..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$capabilities = array(
-
-    'report/courseoverview:view' => array(
-        'riskbitmask' => RISK_PERSONAL,
-        'captype' => 'read',
-        'contextlevel' => CONTEXT_SYSTEM,
-        'archetypes' => array(
-            'teacher' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-            'manager' => CAP_ALLOW
-        ),
-
-        'clonepermissionsfrom' => 'moodle/site:viewreports',
-    )
-);
diff --git a/admin/report/courseoverview/index.php b/admin/report/courseoverview/index.php
deleted file mode 100644 (file)
index 1eb2167..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-
-    require_once('../../../config.php');
-    require_once($CFG->dirroot.'/lib/statslib.php');
-    require_once($CFG->libdir.'/adminlib.php');
-
-    $report     = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT);
-    $time       = optional_param('time', 0, PARAM_INT);
-    $numcourses = optional_param('numcourses', 20, PARAM_INT);
-
-    if (empty($CFG->enablestats)) {
-        if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
-            redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
-        } else {
-            print_error('statsdisable');
-        }
-    }
-
-    admin_externalpage_setup('reportcourseoverview');
-    echo $OUTPUT->header();
-
-    $course = get_site();
-    stats_check_uptodate($course->id);
-
-    $strreports = get_string('reports');
-    $strcourseoverview = get_string('courseoverview');
-
-    $reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);
-
-    $earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_daily}');
-    $earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_weekly}');
-    $earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_monthly}');
-
-    if (empty($earliestday)) $earliestday = time();
-    if (empty($earliestweek)) $earliestweek = time();
-    if (empty($earliestmonth)) $earliestmonth = time();
-
-    $now = stats_get_base_daily();
-    $lastweekend = stats_get_base_weekly();
-    $lastmonthend = stats_get_base_monthly();
-
-    $timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
-
-    if (empty($timeoptions)) {
-        print_error('nostatstodisplay', 'error', $CFG->wwwroot.'/course/view.php?id='.$course->id);
-    }
-
-    echo '<form action="index.php" method="post">'."\n";
-    echo '<div>';
-
-    $table = new html_table();
-    $table->width = '*';
-    $table->align = array('left','left','left','left','left','left');
-
-    $reporttypemenu = html_writer::select($reportoptions,'report',$report, false);
-    $timeoptionsmenu = html_writer::select($timeoptions,'time',$time, false);
-
-    $table->data[] = array(get_string('statsreporttype'),$reporttypemenu,
-                           get_string('statstimeperiod'),$timeoptionsmenu,
-                           '<input type="text" name="numcourses" size="3" maxlength="2" value="'.$numcourses.'" />',
-                           '<input type="submit" value="'.get_string('view').'" />') ;
-
-    echo html_writer::table($table);
-    echo '</div>';
-    echo '</form>';
-
-    echo $OUTPUT->heading($reportoptions[$report]);
-
-
-    if (!empty($report) && !empty($time)) {
-        $param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
-        if (!empty($param->sql)) {
-            $sql = $param->sql;
-        } else {
-            $sql = "SELECT courseid,".$param->fields."
-                      FROM {".'stats_'.$param->table."}
-                     WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0
-                  GROUP BY courseid
-                           $param->extras
-                  ORDER BY $param->orderby";
-        }
-
-        $courses = $DB->get_records_sql($sql, $param->params, 0, $numcourses);
-
-        if (empty($courses)) {
-            echo $OUTPUT->notification(get_string('statsnodata'));
-            echo '</td></tr></table>';
-
-        } else {
-            if (empty($CFG->gdversion)) {
-                echo '<div class="graph">(' . get_string("gdneed") .')</div>';
-            } else {
-                echo '<div class="graph"><img alt="'.get_string('courseoverviewgraph').'" src="'.$CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/reportsgraph.php?time='.$time.'&report='.$report.'&numcourses='.$numcourses.'" /></div>';
-            }
-
-            $table = new html_table();
-            $table->align = array('left','center','center','center');
-            $table->head = array(get_string('course'),$param->line1);
-            if (!empty($param->line2)) {
-                $table->head[] = $param->line2;
-            }
-            if (!empty($param->line3)) {
-                $table->head[] = $param->line3;
-            }
-
-            foreach  ($courses as $c) {
-                $a = array();
-                $a[] = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$c->courseid.'">'.$DB->get_field('course', 'shortname', array('id'=>$c->courseid)).'</a>';
-
-                $a[] = $c->line1;
-                if (isset($c->line2)) {
-                    $a[] = $c->line2;
-                }
-                if (isset($c->line3)) {
-                    $a[] = round($c->line3,2);
-                }
-                $table->data[] = $a;
-            }
-            echo html_writer::table($table);
-        }
-    }
-    echo $OUTPUT->footer();
diff --git a/admin/report/courseoverview/reportsgraph.php b/admin/report/courseoverview/reportsgraph.php
deleted file mode 100644 (file)
index 45ea7d8..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-    require_once('../../../config.php');
-    require_once($CFG->dirroot.'/lib/statslib.php');
-    require_once($CFG->dirroot.'/lib/graphlib.php');
-
-    $report     = required_param('report', PARAM_INT);
-    $time       = required_param('time', PARAM_INT);
-    $numcourses = required_param('numcourses', PARAM_INT);
-
-    require_login();
-
-    require_capability('report/courseoverview:view', get_context_instance(CONTEXT_SYSTEM));
-
-    stats_check_uptodate();
-
-    $param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
-
-    if (!empty($param->sql)) {
-        $sql = $param->sql;
-    } else {
-        $sql = "SELECT courseid, $param->fields
-                  FROM {".'stats_'.$param->table."}
-                 WHERE timeend >= $param->timeafter AND stattype = 'activity' AND roleid = 0
-              GROUP BY courseid
-                       $param->extras
-              ORDER BY $param->orderby";
-    }
-
-    $courses = $DB->get_records_sql($sql, $param->params, 0, $numcourses);
-
-    if (empty($courses)) {
-        $PAGE->set_url('/admin/report/courseoverview/index.php');
-        print_error('statsnodata', 'error', $PAGE->url->out());
-    }
-
-
-    $graph = new graph(750,400);
-
-    $graph->parameter['legend'] = 'outside-right';
-    $graph->parameter['legend_size'] = 10;
-    $graph->parameter['x_axis_angle'] = 90;
-    $graph->parameter['title'] = false; // moodle will do a nicer job.
-    $graph->y_tick_labels = null;
-    $graph->offset_relation = null;
-    if ($report != STATS_REPORT_ACTIVE_COURSES) {
-        $graph->parameter['y_decimal_left'] = 2;
-    }
-
-    foreach ($courses as $c) {
-        $graph->x_data[] = $DB->get_field('course', 'shortname', array('id'=>$c->courseid));
-        $graph->y_data['bar1'][] = $c->{$param->graphline};
-    }
-    $graph->y_order = array('bar1');
-    $graph->y_format['bar1'] = array('colour' => 'blue','bar' => 'fill','legend' => $param->{$param->graphline});
-
-    $graph->draw_stack();
diff --git a/admin/report/courseoverview/settings.php b/admin/report/courseoverview/settings.php
deleted file mode 100644 (file)
index c6a0589..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-defined('MOODLE_INTERNAL') || die;
-
-$ADMIN->add('reports', new admin_externalpage('reportcourseoverview', get_string('pluginname', 'report_courseoverview'), "$CFG->wwwroot/$CFG->admin/report/courseoverview/index.php",'report/courseoverview:view'));
diff --git a/admin/report/courseoverview/version.php b/admin/report/courseoverview/version.php
deleted file mode 100644 (file)
index a2be4bb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?PHP
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$plugin->version  = 2010090501;
-$plugin->requires = 2010090501;
diff --git a/admin/report/log/settings.php b/admin/report/log/settings.php
deleted file mode 100644 (file)
index ecaae3b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-
-defined('MOODLE_INTERNAL') || die;
-
-// just a link to course report
-$ADMIN->add('reports', new admin_externalpage('reportlog', get_string('log', 'admin'), "$CFG->wwwroot/course/report/log/index.php?id=".SITEID, 'coursereport/log:view'));
-$ADMIN->add('reports', new admin_externalpage('reportloglive', get_string('loglive', 'coursereport_log'), "$CFG->wwwroot/course/report/log/indexlive.php?id=".SITEID, 'coursereport/log:viewlive'));
diff --git a/admin/report/questioninstances/db/access.php b/admin/report/questioninstances/db/access.php
deleted file mode 100644 (file)
index c13dd6a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$capabilities = array(
-
-    'report/questioninstances:view' => array(
-        'captype' => 'read',
-        'contextlevel' => CONTEXT_SYSTEM,
-        'archetypes' => array(
-            'manager' => CAP_ALLOW
-        ),
-
-        'clonepermissionsfrom' => 'moodle/site:config',
-    )
-);
diff --git a/admin/report/questioninstances/settings.php b/admin/report/questioninstances/settings.php
deleted file mode 100644 (file)
index 263d39d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-defined('MOODLE_INTERNAL') || die;
-
-$ADMIN->add('reports', new admin_externalpage('reportquestioninstances', get_string('pluginname', 'report_questioninstances'), "$CFG->wwwroot/$CFG->admin/report/questioninstances/index.php", 'report/questioninstances:view'));
diff --git a/admin/report/questioninstances/version.php b/admin/report/questioninstances/version.php
deleted file mode 100644 (file)
index a2be4bb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?PHP
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$plugin->version  = 2010090501;
-$plugin->requires = 2010090501;
diff --git a/admin/report/security/db/access.php b/admin/report/security/db/access.php
deleted file mode 100644 (file)
index 293a66f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$capabilities = array(
-
-    'report/security:view' => array(
-        'riskbitmask' => RISK_CONFIG,
-        'captype' => 'read',
-        'contextlevel' => CONTEXT_SYSTEM,
-        'archetypes' => array(
-            'manager' => CAP_ALLOW
-        ),
-    )
-);
diff --git a/admin/report/security/settings.php b/admin/report/security/settings.php
deleted file mode 100644 (file)
index 8ea8b23..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-defined('MOODLE_INTERNAL') || die;
-
-$ADMIN->add('reports', new admin_externalpage('reportsecurity', get_string('pluginname', 'report_security'), "$CFG->wwwroot/$CFG->admin/report/security/index.php",'report/security:view'));
diff --git a/admin/report/security/version.php b/admin/report/security/version.php
deleted file mode 100644 (file)
index a2be4bb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?PHP
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$plugin->version  = 2010090501;
-$plugin->requires = 2010090501;
diff --git a/admin/report/stats/settings.php b/admin/report/stats/settings.php
deleted file mode 100644 (file)
index 0283339..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-defined('MOODLE_INTERNAL') || die;
-
-// just a link to course report
-$ADMIN->add('reports', new admin_externalpage('reportstats', get_string('stats', 'admin'), "$CFG->wwwroot/course/report/stats/index.php", 'coursereport/stats:view'));
diff --git a/admin/reports.php b/admin/reports.php
new file mode 100644 (file)
index 0000000..e03c928
--- /dev/null
@@ -0,0 +1,134 @@
+<?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/>.
+
+/**
+ * Provides an overview of installed reports
+ *
+ * Displays the list of found reports, their version (if found) and
+ * a link to delete the report.
+ *
+ * The code is based on admin/localplugins.php by David Mudrak.
+ *
+ * @package   admin
+ * @copyright 2011 Petr Skoda {@link http://skodak.org}
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once(dirname(__FILE__) . '/../config.php');
+require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->libdir.'/tablelib.php');
+
+admin_externalpage_setup('managereports');
+
+$delete  = optional_param('delete', '', PARAM_PLUGIN);
+$confirm = optional_param('confirm', '', PARAM_BOOL);
+
+/// If data submitted, then process and store.
+
+if (!empty($delete) and confirm_sesskey()) {
+    echo $OUTPUT->header();
+    echo $OUTPUT->heading(get_string('reports'));
+
+    if (!$confirm) {
+        if (get_string_manager()->string_exists('pluginname', 'report_' . $delete)) {
+            $strpluginname = get_string('pluginname', 'report_' . $delete);
+        } else {
+            $strpluginname = $delete;
+        }
+        echo $OUTPUT->confirm(get_string('reportsdeleteconfirm', 'admin', $strpluginname),
+                                new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
+                                $PAGE->url);
+        echo $OUTPUT->footer();
+        die();
+
+    } else {
+        uninstall_plugin('report', $delete);
+        $a = new stdclass();
+        $a->name = $delete;
+        $pluginlocation = get_plugin_types();
+        $a->directory = $pluginlocation['report'] . '/' . $delete;
+        echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
+        echo $OUTPUT->continue_button($PAGE->url);
+        echo $OUTPUT->footer();
+        die();
+    }
+}
+
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('reports'));
+
+/// Print the table of all installed report plugins
+
+$table = new flexible_table('reportplugins_administration_table');
+$table->define_columns(array('name', 'version', 'delete'));
+$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete')));
+$table->define_baseurl($PAGE->url);
+$table->set_attribute('id', 'reportplugins');
+$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
+$table->setup();
+
+$plugins = array();
+foreach (get_plugin_list('report') as $plugin => $plugindir) {
+    if (get_string_manager()->string_exists('pluginname', 'report_' . $plugin)) {
+        $strpluginname = get_string('pluginname', 'report_' . $plugin);
+    } else {
+        $strpluginname = $plugin;
+    }
+    $plugins[$plugin] = $strpluginname;
+}
+collatorlib::asort($plugins);
+
+$like = $DB->sql_like('plugin', '?', true, true, false, '|');
+$params = array('report|_%');
+$installed = $DB->get_records_select('config_plugins', "$like AND name = 'version'", $params);
+$versions = array();
+foreach ($installed as $config) {
+    $name = preg_replace('/^report_/', '', $config->plugin);
+    $versions[$name] = $config->value;
+    if (!isset($plugins[$name])) {
+        $plugins[$name] = $name;
+    }
+}
+
+foreach ($plugins as $plugin => $name) {
+    $delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
+    $delete = html_writer::link($delete, get_string('delete'));
+
+    if (!isset($versions[$plugin])) {
+        if (file_exists("$CFG->dirroot/report/$plugin/version.php")) {
+            // not installed yet
+            $version = '?';
+        } else {
+            // no version info available
+            $version = '-';
+        }
+    } else {
+        $version = $versions[$plugin];
+        if (file_exists("$CFG->dirroot/report/$plugin")) {
+            $version = $versions[$plugin];
+        } else {
+            // somebody removed plugin without uninstall
+            $name = '<span class="notifyproblem">'.$name.' ('.get_string('missingfromdisk').')</span>';
+            $version = $versions[$plugin];
+        }
+    }
+
+    $table->add_data(array($name, $version, $delete));
+}
+
+$table->print_html();
+
+echo $OUTPUT->footer();
index e05d3e4..15bac9d 100644 (file)
@@ -454,24 +454,27 @@ if ($hassiteconfig) {
             $ADMIN->add('coursereports', $page);
         }
     }
+    unset($pages);
 }
 
 // Now add reports
-foreach (get_plugin_list('report') as $plugin => $plugindir) {
+$pages = array();
+foreach (get_plugin_list('report') as $report => $plugindir) {
     $settings_path = "$plugindir/settings.php";
     if (file_exists($settings_path)) {
+        $settings = new admin_settingpage('report' . $report,
+                get_string('pluginname', 'report_' . $report), 'moodle/site:config');
         include($settings_path);
-        continue;
-    }
-
-    $index_path = "$plugindir/index.php";
-    if (!file_exists($index_path)) {
-        continue;
+        if ($settings) {
+            $pages[] = $settings;
+        }
     }
-    // old style 3rd party plugin without settings.php
-    $www_path = "$CFG->wwwroot/$CFG->admin/report/$plugin/index.php";
-    $reportname = get_string($plugin, 'report_' . $plugin);
-    $ADMIN->add('reports', new admin_externalpage('report'.$plugin, $reportname, $www_path, 'moodle/site:viewreports'));
+}
+$ADMIN->add('modules', new admin_category('reportplugins', get_string('reports')));
+$ADMIN->add('reportplugins', new admin_externalpage('managereports', get_string('reportsmanage', 'admin'),
+                                                    $CFG->wwwroot . '/' . $CFG->admin . '/reports.php'));
+foreach ($pages as $page) {
+    $ADMIN->add('reportplugins', $page);
 }
 
 // Now add various admin tools
index b4e733c..f6938f3 100644 (file)
@@ -132,6 +132,10 @@ class auth_plugin_mnet extends auth_plugin_base {
         global $CFG, $USER, $DB;
         require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
 
+        if (session_is_loggedinas()) {
+            print_error('notpermittedtojumpas', 'mnet');
+        }
+
         // check remote login permissions
         if (! has_capability('moodle/site:mnetlogintoremote', get_system_context())
                 or is_mnet_remote_user($USER)
index d3e1761..328307e 100644 (file)
@@ -1,6 +1,7 @@
 This files describes API changes in /auth/* - plugins,
 information provided here is intended especially for developers.
 
+
 === 2.2 ===
 
 required changes in code:
index 849a4af..a6b7788 100644 (file)
@@ -1779,7 +1779,7 @@ abstract class moodle1_qtype_handler extends moodle1_plugin_handler {
      * @param int $oldquestiontextformat
      * @return array
      */
-    protected function get_default_numerical_options($oldquestiontextformat) {
+    protected function get_default_numerical_options($oldquestiontextformat, $units) {
         global $CFG;
 
         // replay the upgrade step 2009100100 - new table
@@ -1800,6 +1800,11 @@ abstract class moodle1_qtype_handler extends moodle1_plugin_handler {
             $options['instructionsformat'] = $oldquestiontextformat;
         }
 
+        // Set a good default, depending on whether there are any units defined.
+        if (empty($units)) {
+            $options['showunits'] = 3;
+        }
+
         return $options;
     }
 
index 3f66183..0189164 100644 (file)
@@ -36,6 +36,7 @@ require_once($CFG->dirroot . '/backup/moodle2/backup_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_theme_plugin.class.php');
+require_once($CFG->dirroot . '/backup/moodle2/backup_report_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_coursereport_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_plagiarism_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_subplugin.class.php');
diff --git a/backup/moodle2/backup_report_plugin.class.php b/backup/moodle2/backup_report_plugin.class.php
new file mode 100644 (file)
index 0000000..fbc2174
--- /dev/null
@@ -0,0 +1,34 @@
+<?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/>.
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Base class for report backup plugins.
+ *
+ * NOTE: When you back up a course, it potentially may run backup for all
+ * reports. In order to control whether a particular report gets
+ * backed up, a report should make use of the second and third
+ * parameters in get_plugin_element().
+ *
+ * @package    moodlecore
+ * @subpackage backup-moodle2
+ * @copyright  2011 Petr Skoda
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+abstract class backup_report_plugin extends backup_plugin {
+    // Use default parent behaviour
+}
index 987bb9f..dd71337 100644 (file)
@@ -418,6 +418,10 @@ class backup_course_structure_step extends backup_structure_step {
         // save course data (in case of user theme, legacy theme, etc)
         $this->add_plugin_structure('theme', $course, true);
 
+        // attach general report plugin structure to $course element; multiple
+        // reports can save course data if required
+        $this->add_plugin_structure('report', $course, true);
+
         // attach course report plugin structure to $course element; multiple
         // course reports can save course data if required
         $this->add_plugin_structure('coursereport', $course, true);
@@ -809,7 +813,7 @@ class backup_gradebook_structure_step extends backup_structure_step {
         //grade_categories
         $grade_categories = new backup_nested_element('grade_categories');
         $grade_category   = new backup_nested_element('grade_category', array('id'), array(
-                //'courseid', 
+                //'courseid',
                 'parent', 'depth', 'path', 'fullname', 'aggregation', 'keephigh',
                 'dropload', 'aggregateonlygraded', 'aggregateoutcomes', 'aggregatesubcats',
                 'timecreated', 'timemodified', 'hidden'));
index 5232b5b..5c6364f 100644 (file)
@@ -35,12 +35,14 @@ require_once($CFG->dirroot . '/backup/moodle2/restore_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/restore_qtype_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/restore_format_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/restore_theme_plugin.class.php');
+require_once($CFG->dirroot . '/backup/moodle2/restore_report_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/restore_coursereport_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/restore_plagiarism_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_theme_plugin.class.php');
+require_once($CFG->dirroot . '/backup/moodle2/backup_report_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_coursereport_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/backup_plagiarism_plugin.class.php');
 require_once($CFG->dirroot . '/backup/moodle2/restore_subplugin.class.php');
diff --git a/backup/moodle2/restore_report_plugin.class.php b/backup/moodle2/restore_report_plugin.class.php
new file mode 100644 (file)
index 0000000..7db2151
--- /dev/null
@@ -0,0 +1,29 @@
+<?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/>.
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Restore for plugin report.
+ *
+ * @package    moodlecore
+ * @subpackage backup-moodle2
+ * @copyright  2011 Petr Skoda
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+abstract class restore_report_plugin extends restore_plugin {
+    // Use default parent behaviour
+}
index 7141640..ee388a1 100644 (file)
@@ -1080,6 +1080,9 @@ class restore_course_structure_step extends restore_structure_step {
         // Apply for 'theme' plugins optional paths at course level
         $this->add_plugin_structure('theme', $course);
 
+        // Apply for 'report' plugins optional paths at course level
+        $this->add_plugin_structure('report', $course);
+
         // Apply for 'course report' plugins optional paths at course level
         $this->add_plugin_structure('coursereport', $course);
 
index ed72ab8..04ed41a 100644 (file)
@@ -42,7 +42,12 @@ if ($stage & restore_ui::STAGE_CONFIRM + restore_ui::STAGE_DESTINATION) {
 $outcome = $restore->process();
 if (!$restore->is_independent()) {
     if ($restore->get_stage() == restore_ui::STAGE_PROCESS && !$restore->requires_substage()) {
-        $restore->execute();
+        try {
+            $restore->execute();
+        } catch(Exception $e) {
+            $restore->cleanup();
+            throw new moodle_exception((string)$e);
+        }
     } else {
         $restore->save_controller();
     }
index d62a243..4ca5414 100644 (file)
@@ -211,7 +211,7 @@ class core_backup_renderer extends plugin_renderer_base {
      * @return string
      */
     public function course_selector(moodle_url $nextstageurl, $wholecourse = true, restore_category_search $categories = null, restore_course_search $courses=null, $currentcourse = null) {
-        global $CFG;
+        global $CFG, $PAGE;
         require_once($CFG->dirroot.'/course/lib.php');
 
         $nextstageurl->param('sesskey', sesskey());
@@ -232,9 +232,15 @@ class core_backup_renderer extends plugin_renderer_base {
             $html .= $this->output->heading(get_string('restoretonewcourse', 'backup'), 2, array('class'=>'header'));
             $html .= $this->backup_detail_input(get_string('restoretonewcourse', 'backup'), 'radio', 'target', backup::TARGET_NEW_COURSE, array('checked'=>'checked'));
             $html .= $this->backup_detail_pair(get_string('selectacategory', 'backup'), $this->render($categories));
-            $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue'))));
+            $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue'), 'class'=>'newcoursecontinue')));
             $html .= html_writer::end_tag('div');
             $html .= html_writer::end_tag('form');
+            $config = new stdClass;
+            $config->title = get_string('confirmnewcoursecontinue', 'backup');
+            $config->question = get_string('confirmnewcoursecontinuequestion', 'backup');
+            $config->yesLabel = get_string('continue');
+            $config->noLabel = get_string('cancel');
+            $PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.watch_newcoursecontinue_buttons', array($config));
         }
 
         if ($wholecourse && !empty($currentcourse)) {
index 220cc23..b932508 100644 (file)
@@ -146,6 +146,39 @@ class restore_ui extends base_ui {
         $this->stage = new restore_ui_stage_complete($this, $this->stage->get_params(), $this->controller->get_results());
         return true;
     }
+
+    /**
+     * Delete course which is created by restore process
+     */
+    public function cleanup() {
+        $courseid = $this->controller->get_courseid();
+        if ($this->is_temporary_course_created($courseid)) {
+            delete_course($courseid, false);
+        }
+    }
+
+    /**
+     * Checks if the course is not restored fully and current controller has created it.
+     * @param int $courseid id of the course which needs to be checked
+     * @return bool
+     */
+    protected function is_temporary_course_created($courseid) {
+        global $DB;
+        //Check if current controller instance has created new course.
+        if ($this->controller->get_target() == backup::TARGET_NEW_COURSE) {
+            $results = $DB->record_exists_sql("SELECT bc.itemid
+                                               FROM {backup_controllers} bc, {course} c
+                                               WHERE bc.operation = 'restore'
+                                                 AND bc.type = 'course'
+                                                 AND bc.itemid = c.id
+                                                 AND bc.itemid = ?",
+                                               array($courseid)
+                                             );
+            return $results;
+        }
+        return false;
+    }
+
     /**
      * Returns true if enforce_dependencies changed any settings
      * @return bool
@@ -191,15 +224,12 @@ class restore_ui extends base_ui {
     /**
      * Cancels the current restore and redirects the user back to the relevant place
      */
-    public function cancel_restore() {
-        global $PAGE;
-        // Determine the approriate URL to redirect the user to
-        if ($PAGE->context->contextlevel == CONTEXT_MODULE && $PAGE->cm !== null) {
-            $relevanturl = new moodle_url('/mod/'.$PAGE->cm->modname.'/view.php', array('id'=>$PAGE->cm->id));
-        } else {
-            $relevanturl = new moodle_url('/course/view.php', array('id'=>$PAGE->course->id));
+    public function cancel_process() {
+        //Delete temporary restore course if exists.
+        if ($this->controller->get_target() == backup::TARGET_NEW_COURSE) {
+            $this->cleanup();
         }
-        redirect($relevanturl);
+        parent::cancel_process();
     }
     /**
      * Gets an array of progress bar items that can be displayed through the restore renderer.
index cd19b7d..478fe7a 100644 (file)
@@ -333,7 +333,7 @@ class restore_ui_stage_settings extends restore_ui_stage {
         $form = $this->initialise_stage_form();
 
         if ($form->is_cancelled()) {
-            $this->ui->cancel_restore();
+            $this->ui->cancel_process();
         }
 
         $data = $form->get_data();
index 267b853..05395e4 100644 (file)
@@ -27,4 +27,24 @@ M.core_backup.watch_cancel_buttons = function(config) {
     });
 }
 
+M.core_backup.watch_newcoursecontinue_buttons = function(config) {
+    Y.all('.newcoursecontinue').each(function(){
+        this._confirmationListener = this._confirmationListener || this.on('click', function(e){
+            // Prevent the default event (sumbit) from firing
+            e.preventDefault();
+            // Create the confirm box
+            var confirm = new M.core.confirm(config);
+            // If the user clicks yes
+            confirm.on('complete-yes', function(e){
+                // Detach the listener for the confirm box so it doesn't fire again.
+                this._confirmationListener.detach();
+                // Simulate the original cancel button click
+                this.simulate('click');
+            }, this);
+            // Show the confirm box
+            confirm.show();
+        }, this);
+    });
+}
+
 }, '@VERSION@', {'requires':['base','node','node-event-simulate','moodle-enrol-notification']});
\ No newline at end of file
index 9e92f25..7013b12 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
 // You should have received a copy of the GNU General Public License
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
-
 /**
  * Block for displayed logged in user's course completion status
  *
- * @package   moodlecore
- * @copyright 2009 Catalyst IT Ltd
- * @author    Aaron Barnes <aaronb@catalyst.net.nz>
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package    block
+ * @subpackage completion
+ * @copyright  2009 Catalyst IT Ltd
+ * @author     Aaron Barnes <aaronb@catalyst.net.nz>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
+
+defined('MOODLE_INTERNAL') || die();
+
+
 require_once($CFG->libdir.'/completionlib.php');
 
 /**
@@ -81,8 +84,8 @@ class block_completionstatus extends block_base {
         // Check this user is enroled
         if (!$info->is_tracked_user($USER->id)) {
             // If not enrolled, but are can view the report:
-            if (has_capability('coursereport/completion:view', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {
-                $this->content->text = '<a href="'.$CFG->wwwroot.'/course/report/completion/index.php?course='.$COURSE->id.
+            if (has_capability('report/completion:view', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {
+                $this->content->text = '<a href="'.$CFG->wwwroot.'/report/completion/index.php?course='.$COURSE->id.
                                        '">'.get_string('viewcoursereport', 'completion').'</a>';
                 return $this->content;
             }
index 7bfbde7..a1ac771 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
 // You should have received a copy of the GNU General Public License
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
-
 /**
  * Block for displayed logged in user's course completion status
  *
- * @package   moodlecore
- * @copyright 2009 Catalyst IT Ltd
- * @author    Aaron Barnes <aaronb@catalyst.net.nz>
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package    block
+ * @subpackage completion
+ * @copyright  2009 Catalyst IT Ltd
+ * @author     Aaron Barnes <aaronb@catalyst.net.nz>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
+
 require_once('../../config.php');
 require_once($CFG->libdir.'/completionlib.php');
 
@@ -62,9 +62,9 @@ if ($USER->id == $user->id) {
     $can_view = true;
 } else if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
     $can_view = true;
-} else if (has_capability('coursereport/completion:view', $coursecontext)) {
+} else if (has_capability('report/completion:view', $coursecontext)) {
     $can_view = true;
-} else if (has_capability('coursereport/completion:view', $personalcontext)) {
+} else if (has_capability('report/completion:view', $personalcontext)) {
     $can_view = true;
 }
 
@@ -165,7 +165,7 @@ echo '<th class="c1 header" scope="col">'.get_string('criteria', 'completion').'
 echo '<th class="c2 header" scope="col">'.get_string('requirement', 'block_completionstatus').'</th>';
 echo '<th class="c3 header" scope="col">'.get_string('status').'</th>';
 echo '<th class="c4 header" scope="col">'.get_string('complete').'</th>';
-echo '<th class="c5 header" scope="col">'.get_string('completiondate', 'coursereport_completion').'</th>';
+echo '<th class="c5 header" scope="col">'.get_string('completiondate', 'report_completion').'</th>';
 echo '</tr>';
 
 // Save row data
index 279b001..eece519 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
 // You should have received a copy of the GNU General Public License
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
-$plugin->version = 2009072800;
+/**
+ * Version info
+ *
+ * @package    block
+ * @subpackage completion
+ * @copyright  2009 Catalyst IT Ltd
+ * @author     Aaron Barnes <aaronb@catalyst.net.nz>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version      = 2011110300;
+$plugin->component    = 'block_completionstatus';
+$plugin->dependencies = array('report_completion' => 2011110200);
\ No newline at end of file
index bead128..f030401 100644 (file)
@@ -121,4 +121,14 @@ class block_html extends block_base {
 
         return true;
     }
+
+    /**
+     * The block should only be dockable when the title of the block is not empty
+     * and when parent allows docking.
+     *
+     * @return bool
+     */
+    public function instance_can_be_docked() {
+        return (!empty($this->config->title) && parent::instance_can_be_docked());
+    }
 }
index 1af74ac..3c6916b 100644 (file)
@@ -25,6 +25,13 @@ class block_mnet_hosts extends block_list {
             return false;
         }
 
+        if (session_is_loggedinas()) {
+            $this->content = new stdClass();
+            $this->content->footer = html_writer::tag('span',
+                get_string('notpermittedtojumpas', 'mnet'));
+            return $this->content;
+        }
+
         // according to start_jump_session,
         // remote users can't on-jump
         // so don't show this block to them
index ce7766f..a87cbf8 100644 (file)
@@ -1,6 +1,7 @@
 This files describes API changes in /blocks/* - activity modules,
 information provided here is intended especially for developers.
 
+
 === 2.0 ===
 
 required changes in code:
@@ -15,12 +16,7 @@ required changes in code:
                  move all images into new blocks/xxx/pix/ directory and use new outputlib api
                  old global $THEME is fully replaced by $OUTPUT
 * remove '_utf8' from language pack names, use new {$a} syntax in language packs
-* use 'pluginname' lang pack identifier instead of 'blockname' 
+* use 'pluginname' lang pack identifier instead of 'blockname'
 * move cron and version number into standard version.php
 * removed support for old config_global.html, use settings.php
 
-optional - no changes needed in older code:
-*
-
-
-TODO: add links to docs
\ No newline at end of file
index d43f665..5d72d2a 100644 (file)
@@ -59,6 +59,7 @@ $action = optional_param('action', '', PARAM_ALPHA);
 $day  = optional_param('cal_d', 0, PARAM_INT);
 $mon  = optional_param('cal_m', 0, PARAM_INT);
 $yr   = optional_param('cal_y', 0, PARAM_INT);
+$generateurl = optional_param('generateurl', 0, PARAM_BOOL);
 
 if ($courseid != SITEID && !empty($courseid)) {
     $course = $DB->get_record('course', array('id' => $courseid));
@@ -93,6 +94,7 @@ $calendar = new calendar_information($day, $mon, $yr);
 $calendar->prepare_for_view($course, $courses);
 
 $pagetitle = get_string('export', 'calendar');
+$now = usergetdate(time());
 
 // Print title and header
 if ($issite) {
@@ -122,8 +124,8 @@ switch($action) {
         if (isset($CFG->calendar_weekend)) {
             $weekend = intval($CFG->calendar_weekend);
         }
-        $username = $USER->username;
-        $authtoken = sha1($USER->username . $USER->password . $CFG->calendar_exportsalt);
+
+        $authtoken = sha1($USER->id . $USER->password . $CFG->calendar_exportsalt);
         // Let's populate some vars to let "common tasks" be somewhat smart...
         // If today it's weekend, give the "next week" option
         $allownextweek  = $weekend & (1 << $now['wday']);
@@ -131,9 +133,19 @@ switch($action) {
         $allownextmonth = calendar_days_in_month($now['mon'], $now['year']) - $now['mday'] < 7;
         // If today it's weekend but tomorrow it isn't, do NOT give the "this week" option
         $allowthisweek  = !(($weekend & (1 << $now['wday'])) && !($weekend & (1 << (($now['wday'] + 1) % 7))));
-        echo $renderer->basic_export_form($allowthisweek, $allownextweek, $allownextmonth, $username, $authtoken);
+        echo $renderer->basic_export_form($allowthisweek, $allownextweek, $allownextmonth, $USER->id, $authtoken);
         break;
 }
 
+if (!empty($generateurl)) {
+    $params['userid']      = optional_param('userid', 0, PARAM_INT);
+    $params['authtoken']   = optional_param('authtoken', '', PARAM_ALPHANUM);
+    $params['preset_what'] = optional_param('preset_what', 'all', PARAM_ALPHA);
+    $params['preset_time'] = optional_param('preset_time', 'weeknow', PARAM_ALPHA);
+
+    $link = new moodle_url('/calendar/export_execute.php', $params);
+    print html_writer::tag('div', get_string('calendarurl', 'calendar', $link->out()), array('class' => 'generalbox calendarurl'));
+}
+
 echo $renderer->complete_layout();
 echo $OUTPUT->footer();
index e50123e..7f195be 100644 (file)
@@ -5,21 +5,29 @@ require_once('../config.php');
 require_once($CFG->dirroot.'/calendar/lib.php');
 require_once($CFG->libdir.'/bennu/bennu.inc.php');
 
-$username = required_param('username', PARAM_TEXT);
+$userid = optional_param('userid', 0, PARAM_INT);
+$username = optional_param('username', '', PARAM_TEXT);
 $authtoken = required_param('authtoken', PARAM_ALPHANUM);
+$generateurl = optional_param('generateurl', '', PARAM_TEXT);
 
 if (empty($CFG->enablecalendarexport)) {
     die('no export');
 }
 
 //Fetch user information
-if (!$user = $DB->get_record('user', array('username' => $username), 'id,password')) {
-   //No such user
+$checkuserid = !empty($userid) && $user = $DB->get_record('user', array('id' => $userid), 'id,password');
+//allowing for fallback check of old url - MDL-27542
+$checkusername = !empty($username) && $user = $DB->get_record('user', array('username' => $username), 'id,password');
+if (!$checkuserid && !$checkusername) {
+    //No such user
     die('Invalid authentication');
 }
 
 //Check authentication token
-if ($authtoken != sha1($username . $user->password . $CFG->calendar_exportsalt)) {
+$authuserid = !empty($userid) && $authtoken == sha1($userid . $user->password . $CFG->calendar_exportsalt);
+//allowing for fallback check of old url - MDL-27542
+$authusername = !empty($username) && $authtoken == sha1($username . $user->password . $CFG->calendar_exportsalt);
+if (!$authuserid && !$authusername) {
     die('Invalid authentication');
 }
 
@@ -31,6 +39,20 @@ $now = usergetdate(time());
 $allowed_what = array('all', 'courses');
 $allowed_time = array('weeknow', 'weeknext', 'monthnow', 'monthnext', 'recentupcoming');
 
+if (!empty($generateurl)) {
+    $authtoken = sha1($user->id . $user->password . $CFG->calendar_exportsalt);
+    $params = array();
+    $params['preset_what'] = $what;
+    $params['preset_time'] = $time;
+    $params['userid'] = $userid;
+    $params['authtoken'] = $authtoken;
+    $params['generateurl'] = true;
+
+    $link = new moodle_url('/calendar/export.php', $params);
+    redirect($link->out());
+    die;
+}
+
 if(!empty($what) && !empty($time)) {
     if(in_array($what, $allowed_what) && in_array($time, $allowed_time)) {
         $courses = enrol_get_users_courses($user->id, true, 'id, visible, shortname');
index 5255a72..c60e6b6 100644 (file)
@@ -1806,7 +1806,7 @@ class calendar_event {
             $group = $DB->get_record('groups', array('id'=>$data->groupid));
             $context = get_context_instance(CONTEXT_COURSE, $group->courseid);
         } else if (isset($data->userid) && $data->userid > 0 && $data->userid == $USER->id) {
-            $context =  get_context_instance(CONTEXT_USER);
+            $context =  get_context_instance(CONTEXT_USER, $data->userid);
         } else if (isset($data->userid) && $data->userid > 0 && $data->userid != $USER->id &&
                    isset($data->instance) && $data->instance > 0) {
             $cm = get_coursemodule_from_instance($data->modulename, $data->instance, 0, false, MUST_EXIST);
index 48d1ef3..312c572 100644 (file)
@@ -34,11 +34,11 @@ class core_calendar_renderer extends plugin_renderer_base {
      * @param bool $allowthisweek
      * @param bool $allownextweek
      * @param bool $allownextmonth
-     * @param string $username
+     * @param int $userid
      * @param string $authtoken
      * @return string
      */
-    public function basic_export_form($allowthisweek, $allownextweek, $allownextmonth, $username, $authtoken) {
+    public function basic_export_form($allowthisweek, $allownextweek, $allownextmonth, $userid, $authtoken) {
 
         $output  = html_writer::tag('div', get_string('export', 'calendar'), array('class'=>'header'));
         $output .= html_writer::start_tag('fieldset');
@@ -86,10 +86,10 @@ class core_calendar_renderer extends plugin_renderer_base {
         $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'cal_d', 'value'=>''));
         $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'cal_m', 'value'=>''));
         $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'cal_y', 'value'=>''));
-        $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'username', 'value'=>$username));
+        $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'userid', 'value'=>$userid));
         $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'authtoken', 'value'=>$authtoken));
 
-        $output .= html_writer::empty_tag('input', array('type'=>'button', 'id'=>'generateurl', 'value'=>get_string('generateurlbutton', 'calendar')));
+        $output .= html_writer::empty_tag('input', array('type'=>'submit', 'name' => 'generateurl', 'id'=>'generateurl', 'value'=>get_string('generateurlbutton', 'calendar')));
         $output .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('exportbutton', 'calendar')));
 
         $output .= html_writer::end_tag('div');
@@ -102,8 +102,6 @@ class core_calendar_renderer extends plugin_renderer_base {
         $output .= html_writer::tag('div', '', array('id'=>'url', 'style'=>'overflow:scroll;width:650px;'));
         $output .= html_writer::end_tag('div');
 
-        $this->page->requires->yui_module('moodle-calendar-eventmanager', 'M.core_calendar.init_basic_export', array($allowthisweek, $allownextweek, $allownextmonth, $username, $authtoken));
-
         return $output;
     }
 
index 8f6b084..31c3ee2 100644 (file)
@@ -150,8 +150,8 @@ echo $OUTPUT->container_start('bottom');
 if (!empty($CFG->enablecalendarexport)) {
     echo $OUTPUT->single_button(new moodle_url('export.php', array('course'=>$courseid)), get_string('exportcalendar', 'calendar'));
     if (isloggedin()) {
-        $authtoken = sha1($USER->username . $USER->password . $CFG->calendar_exportsalt);
-        $link = new moodle_url('/calendar/export_execute.php', array('preset_what'=>'all', 'preset_time'=>'recentupcoming', 'username'=>$USER->username, 'authtoken'=>$authtoken));
+        $authtoken = sha1($USER->id . $USER->password . $CFG->calendar_exportsalt);
+        $link = new moodle_url('/calendar/export_execute.php', array('preset_what'=>'all', 'preset_time'=>'recentupcoming', 'userid' => $USER->id, 'authtoken'=>$authtoken));
         $icon = html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('i/ical'), 'height'=>'14', 'width'=>'36', 'alt'=>get_string('ical', 'calendar'), 'title'=>get_string('quickdownloadcalendar', 'calendar')));
         echo html_writer::tag('a', $icon, array('href'=>$link));
     }
index 7ee5704..578ba81 100644 (file)
@@ -120,26 +120,6 @@ YUI.add('moodle-calendar-eventmanager', function(Y) {
     var EVENTMANAGER = {
         add_event : function(config) {
             new EVENT(config);
-        },
-        init_basic_export : function(allowthisweek, allownextweek, allownextmonth, username, authtoken) {
-            var params = {
-                preset_what : (Y.one('#pw_course').get('checked'))?'courses':'all',
-                preset_time : 'recentupcoming',
-                username : username,
-                authtoken : authtoken
-
-            }
-            if (allowthisweek && Y.one('#pt_wknow').get('checked')) {
-                params.presettime = 'weeknow';
-            } else if (allownextweek && Y.one('#pt_wknext').get('checked')) {
-                params.presettime = 'weeknext';
-            } else if (allownextmonth && Y.one('#pt_monnext').get('checked')) {
-                params.presettime = 'monthnext';
-            } else if (Y.one('#pt_monnow').get('checked')) {
-                params.presettime = 'monthnow';
-            }
-            Y.one('#url').setContent(M.cfg.wwwroot+'/calendar/export_execute.php?'+build_querystring(params));
-            Y.one('#urlbox').setStyle('display', 'block');
         }
     }
 
index 79ccf91..8a9b0d2 100644 (file)
@@ -29,9 +29,7 @@ defined('MOODLE_INTERNAL') || die;
 require_once($CFG->libdir.'/completionlib.php');
 require_once($CFG->libdir.'/filelib.php');
 
-define('COURSE_MAX_LOG_DISPLAY', 150);          // days
 define('COURSE_MAX_LOGS_PER_PAGE', 1000);       // records
-define('COURSE_LIVELOG_REFRESH', 60);           // Seconds
 define('COURSE_MAX_RECENT_PERIOD', 172800);     // Two days, in seconds
 define('COURSE_MAX_SUMMARIES_PER_PAGE', 10);    // courses
 define('COURSE_MAX_COURSES_PER_DROPDOWN',1000); //  max courses in log dropdown before switching to optional
@@ -830,21 +828,6 @@ function print_log_ods($course, $user, $date, $order='l.time DESC', $modname,
 }
 
 
-function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
-    global $CFG, $USER;
-    if (empty($CFG->gdversion)) {
-        echo "(".get_string("gdneed").")";
-    } else {
-        // MDL-10818, do not display broken graph when user has no permission to view graph
-        if (has_capability('coursereport/log:view', get_context_instance(CONTEXT_COURSE, $course->id)) ||
-            ($course->showreports and $USER->id == $userid)) {
-            echo '<img src="'.$CFG->wwwroot.'/course/report/log/graph.php?id='.$course->id.
-                 '&amp;user='.$userid.'&amp;type='.$type.'&amp;date='.$date.'" alt="" />';
-        }
-    }
-}
-
-
 function print_overview($courses, array $remote_courses=array()) {
     global $CFG, $USER, $DB, $OUTPUT;
 
@@ -1149,6 +1132,9 @@ function get_array_of_activities($courseid) {
                                if (!empty($info->extraclasses)) {
                                    $mod[$seq]->extraclasses = $info->extraclasses;
                                }
+                               if (!empty($info->iconurl)) {
+                                   $mod[$seq]->iconurl = $info->iconurl;
+                               }
                                if (!empty($info->onclick)) {
                                    $mod[$seq]->onclick = $info->onclick;
                                }
@@ -1186,7 +1172,7 @@ function get_array_of_activities($courseid) {
                    // Minimise the database size by unsetting default options when they are
                    // 'empty'. This list corresponds to code in the cm_info constructor.
                    foreach (array('idnumber', 'groupmode', 'groupingid', 'groupmembersonly',
-                           'indent', 'completion', 'extra', 'extraclasses', 'onclick', 'content',
+                           'indent', 'completion', 'extra', 'extraclasses', 'iconurl', 'onclick', 'content',
                            'icon', 'iconcomponent', 'customdata', 'showavailability', 'availablefrom',
                            'availableuntil', 'conditionscompletion', 'conditionsgrade',
                            'completionview', 'completionexpected', 'score', 'showdescription')
diff --git a/course/report/completion/db/access.php b/course/report/completion/db/access.php
deleted file mode 100644 (file)
index ac82f58..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$capabilities = array(
-
-    'coursereport/completion:view' => array(
-        'riskbitmask' => RISK_PERSONAL,
-        'captype' => 'read',
-        'contextlevel' => CONTEXT_COURSE,
-        'archetypes' => array(
-            'teacher' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-            'manager' => CAP_ALLOW
-        ),
-
-        'clonepermissionsfrom' => 'moodle/site:viewreports',
-    )
-);
diff --git a/course/report/completion/lang/en/coursereport_completion.php b/course/report/completion/lang/en/coursereport_completion.php
deleted file mode 100644 (file)
index 808f4c8..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-$string['completion:view'] = 'View course completion report';
-$string['completiondate']='Completion date';
-$string['pluginpagetype'] = 'Course completion report';
-$string['pluginname']='Course completion';
diff --git a/course/report/completion/lib.php b/course/report/completion/lib.php
deleted file mode 100644 (file)
index 21874c6..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?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/>.
-
-/**
- * This file contains functions used by the progress report
- *
- * @since 2.0
- * @package course-report
- * @copyright 2009 Sam Hemelryk
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-require_once($CFG->libdir.'/completionlib.php');
-
-/**
- * This function extends the navigation with the report items
- *
- * @param navigation_node $navigation The navigation node to extend
- * @param stdClass $course The course to object for the report
- * @param stdClass $context The context of the course
- */
-function completion_report_extend_navigation($navigation, $course, $context) {
-    global $CFG, $OUTPUT;
-
-    if (has_capability('coursereport/completion:view', $context)) {
-        $completion = new completion_info($course);
-        if ($completion->is_enabled() && $completion->has_criteria()) {
-            $url = new moodle_url('/course/report/completion/index.php', array('course'=>$course->id));
-            $navigation->add(get_string('pluginname','coursereport_completion'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
-        }
-    }
-}
-
-/**
- * Return a list of page types
- * @param string $pagetype current page type
- * @param stdClass $parentcontext Block's parent context
- * @param stdClass $currentcontext Current context of block
- */
-function completion_page_type_list($pagetype, $parentcontext, $currentcontext) {
-    $array = array(
-        '*' => get_string('page-x', 'pagetype'),
-        'course-report-*' => get_string('page-course-report-x', 'pagetype'),
-        'course-report-completion-index' => get_string('pluginpagetype',  'coursereport_completion')
-    );
-    return $array;
-}
diff --git a/course/report/completion/mod.php b/course/report/completion/mod.php
deleted file mode 100644 (file)
index 44cca9a..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-    if (!defined('MOODLE_INTERNAL')) {
-        die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
-    }
-
-    require_once($CFG->libdir.'/completionlib.php');
-
-    if (has_capability('coursereport/completion:view', $context)) {
-        $completion = new completion_info($course);
-        if ($completion->is_enabled() && $completion->has_criteria()) {
-            echo '<p>';
-            echo '<a href="'.$CFG->wwwroot.'/course/report/completion/index.php?course='.$course->id.'">'.get_string('coursecompletion').'</a>';
-            echo '</p>';
-        }
-    }
-
diff --git a/course/report/completion/version.php b/course/report/completion/version.php
deleted file mode 100644 (file)
index a2be4bb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?PHP
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$plugin->version  = 2010090501;
-$plugin->requires = 2010090501;
diff --git a/course/report/log/db/access.php b/course/report/log/db/access.php
deleted file mode 100644 (file)
index 7a4021b..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$capabilities = array(
-
-    'coursereport/log:view' => array(
-        'riskbitmask' => RISK_PERSONAL,
-        'captype' => 'read',
-        'contextlevel' => CONTEXT_COURSE,
-        'archetypes' => array(
-            'teacher' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-            'manager' => CAP_ALLOW
-        ),
-
-        'clonepermissionsfrom' => 'moodle/site:viewreports',
-    ),
-
-    'coursereport/log:viewlive' => array(
-        'riskbitmask' => RISK_PERSONAL,
-        'captype' => 'read',
-        'contextlevel' => CONTEXT_COURSE,
-        'archetypes' => array(
-            'teacher' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-            'manager' => CAP_ALLOW
-        ),
-
-        'clonepermissionsfrom' => 'moodle/site:viewreports',
-    ),
-
-    'coursereport/log:viewtoday' => array(
-        'riskbitmask' => RISK_PERSONAL,
-        'captype' => 'read',
-        'contextlevel' => CONTEXT_COURSE,
-        'archetypes' => array(
-            'teacher' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-            'manager' => CAP_ALLOW
-        ),
-
-        'clonepermissionsfrom' => 'moodle/site:viewreports',
-    )
-);
-
-
diff --git a/course/report/log/index.php b/course/report/log/index.php
deleted file mode 100644 (file)
index 015d17d..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-<?php
-      // Displays different views of the logs.
-
-    require_once('../../../config.php');
-    require_once('../../lib.php');
-    require_once('lib.php');
-    require_once($CFG->libdir.'/adminlib.php');
-
-    $id          = optional_param('id', 0, PARAM_INT);// Course ID
-
-    $host_course = optional_param('host_course', '', PARAM_PATH);// Course ID
-
-    if (empty($host_course)) {
-        $hostid = $CFG->mnet_localhost_id;
-        if (empty($id)) {
-            $site = get_site();
-            $id = $site->id;
-        }
-    } else {
-        list($hostid, $id) = explode('/', $host_course);
-    }
-
-    $group       = optional_param('group', 0, PARAM_INT); // Group to display
-    $user        = optional_param('user', 0, PARAM_INT); // User to display
-    $date        = optional_param('date', 0, PARAM_FILE); // Date to display - number or some string
-    $modname     = optional_param('modname', '', PARAM_PLUGIN); // course_module->id
-    $modid       = optional_param('modid', 0, PARAM_FILE); // number or 'site_errors'
-    $modaction   = optional_param('modaction', '', PARAM_PATH); // an action as recorded in the logs
-    $page        = optional_param('page', '0', PARAM_INT);     // which page to show
-    $perpage     = optional_param('perpage', '100', PARAM_INT); // how many per page
-    $showcourses = optional_param('showcourses', 0, PARAM_INT); // whether to show courses if we're over our limit.
-    $showusers   = optional_param('showusers', 0, PARAM_INT); // whether to show users if we're over our limit.
-    $chooselog   = optional_param('chooselog', 0, PARAM_INT);
-    $logformat   = optional_param('logformat', 'showashtml', PARAM_ALPHA);
-
-    $params = array();
-    if ($id !== 0) $params['id'] = $id;
-    if ($host_course !== '') $params['host_course'] = $host_course;
-    if ($group !== 0) $params['group'] = $group;
-    if ($user !== 0) $params['user'] = $user;
-    if ($date !== 0) $params['date'] = $date;
-    if ($modname !== '') $params['modname'] = $modname;
-    if ($modid !== 0) $params['modid'] = $modid;
-    if ($modaction !== '') $params['modaction'] = $modaction;
-    if ($page !== '0') $params['page'] = $page;
-    if ($perpage !== '100') $params['perpage'] = $perpage;
-    if ($showcourses !== 0) $params['showcourses'] = $showcourses;
-    if ($showusers !== 0) $params['showusers'] = $showusers;
-    if ($chooselog !== 0) $params['chooselog'] = $chooselog;
-    if ($logformat !== 'showashtml') $params['logformat'] = $logformat;
-    $PAGE->set_url('/course/report/log/index.php', $params);
-    $PAGE->set_pagelayout('report');
-
-    if ($hostid == $CFG->mnet_localhost_id) {
-        if (!$course = $DB->get_record('course', array('id'=>$id))) {
-            print_error('That\'s an invalid course id'.$id);
-        }
-    } else {
-        $course_stub       = $DB->get_record('mnet_log', array('hostid'=>$hostid, 'course'=>$id), '*', true);
-        $course->id        = $id;
-        $course->shortname = $course_stub->coursename;
-        $course->fullname  = $course_stub->coursename;
-    }
-
-    require_login($course);
-
-    $context = get_context_instance(CONTEXT_COURSE, $course->id);
-
-    require_capability('coursereport/log:view', $context);
-
-    add_to_log($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->id);
-
-    $strlogs = get_string('logs');
-    $stradministration = get_string('administration');
-    $strreports = get_string('reports');
-
-    session_get_instance()->write_close();
-
-    $navlinks = array();
-
-    if (!empty($chooselog)) {
-        $userinfo = get_string('allparticipants');
-        $dateinfo = get_string('alldays');
-
-        if ($user) {
-            if (!$u = $DB->get_record('user', array('id'=>$user))) {
-                print_error('That\'s an invalid user!');
-            }
-            $userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context));
-        }
-        if ($date) {
-            $dateinfo = userdate($date, get_string('strftimedaydate'));
-        }
-
-        switch ($logformat) {
-            case 'showashtml':
-                if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
-                    admin_externalpage_setup('reportlog');
-                    echo $OUTPUT->header();
-
-                } else {
-                    $PAGE->set_title($course->shortname .': '. $strlogs);
-                    $PAGE->set_heading($course->fullname);
-                    $PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)));
-                    $PAGE->navbar->add($strlogs, new moodle_url('/course/report/log/index.php', array('id'=>$course->id)));
-                    $PAGE->navbar->add("$userinfo, $dateinfo");
-                    echo $OUTPUT->header();
-                }
-
-                echo $OUTPUT->heading(format_string($course->fullname) . ": $userinfo, $dateinfo (".usertimezone().")");
-                print_mnet_log_selector_form($hostid, $course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
-
-                if($hostid == $CFG->mnet_localhost_id) {
-                    print_log($course, $user, $date, 'l.time DESC', $page, $perpage,
-                            "index.php?id=$course->id&amp;chooselog=1&amp;user=$user&amp;date=$date&amp;modid=$modid&amp;modaction=$modaction&amp;group=$group",
-                            $modname, $modid, $modaction, $group);
-                } else {
-                    print_mnet_log($hostid, $id, $user, $date, 'l.time DESC', $page, $perpage, "", $modname, $modid, $modaction, $group);
-                }
-                break;
-            case 'downloadascsv':
-                if (!print_log_csv($course, $user, $date, 'l.time DESC', $modname,
-                        $modid, $modaction, $group)) {
-                    echo $OUTPUT->notification("No logs found!");
-                    echo $OUTPUT->footer();
-                }
-                exit;
-            case 'downloadasods':
-                if (!print_log_ods($course, $user, $date, 'l.time DESC', $modname,
-                        $modid, $modaction, $group)) {
-                    echo $OUTPUT->notification("No logs found!");
-                    echo $OUTPUT->footer();
-                }
-                exit;
-            case 'downloadasexcel':
-                if (!print_log_xls($course, $user, $date, 'l.time DESC', $modname,
-                        $modid, $modaction, $group)) {
-                    echo $OUTPUT->notification("No logs found!");
-                    echo $OUTPUT->footer();
-                }
-                exit;
-        }
-
-
-    } else {
-        if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
-            admin_externalpage_setup('reportlog');
-            echo $OUTPUT->header();
-        } else {
-            $PAGE->set_title($course->shortname .': '. $strlogs);
-            $PAGE->set_heading($course->fullname);
-            echo $OUTPUT->header();
-        }
-
-        echo $OUTPUT->heading(get_string('chooselogs') .':');
-
-        print_log_selector_form($course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
-
-        $livelogs = get_string('livelogs');
-        $url = new moodle_url('/course/report/log/live.php', array('id'=>$course->id));
-        $link = new action_link($url, $livelogs, new popup_action('click', $url, 'livelog', array('height' => 500, 'width' => 800)));
-
-        echo $OUTPUT->render($link);
-    }
-
-    echo $OUTPUT->footer();
-
-    exit;
-
diff --git a/course/report/log/indexlive.php b/course/report/log/indexlive.php
deleted file mode 100644 (file)
index 09978b9..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-      // Display link to live logs in separate window
-
-    require_once('../../../config.php');
-    require_once('../../lib.php');
-    require_once('lib.php');
-    require_once($CFG->libdir.'/adminlib.php');
-
-    $id = optional_param('id', 0, PARAM_INT);// Course ID
-
-    if (!$course = $DB->get_record('course', array('id'=>$id)) ) {
-        print_error('invalidcourseid');
-    }
-
-    require_login($course);
-    $context = get_context_instance(CONTEXT_COURSE, $course->id);
-
-    require_capability('coursereport/log:viewlive', $context);
-
-    $strlogs = get_string('logs');
-    $strreports = get_string('reports');
-
-    if ($course->id == SITEID) {
-        admin_externalpage_setup('reportloglive');
-        echo $OUTPUT->header();
-
-    } else {
-        $PAGE->set_title($course->shortname .': '. $strlogs);
-        $PAGE->set_heading($course->fullname);
-        $PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)), navigation_node::TYPE_CUSTOM);
-        $PAGE->navbar->add($strlogs);
-        echo $OUTPUT->header();
-    }
-
-    echo $OUTPUT->heading(get_string('loglive', 'coursereport_log'));
-
-    echo $OUTPUT->container_start('info');
-    $link = new moodle_url('/course/report/log/live.php?id='. $course->id);
-    echo $OUTPUT->action_link($link, get_string('livelogs'), new popup_action('click', $link, 'livelog', array('height' => 500, 'width' => 800)));
-    echo $OUTPUT->container_end();
-
-    echo $OUTPUT->footer();
-
-
diff --git a/course/report/log/live.php b/course/report/log/live.php
deleted file mode 100644 (file)
index 3062233..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-      //  Displays live view of recent logs
-
-    require_once("../../../config.php");
-    require_once("../../lib.php");
-
-    $id   = required_param('id', PARAM_INT);
-    $page = optional_param('page', 0, PARAM_INT);     // which page to show
-
-    if (! $course = $DB->get_record("course", array("id"=>$id))) {
-        print_error('invalidcourseid');
-    }
-
-    require_login($course);
-
-    $context = get_context_instance(CONTEXT_COURSE, $course->id);
-    require_capability('coursereport/log:viewlive', $context);
-
-    add_to_log($course->id, "course", "report live", "report/log/live.php?id=$course->id", $course->id);
-
-    session_get_instance()->write_close();
-
-    $strlivelogs = get_string("livelogs");
-    $strupdatesevery = get_string("updatesevery", "moodle", COURSE_LIVELOG_REFRESH);
-
-    $PAGE->set_url('/course/report/log/live.php', array('id'=>$course->id));
-    $PAGE->set_pagelayout('popup');
-    $PAGE->set_title("$strlivelogs ($strupdatesevery)");
-    $PAGE->set_periodic_refresh_delay(COURSE_LIVELOG_REFRESH);
-    $PAGE->set_heading($strlivelogs);
-    echo $OUTPUT->header();
-
-    $user=0;
-    $date=time() - 3600;
-
-    print_log($course, $user, $date, "l.time DESC", $page, 500,
-              "live.php?id=$course->id&amp;user=$user&amp;date=$date");
-
-    echo $OUTPUT->footer();
-
-    exit;
-
-
diff --git a/course/report/log/mod.php b/course/report/log/mod.php
deleted file mode 100644 (file)
index 3c278a6..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-    if (!defined('MOODLE_INTERNAL')) {
-        die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
-    }
-
-    require_once($CFG->dirroot.'/course/lib.php');
-    require_once($CFG->dirroot.'/course/report/log/lib.php');
-
-    if (has_capability('coursereport/log:view', $context)) {
-        echo $OUTPUT->heading(get_string('chooselogs') .':');
-
-        print_log_selector_form($course);
-    }
-
-    if (has_capability('coursereport/log:viewlive', $context)) {
-        echo $OUTPUT->heading(get_string('chooselivelogs') .':');
-        echo '<p>';
-        $link = new moodle_url('/course/report/log/live.php?id='. $course->id);
-        echo $OUTPUT->action_link($link, get_string('livelogs'), new popup_action('click', $link, 'livelog', array('height' => 500, 'width' => 800)));
-        echo '</p>';
-    }
-
diff --git a/course/report/log/version.php b/course/report/log/version.php
deleted file mode 100644 (file)
index 819c2f1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$plugin->version  = 2010090501;
-$plugin->requires = 2010090501;
-
-
diff --git a/course/report/outline/db/access.php b/course/report/outline/db/access.php
deleted file mode 100644 (file)
index 20cab93..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$capabilities = array(
-
-    'coursereport/outline:view' => array(
-        'riskbitmask' => RISK_PERSONAL,
-        'captype' => 'read',
-        'contextlevel' => CONTEXT_COURSE,
-        'archetypes' => array(
-            'teacher' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-            'manager' => CAP_ALLOW
-        ),
-
-        'clonepermissionsfrom' => 'moodle/site:viewreports',
-    )
-);
-
-
diff --git a/course/report/outline/index.php b/course/report/outline/index.php
deleted file mode 100644 (file)
index dc1dd10..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-<?php
-
-// Display user activity reports for a course (totals)
-
-    require_once('../../../config.php');
-    require_once($CFG->dirroot.'/course/lib.php');
-
-    $id = required_param('id',PARAM_INT);       // course id
-
-    if (!$course = $DB->get_record('course', array('id'=>$id))) {
-        print_error('invalidcourseid');
-    }
-
-    $PAGE->set_url('/course/report/outline/index.php', array('id'=>$id));
-    $PAGE->set_pagelayout('report');
-
-    require_login($course);
-    $context = get_context_instance(CONTEXT_COURSE, $course->id);
-    require_capability('coursereport/outline:view', $context);
-
-    add_to_log($course->id, 'course', 'report outline', "report/outline/index.php?id=$course->id", $course->id);
-
-    $showlastaccess = true;
-    $hiddenfields = explode(',', $CFG->hiddenuserfields);
-
-    if (array_search('lastaccess', $hiddenfields) and !has_capability('moodle/user:viewhiddendetails', $coursecontext)) {
-        $showlastaccess = false;
-    }
-
-    $stractivityreport = get_string('activityreport');
-    $stractivity       = get_string('activity');
-    $strlast           = get_string('lastaccess');
-    $strreports        = get_string('reports');
-    $strviews          = get_string('views');
-    $strrelatedblogentries = get_string('relatedblogentries', 'blog');
-
-    $PAGE->set_title($course->shortname .': '. $stractivityreport);
-    $PAGE->set_heading($course->fullname);
-    echo $OUTPUT->header();
-    echo $OUTPUT->heading(format_string($course->fullname));
-
-    if (!$logstart = $DB->get_field_sql("SELECT MIN(time) FROM {log}")) {
-        print_error('logfilenotavailable');
-    }
-
-    echo $OUTPUT->container(get_string('computedfromlogs', 'admin', userdate($logstart)), 'loginfo');
-
-    $outlinetable = new html_table();
-    $outlinetable->attributes['class'] = 'generaltable boxaligncenter';
-    $outlinetable->cellpadding = 5;
-    $outlinetable->id = 'outlinetable';
-    $outlinetable->head = array($stractivity, $strviews);
-
-    if ($CFG->useblogassociations) {
-        $outlinetable->head[] = $strrelatedblogentries;
-    }
-
-    if ($showlastaccess) {
-        $outlinetable->head[] = $strlast;
-    }
-
-    $modinfo = get_fast_modinfo($course);
-    $sections = get_all_sections($course->id);
-
-    $sql = "SELECT cm.id, COUNT('x') AS numviews, MAX(time) AS lasttime
-              FROM {course_modules} cm
-                   JOIN {modules} m ON m.id = cm.module
-                   JOIN {log} l     ON l.cmid = cm.id
-             WHERE cm.course = ? AND l.action LIKE 'view%' AND m.visible = 1
-          GROUP BY cm.id";
-    $views = $DB->get_records_sql($sql, array($course->id));
-
-    $prevsecctionnum = 0;
-    foreach ($modinfo->sections as $sectionnum=>$section) {
-        foreach ($section as $cmid) {
-            $cm = $modinfo->cms[$cmid];
-            if (!$cm->has_view()) {
-                continue;
-            }
-            if (!$cm->uservisible) {
-                continue;
-            }
-            if ($prevsecctionnum != $sectionnum) {
-                $sectionrow = new html_table_row();
-                $sectionrow->attributes['class'] = 'section';
-                $sectioncell = new html_table_cell();
-                $sectioncell->colspan = count($outlinetable->head);
-
-                $sectiontitle = get_section_name($course, $sections[$sectionnum]);
-
-                $sectioncell->text = $OUTPUT->heading($sectiontitle, 3);
-                $sectionrow->cells[] = $sectioncell;
-                $outlinetable->data[] = $sectionrow;
-
-                $prevsecctionnum = $sectionnum;
-            }
-
-            $dimmed = $cm->visible ? '' : 'class="dimmed"';
-            $modulename = get_string('modulename', $cm->modname);
-
-            $reportrow = new html_table_row();
-            $activitycell = new html_table_cell();
-            $activitycell->attributes['class'] = 'activity';
-
-            $activityicon = $OUTPUT->pix_icon('icon', $modulename, $cm->modname, array('class'=>'icon'));
-
-            $attributes = array();
-            if (!$cm->visible) {
-                $attributes['class'] = 'dimmed';
-            }
-
-            $activitycell->text = $activityicon . html_writer::link("$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id", format_string($cm->name), $attributes);;
-
-            $reportrow->cells[] = $activitycell;
-
-            $numviewscell = new html_table_cell();
-            $numviewscell->attributes['class'] = 'numviews';
-
-            if (!empty($views[$cm->id]->numviews)) {
-                $numviewscell->text = $views[$cm->id]->numviews;
-            } else {
-                $numviewscell->text = '-';
-            }
-
-            $reportrow->cells[] = $numviewscell;
-
-            if ($CFG->useblogassociations) {
-                require_once($CFG->dirroot.'/blog/lib.php');
-                $blogcell = new html_table_cell();
-                $blogcell->attributes['class'] = 'blog';
-                if ($blogcount = blog_get_associated_count($course->id, $cm->id)) {
-                    $blogcell->text = html_writer::link('/blog/index.php?modid='.$cm->id, $blogcount);
-                } else {
-                    $blogcell->text = '-';
-                }
-                $reportrow->cells[] = $blogcell;
-            }
-
-            if ($showlastaccess) {
-                $lastaccesscell = new html_table_cell();
-                $lastaccesscell->attributes['class'] = 'lastaccess';
-
-                if (isset($views[$cm->id]->lasttime)) {
-                    $timeago = format_time(time() - $views[$cm->id]->lasttime);
-                    $lastaccesscell->text = userdate($views[$cm->id]->lasttime)." ($timeago)";
-                }
-                $reportrow->cells[] = $lastaccesscell;
-            }
-            $outlinetable->data[] = $reportrow;
-        }
-    }
-    echo html_writer::table($outlinetable);
-
-    echo $OUTPUT->footer();
-
-
-
diff --git a/course/report/outline/lib.php b/course/report/outline/lib.php
deleted file mode 100644 (file)
index 3d30cce..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?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/>.
-
-/**
- * This file contains functions used by the outline report
- *
- * @since 2.0
- * @package course-report
- * @copyright 2009 Sam Hemelryk
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-/**
- * This function extends the navigation with the report items
- *
- * @param navigation_node $navigation The navigation node to extend
- * @param stdClass $course The course to object for the report
- * @param stdClass $context The context of the course
- */
-function outline_report_extend_navigation($navigation, $course, $context) {
-    global $CFG, $OUTPUT;
-    if (has_capability('coursereport/outline:view', $context)) {
-        $url = new moodle_url('/course/report/outline/index.php', array('id'=>$course->id));
-        $navigation->add(get_string( 'activityreport' ), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
-    }
-}
-
-/**
- * Return a list of page types
- * @param string $pagetype current page type
- * @param stdClass $parentcontext Block's parent context
- * @param stdClass $currentcontext Current context of block
- */
-function outline_page_type_list($pagetype, $parentcontext, $currentcontext) {
-    $array = array(
-        '*' => get_string('page-x', 'pagetype'),
-        'course-report-*' => get_string('page-course-report-x', 'pagetype'),
-        'course-report-outline-index' => get_string('pluginpagetype',  'coursereport_outline')
-    );
-    return $array;
-}
\ No newline at end of file
diff --git a/course/report/outline/mod.php b/course/report/outline/mod.php
deleted file mode 100644 (file)
index 22a5b66..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-    if (!defined('MOODLE_INTERNAL')) {
-        die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
-    }
-
-    if (has_capability('coursereport/outline:view', $context)) {
-        echo '<p>';
-        $activityreport = get_string( 'activityreport' );
-        echo "<a href=\"{$CFG->wwwroot}/course/report/outline/index.php?id={$course->id}\">";
-        echo "$activityreport</a>\n";
-        echo '</p>';
-    }
diff --git a/course/report/outline/version.php b/course/report/outline/version.php
deleted file mode 100644 (file)
index 819c2f1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$plugin->version  = 2010090501;
-$plugin->requires = 2010090501;
-
-
diff --git a/course/report/participation/db/access.php b/course/report/participation/db/access.php
deleted file mode 100644 (file)
index 6a3293e..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$capabilities = array(
-
-    'coursereport/participation:view' => array(
-        'riskbitmask' => RISK_PERSONAL,
-        'captype' => 'read',
-        'contextlevel' => CONTEXT_COURSE,
-        'archetypes' => array(
-            'teacher' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-            'manager' => CAP_ALLOW
-        ),
-
-        'clonepermissionsfrom' => 'moodle/site:viewreports',
-    )
-);
-
-
diff --git a/course/report/participation/index.php b/course/report/participation/index.php
deleted file mode 100644 (file)
index 659b198..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-<?php
-
-    require_once('../../../config.php');
-    require_once($CFG->dirroot.'/lib/tablelib.php');
-
-    define('DEFAULT_PAGE_SIZE', 20);
-    define('SHOW_ALL_PAGE_SIZE', 5000);
-
-    $id         = required_param('id', PARAM_INT); // course id.
-    $roleid     = optional_param('roleid', 0, PARAM_INT); // which role to show
-    $instanceid = optional_param('instanceid', 0, PARAM_INT); // instance we're looking at.
-    $timefrom   = optional_param('timefrom', 0, PARAM_INT); // how far back to look...
-    $action     = optional_param('action', '', PARAM_ALPHA);
-    $page       = optional_param('page', 0, PARAM_INT);                     // which page to show
-    $perpage    = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT);  // how many per page
-
-    $url = new moodle_url('/course/report/participation/index.php', array('id'=>$id));
-    if ($roleid !== 0) $url->param('roleid');
-    if ($instanceid !== 0) $url->param('instanceid');
-    if ($timefrom !== 0) $url->param('timefrom');
-    if ($action !== '') $url->param('action');
-    if ($page !== 0) $url->param('page');
-    if ($perpage !== DEFAULT_PAGE_SIZE) $url->param('perpage');
-    $PAGE->set_url($url);
-    $PAGE->set_pagelayout('admin');
-
-    if ($action != 'view' and $action != 'post') {
-        $action = ''; // default to all (don't restrict)
-    }
-
-    if (!$course = $DB->get_record('course', array('id'=>$id))) {
-        print_error('invalidcourse');
-    }
-
-    if ($roleid != 0 and !$role = $DB->get_record('role', array('id'=>$roleid))) {
-        print_error('invalidrole');
-    }
-
-    require_login($course);
-    $context = get_context_instance(CONTEXT_COURSE, $course->id);
-    require_capability('coursereport/participation:view', $context);
-
-    add_to_log($course->id, "course", "report participation", "report/participation/index.php?id=$course->id", $course->id);
-
-    $strparticipation = get_string('participationreport');
-    $strviews         = get_string('views');
-    $strposts         = get_string('posts');
-    $strview          = get_string('view');
-    $strpost          = get_string('post');
-    $strallactions    = get_string('allactions');
-    $strreports       = get_string('reports');
-
-    $actionoptions = array('' => $strallactions,
-                           'view' => $strview,
-                           'post' => $strpost,);
-    if (!array_key_exists($action, $actionoptions)) {
-        $action = '';
-    }
-
-    $PAGE->set_title($course->shortname .': '. $strparticipation);
-    $PAGE->set_heading($course->fullname);
-    echo $OUTPUT->header();
-
-    $modinfo = get_fast_modinfo($course);
-
-    $modules = $DB->get_records_select('modules', "visible = 1", null, 'name ASC');
-
-    $instanceoptions = array();
-    foreach ($modules as $module) {
-        if (empty($modinfo->instances[$module->name])) {
-            continue;
-        }
-        $instances = array();
-        foreach ($modinfo->instances[$module->name] as $cm) {
-            // Skip modules such as label which do not actually have links;
-            // this means there's nothing to participate in
-            if (!$cm->has_view()) {
-                continue;
-            }
-            $instances[$cm->id] = format_string($cm->name);
-        }
-        if (count($instances) == 0) {
-            continue;
-        }
-        $instanceoptions[] = array(get_string('modulenameplural', $module->name)=>$instances);
-    }
-
-    $timeoptions = array();
-    // get minimum log time for this course
-    $minlog = $DB->get_field_sql('SELECT min(time) FROM {log} WHERE course = ?', array($course->id));
-
-    $now = usergetmidnight(time());
-
-    // days
-    for ($i = 1; $i < 7; $i++) {
-        if (strtotime('-'.$i.' days',$now) >= $minlog) {
-            $timeoptions[strtotime('-'.$i.' days',$now)] = get_string('numdays','moodle',$i);
-        }
-    }
-    // weeks
-    for ($i = 1; $i < 10; $i++) {
-        if (strtotime('-'.$i.' weeks',$now) >= $minlog) {
-            $timeoptions[strtotime('-'.$i.' weeks',$now)] = get_string('numweeks','moodle',$i);
-        }
-    }
-    // months
-    for ($i = 2; $i < 12; $i++) {
-        if (strtotime('-'.$i.' months',$now) >= $minlog) {
-            $timeoptions[strtotime('-'.$i.' months',$now)] = get_string('nummonths','moodle',$i);
-        }
-    }
-    // try a year
-    if (strtotime('-1 year',$now) >= $minlog) {
-        $timeoptions[strtotime('-1 year',$now)] = get_string('lastyear');
-    }
-
-    $roleoptions = array();
-    // TODO: we need a new list of roles that are visible here
-    if ($roles = get_roles_used_in_context($context)) {
-        foreach ($roles as $r) {
-            $roleoptions[$r->id] = $r->name;
-        }
-    }
-    $guestrole = get_guest_role();
-    if (empty($roleoptions[$guestrole->id])) {
-            $roleoptions[$guestrole->id] = $guestrole->name;
-    }
-
-    $roleoptions = role_fix_names($roleoptions, $context);
-
-    // print first controls.
-    echo '<form class="participationselectform" action="index.php" method="get"><div>'."\n".
-         '<input type="hidden" name="id" value="'.$course->id.'" />'."\n";
-    echo '<label for="menuinstanceid">'.get_string('activitymodule').'</label>'."\n";
-    echo html_writer::select($instanceoptions, 'instanceid', $instanceid);
-    echo '<label for="menutimefrom">'.get_string('lookback').'</label>'."\n";
-    echo html_writer::select($timeoptions,'timefrom',$timefrom);
-    echo '<label for="menuroleid">'.get_string('showonly').'</label>'."\n";
-    echo html_writer::select($roleoptions,'roleid',$roleid,false);
-    echo '<label for="menuaction">'.get_string('showactions').'</label>'."\n";
-    echo html_writer::select($actionoptions,'action',$action,false);
-    echo '<input type="submit" value="'.get_string('go').'" />'."\n</div></form>\n";
-
-    $baseurl =  $CFG->wwwroot.'/course/report/participation/index.php?id='.$course->id.'&amp;roleid='
-        .$roleid.'&amp;instanceid='.$instanceid.'&amp;timefrom='.$timefrom.'&amp;action='.$action.'&amp;perpage='.$perpage;
-
-    if (!empty($instanceid) && !empty($roleid)) {
-        // from here assume we have at least the module we're using.
-        $cm = $modinfo->cms[$instanceid];
-        $modulename = get_string('modulename', $cm->modname);
-
-        include_once($CFG->dirroot.'/mod/'.$cm->modname.'/lib.php');
-
-        $viewfun = $cm->modname.'_get_view_actions';
-        $postfun = $cm->modname.'_get_post_actions';
-
-        if (!function_exists($viewfun) || !function_exists($postfun)) {
-            print_error('modulemissingcode', 'error', $baseurl, $cm->modname);
-        }
-
-        $viewnames = $viewfun();
-        $postnames = $postfun();
-
-        $table = new flexible_table('course-participation-'.$course->id.'-'.$cm->id.'-'.$roleid);
-        $table->course = $course;
-
-        $table->define_columns(array('fullname','count','select'));
-        $table->define_headers(array(get_string('user'),((!empty($action)) ? get_string($action) : get_string('allactions')),get_string('select')));
-        $table->define_baseurl($baseurl);
-
-        $table->set_attribute('cellpadding','5');
-        $table->set_attribute('class', 'generaltable generalbox reporttable');
-
-        $table->sortable(true,'lastname','ASC');
-        $table->no_sorting('select');
-
-        $table->set_control_variables(array(
-                                            TABLE_VAR_SORT    => 'ssort',
-                                            TABLE_VAR_HIDE    => 'shide',
-                                            TABLE_VAR_SHOW    => 'sshow',
-                                            TABLE_VAR_IFIRST  => 'sifirst',
-                                            TABLE_VAR_ILAST   => 'silast',
-                                            TABLE_VAR_PAGE    => 'spage'
-                                            ));
-        $table->setup();
-
-        switch ($action) {
-            case 'view':
-                $actions = $viewnames;
-                break;
-            case 'post':
-                $actions = $postnames;
-                break;
-            default:
-                // some modules have stuff we want to hide, ie mail blocked etc so do actually need to limit here.
-                $actions = array_merge($viewnames, $postnames);
-        }
-
-        list($actionsql, $params) = $DB->get_in_or_equal($actions, SQL_PARAMS_NAMED, 'action');
-        $actionsql = "action $actionsql";
-
-        $relatedcontexts = get_related_contexts_string($context);
-
-        $sql = "SELECT ra.userid, u.firstname, u.lastname, u.idnumber, l.actioncount AS count
-                FROM (SELECT * FROM {role_assignments} WHERE contextid $relatedcontexts AND roleid = :roleid ) ra
-                JOIN {user} u ON u.id = ra.userid
-                LEFT JOIN (
-                    SELECT userid, COUNT(action) AS actioncount FROM {log} WHERE cmid = :instanceid AND time > :timefrom AND $actionsql GROUP BY userid
-                ) l ON (l.userid = ra.userid)";
-        $params['roleid'] = $roleid;
-        $params['instanceid'] = $instanceid;
-        $params['timefrom'] = $timefrom;
-
-        list($twhere, $tparams) = $table->get_sql_where();
-        if ($twhere) {
-            $sql .= ' WHERE '.$twhere; //initial bar
-            $params = array_merge($params, $tparams);
-        }
-
-        if ($table->get_sql_sort()) {
-            $sql .= ' ORDER BY '.$table->get_sql_sort();
-        }
-
-        $countsql = "SELECT COUNT(DISTINCT(ra.userid))
-                       FROM {role_assignments} ra
-                      WHERE ra.contextid $relatedcontexts AND ra.roleid = :roleid";
-
-        $totalcount = $DB->count_records_sql($countsql, $params);
-
-        if ($twhere) {
-            $matchcount = $DB->count_records_sql($countsql.' AND '.$twhere, $params);
-        } else {
-            $matchcount = $totalcount;
-        }
-
-        echo '<div id="participationreport">' . "\n";
-        echo '<p class="modulename">'.$modulename . ' ' . $strviews.': '.implode(', ',$viewnames).'<br />'."\n"
-            . $modulename . ' ' . $strposts.': '.implode(', ',$postnames).'</p>'."\n";
-
-        $table->initialbars($totalcount > $perpage);
-        $table->pagesize($perpage, $matchcount);
-
-        if (!$users = $DB->get_records_sql($sql, $params, $table->get_page_start(), $table->get_page_size())) {
-            $users = array(); // tablelib will handle saying 'Nothing to display' for us.
-        }
-
-        $data = array();
-
-        $a->count = $totalcount;
-        $a->items = $role->name;
-
-        if ($matchcount != $totalcount) {
-            $a->count = $matchcount.'/'.$a->count;
-        }
-
-        echo '<h2>'.get_string('counteditems', '', $a).'</h2>'."\n";
-
-        echo '<form action="'.$CFG->wwwroot.'/user/action_redir.php" method="post" id="studentsform">'."\n";
-        echo '<div>'."\n";
-        echo '<input type="hidden" name="id" value="'.$id.'" />'."\n";
-        echo '<input type="hidden" name="returnto" value="'. s($FULLME) .'" />'."\n";
-        echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'."\n";
-
-        foreach ($users as $u) {
-            $data = array('<a href="'.$CFG->wwwroot.'/user/view.php?id='.$u->userid.'&amp;course='.$course->id.'">'.fullname($u,true).'</a>'."\n",
-                          ((!empty($u->count)) ? get_string('yes').' ('.$u->count.') ' : get_string('no')),
-                          '<input type="checkbox" class="usercheckbox" name="user'.$u->userid.'" value="'.$u->count.'" />'."\n",
-                          );
-            $table->add_data($data);
-        }
-
-        $table->print_html();
-
-        if ($perpage == SHOW_ALL_PAGE_SIZE) {
-            echo '<div id="showall"><a href="'.$baseurl.'&amp;perpage='.DEFAULT_PAGE_SIZE.'">'.get_string('showperpage', '', DEFAULT_PAGE_SIZE).'</a></div>'."\n";
-        }
-        else if ($matchcount > 0 && $perpage < $matchcount) {
-            echo '<div id="showall"><a href="'.$baseurl.'&amp;perpage='.SHOW_ALL_PAGE_SIZE.'">'.get_string('showall', '', $matchcount).'</a></div>'."\n";
-        }
-
-        echo '<div class="selectbuttons">';
-        echo '<input type="button" id="checkall" value="'.get_string('selectall').'" /> '."\n";
-        echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" /> '."\n";
-        if ($perpage >= $matchcount) {
-            echo '<input type="button" id="checknos" value="'.get_string('selectnos').'" />'."\n";
-        }
-        echo '</div>';
-        echo '<div>';
-        echo '<label for="formaction">'.get_string('withselectedusers').'</label>';
-        $displaylist['messageselect.php'] = get_string('messageselectadd');
-        echo html_writer::select($displaylist, 'formaction', '', array(''=>'choosedots'), array('id'=>'formactionselect'));
-        echo $OUTPUT->help_icon('withselectedusers');
-        echo '<input type="submit" value="' . get_string('ok') . '" />'."\n";
-        echo '</div>';
-        echo '</div>'."\n";
-        echo '</form>'."\n";
-        echo '</div>'."\n";
-
-        $PAGE->requires->js_init_call('M.coursereport_participation.init');
-    }
-
-    echo $OUTPUT->footer();
-
-
diff --git a/course/report/participation/mod.php b/course/report/participation/mod.php
deleted file mode 100644 (file)
index 5c1fbff..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-    if (!defined('MOODLE_INTERNAL')) {
-        die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
-    }
-
-    if (has_capability('coursereport/participation:view', $context)) {
-        echo '<p>';
-        $participationreport = get_string('participationreport');
-        echo "<a href=\"{$CFG->wwwroot}/course/report/participation/index.php?id={$course->id}\">";
-        echo "$participationreport</a>\n";
-        echo '</p>';
-    }
-
diff --git a/course/report/participation/version.php b/course/report/participation/version.php
deleted file mode 100644 (file)
index 819c2f1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$plugin->version  = 2010090501;
-$plugin->requires = 2010090501;
-
-
diff --git a/course/report/progress/db/access.php b/course/report/progress/db/access.php
deleted file mode 100644 (file)
index 89a0f38..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$capabilities = array(
-
-    'coursereport/progress:view' => array(
-        'riskbitmask' => RISK_PERSONAL,
-        'captype' => 'read',
-        'contextlevel' => CONTEXT_COURSE,
-        'archetypes' => array(
-            'teacher' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-            'manager' => CAP_ALLOW
-        ),
-
-        'clonepermissionsfrom' => 'moodle/site:viewreports',
-    )
-);
-
-
diff --git a/course/report/progress/mod.php b/course/report/progress/mod.php
deleted file mode 100644 (file)
index db7ea02..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-    if (!defined('MOODLE_INTERNAL')) {
-        die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
-    }
-
-    require_once($CFG->libdir.'/completionlib.php');
-
-    if (has_capability('coursereport/progress:view', $context)) {
-        $completion = new completion_info($course);
-        if ($completion->is_enabled()) {
-            echo '<p>';
-            echo '<a href="'.$CFG->wwwroot.'/course/report/progress/?course='.$course->id.'">'.get_string('activitycompletion', 'completion').'</a>';
-            echo '</p>';
-        }
-    }
-
diff --git a/course/report/progress/version.php b/course/report/progress/version.php
deleted file mode 100644 (file)
index 819c2f1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$plugin->version  = 2010090501;
-$plugin->requires = 2010090501;
-
-
diff --git a/course/report/stats/index.php b/course/report/stats/index.php
deleted file mode 100644 (file)
index 6af3bc7..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-    require_once('../../../config.php');
-    require_once($CFG->dirroot.'/lib/statslib.php');
-    require_once($CFG->dirroot.'/course/report/stats/lib.php');
-    require_once($CFG->libdir.'/adminlib.php');
-
-    $courseid = optional_param('course', SITEID, PARAM_INT);
-    $report   = optional_param('report', 0, PARAM_INT);
-    $time     = optional_param('time', 0, PARAM_INT);
-    $mode     = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
-    $userid   = optional_param('userid', 0, PARAM_INT);
-    $roleid   = 0;
-
-    if ($report > 50) {
-        $roleid = substr($report,1);
-        $report = 5;
-    }
-
-    if ($report == STATS_REPORT_USER_LOGINS) {
-        $courseid = SITEID; //override
-    }
-
-    if ($mode == STATS_MODE_RANKED) {
-        redirect($CFG->wwwroot.'/course/report/stats/index.php?time='.$time);
-    }
-
-    if (!$course = $DB->get_record("course", array("id"=>$courseid))) {
-        print_error("invalidcourseid");
-    }
-
-    if (!empty($userid)) {
-        if (!$user = $DB->get_record('user', array('id'=>$userid))) {
-            print_error("nousers");
-        }
-    }
-
-    require_login($course);
-    $context = get_context_instance(CONTEXT_COURSE, $course->id);
-    require_capability('coursereport/stats:view', $context);
-
-    $PAGE->set_url(new moodle_url('/course/report/stats/index.php', array('course' => $course->id,
-                                                                          'report' => $report,
-                                                                          'time'   => $time,
-                                                                          'mode'   => $mode,
-                                                                          'userid' => $userid)));
-
-    add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
-    stats_check_uptodate($course->id);
-
-    if ($course->id == SITEID) {
-        admin_externalpage_setup('reportstats');
-        echo $OUTPUT->header();
-    } else {
-        $strreports = get_string("reports");
-        $strstats = get_string('stats');
-
-        $PAGE->set_title("$course->shortname: $strstats");
-        $PAGE->set_heading($course->fullname);
-        $PAGE->set_pagelayout('report');
-        $PAGE->set_headingmenu(report_stats_mode_menu($course, $mode, $time, "$CFG->wwwroot/course/report/stats/index.php"));
-        echo $OUTPUT->header();
-    }
-
-    require($CFG->dirroot.'/course/report/stats/report.php');
-
-    if (empty($CFG->enablestats)) {
-        if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
-            redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
-        } else {
-            print_error('statsdisable');
-        }
-    }
-
-    echo $OUTPUT->footer();
-
-
diff --git a/course/report/stats/lib.php b/course/report/stats/lib.php
deleted file mode 100644 (file)
index 974463c..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-<?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/>.
-
-/**
- * This file contains functions used by the log reports
- *
- * This file is also required by /admin/reports/stats/index.php.
- *
- * @package course-report
- * @copyright  1999 onwards  Martin Dougiamas  http://moodle.com
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-require_once($CFG->dirroot.'/lib/statslib.php');
-
-function report_stats_mode_menu($course, $mode, $time, $url) {
-    global $CFG, $OUTPUT;
-    /*
-    $reportoptions = stats_get_report_options($course->id, $mode);
-    $timeoptions = report_stats_timeoptions($mode);
-    if (empty($timeoptions)) {
-        print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
-    }
-    */
-
-    $options = array();
-    $options[STATS_MODE_GENERAL] = get_string('statsmodegeneral');
-    $options[STATS_MODE_DETAILED] = get_string('statsmodedetailed');
-    if (has_capability('coursereport/stats:view', get_context_instance(CONTEXT_SYSTEM))) {
-        $options[STATS_MODE_RANKED] = get_string('reports');
-    }
-    $popupurl = $url."?course=$course->id&time=$time";
-    $select = new single_select(new moodle_url($popupurl), 'mode', $options, $mode, null);
-    $select->formid = 'switchmode';
-    return $OUTPUT->render($select);
-}
-
-
-function report_stats_timeoptions($mode) {
-    global $CFG, $DB;
-
-    if ($mode == STATS_MODE_DETAILED) {
-        $earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_daily}');
-        $earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_weekly}');
-        $earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_user_monthly}');
-    } else {
-        $earliestday = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_daily}');
-        $earliestweek = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_weekly}');
-        $earliestmonth = $DB->get_field_sql('SELECT MIN(timeend) FROM {stats_monthly}');
-    }
-
-
-    if (empty($earliestday)) $earliestday = time();
-    if (empty($earliestweek)) $earliestweek = time();
-    if (empty($earliestmonth)) $earliestmonth = time();
-
-    $now = stats_get_base_daily();
-    $lastweekend = stats_get_base_weekly();
-    $lastmonthend = stats_get_base_monthly();
-
-    return stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
-}
-
-/**
- * This function extends the navigation with the report items
- *
- * @param navigation_node $navigation The navigation node to extend
- * @param stdClass $course The course to object for the report
- * @param stdClass $context The context of the course
- */
-function stats_report_extend_navigation($navigation, $course, $context) {
-    global $CFG, $OUTPUT;
-    if (has_capability('coursereport/stats:view', $context)) {
-        if (!empty($CFG->enablestats)) {
-            $url = new moodle_url('/course/report/stats/index.php', array('course'=>$course->id));
-            $navigation->add(get_string('stats'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
-        }
-    }
-}
-
-/**
- * Return a list of page types
- * @param string $pagetype current page type
- * @param stdClass $parentcontext Block's parent context
- * @param stdClass $currentcontext Current context of block
- */
-function stats_page_type_list($pagetype, $parentcontext, $currentcontext) {
-    $array = array(
-        '*' => get_string('page-x', 'pagetype'),
-        'course-report-*' => get_string('page-course-report-x', 'pagetype'),
-        'course-report-stats-index' => get_string('pluginpagetype',  'coursereport_stats')
-    );
-    return $array;
-}
\ No newline at end of file
diff --git a/course/report/stats/mod.php b/course/report/stats/mod.php
deleted file mode 100644 (file)
index 1f70b7a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-    if (!defined('MOODLE_INTERNAL')) {
-        die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
-    }
-
-    if (has_capability('coursereport/stats:view', $context)) {
-        if (!empty($CFG->enablestats)) {
-            echo '<p>';
-            echo '<a href="'.$CFG->wwwroot.'/course/report/stats/index.php?course='.$course->id.'">'.get_string('stats').'</a>';
-            echo '</p>';
-        } else {
-            echo '<p>';
-            echo get_string('statsoff');
-            echo '</p>';
-        }
-    }
-
diff --git a/course/report/stats/version.php b/course/report/stats/version.php
deleted file mode 100644 (file)
index 819c2f1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-$plugin->version  = 2010090501;
-$plugin->requires = 2010090501;
-
-
index 21af6d7..c7b9e30 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
 
 require_once("../config.php");
 require_once("lib.php");
-require_once($CFG->libdir.'/completionlib.php');
 
 $id      = required_param('id',PARAM_INT);       // course id
 $user    = required_param('user',PARAM_INT);     // user id
 $mode    = optional_param('mode', "todaylogs", PARAM_ALPHA);
-$page    = optional_param('page', 0, PARAM_INT);
-$perpage = optional_param('perpage', 100, PARAM_INT);
 
 $url = new moodle_url('/course/user.php', array('id'=>$id,'user'=>$user, 'mode'=>$mode));
-if ($page !== 0) {
-    $url->param('page', $page);
+
+$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
+$user = $DB->get_record("user", array("id"=>$user, 'deleted'=>0), '*', MUST_EXIST);
+
+if ($mode === 'outline' or $mode === 'complete') {
+    $url = new moodle_url('/report/outline/user.php', array('id'=>$user->id, 'course'=>$course->id, 'mode'=>$mode));
+    redirect($url);
 }
-if ($perpage !== 100) {
-    $url->param('perpage', $perpage);
+if ($mode === 'todaylogs' or $mode === 'alllogs') {
+    $logmode = ($mode === 'todaylogs') ? 'today' : 'all';
+    $url = new moodle_url('/report/log/user.php', array('id'=>$user->id, 'course'=>$course->id, 'mode'=>$logmode));
+    redirect($url);
 }
-$PAGE->set_url($url);
-
-if (!$course = $DB->get_record('course', array('id'=>$id))) {
-    print_error('invalidcourseid', 'error');
+if ($mode === 'stats') {
+    $url = new moodle_url('/report/stats/user.php', array('id'=>$user->id, 'course'=>$course->id));
+    redirect($url);
 }
-
-if (! $user = $DB->get_record("user", array("id"=>$user))) {
-    print_error('invaliduserid', 'error');
+if ($mode === 'coursecompletions' or $mode === 'coursecompletion') {
+    $url = new moodle_url('/report/completion/user.php', array('id'=>$user->id, 'course'=>$course->id));
+    redirect($url);
 }
 
-require_login();
 $coursecontext   = get_context_instance(CONTEXT_COURSE, $course->id);
 $personalcontext = get_context_instance(CONTEXT_USER, $user->id);
 
@@ -76,26 +77,6 @@ $anyreport  = has_capability('moodle/user:viewuseractivitiesreport', $personalco
 
 $modes = array();
 
-if ($myreports or $anyreport or has_capability('coursereport/outline:view', $coursecontext)) {
-    $modes[] = 'outline';
-}
-
-if ($myreports or $anyreport or has_capability('coursereport/outline:view', $coursecontext)) {
-    $modes[] = 'complete';
-}
-
-if ($myreports or $anyreport or has_capability('coursereport/log:viewtoday', $coursecontext)) {
-    $modes[] = 'todaylogs';
-}
-
-if ($myreports or $anyreport or has_capability('coursereport/log:view', $coursecontext)) {
-    $modes[] = 'alllogs';
-}
-
-if ($myreports or $anyreport or has_capability('coursereport/stats:view', $coursecontext)) {
-    $modes[] = 'stats';
-}
-
 if (has_capability('moodle/grade:viewall', $coursecontext)) {
     //ok - can view all course grades
     $modes[] = 'grade';
@@ -113,19 +94,6 @@ if (has_capability('moodle/grade:viewall', $coursecontext)) {
     $modes[] = 'grade';
 }
 
-// Course completion tab
-if (!empty($CFG->enablecompletion) && ($course->id == SITEID || !empty($course->enablecompletion)) && // completion enabled
-    ($myreports || $anyreport || ($course->id == SITEID || has_capability('coursereport/completion:view', $coursecontext)))) { // permissions to view the report
-
-    // Decide if singular or plural
-    if ($course->id == SITEID) {
-        $modes[] = 'coursecompletions';
-    } else {
-        $modes[] = 'coursecompletion';
-    }
-}
-
-
 if (empty($modes)) {
     require_capability('moodle/user:viewuseractivitiesreport', $personalcontext);
 }
@@ -138,18 +106,6 @@ if (!in_array($mode, $modes)) {
 add_to_log($course->id, "course", "user report", "user.php?id=$course->id&amp;user=$user->id&amp;mode=$mode", "$user->id");
 
 $stractivityreport = get_string("activityreport");
-$strparticipants   = get_string("participants");
-$stroutline        = get_string("outline");
-$strcomplete       = get_string("complete");
-$stralllogs        = get_string("alllogs");
-$strtodaylogs      = get_string("todaylogs");
-$strmode           = get_string($mode);
-$fullname          = fullname($user, true);
-
-$link = null;
-if ($course->id != SITEID && has_capability('moodle/course:viewparticipants', $coursecontext)) {
-    $link = new moodle_url('/user/index.php', array('id'=>$course->id));
-}
 
 $PAGE->navigation->extend_for_user($user);
 $PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.
@@ -172,434 +128,6 @@ switch ($mode) {
         }
         break;
 
-    case "todaylogs" :
-        echo '<div class="graph">';
-        print_log_graph($course, $user->id, "userday.png");
-        echo '</div>';
-        print_log($course, $user->id, usergetmidnight(time()), "l.time DESC", $page, $perpage,
-                  "user.php?id=$course->id&amp;user=$user->id&amp;mode=$mode");
-        break;
-
-    case "alllogs" :
-        echo '<div class="graph">';
-        print_log_graph($course, $user->id, "usercourse.png");
-        echo '</div>';
-        print_log($course, $user->id, 0, "l.time DESC", $page, $perpage,
-                  "user.php?id=$course->id&amp;user=$user->id&amp;mode=$mode");
-        break;
-    case 'stats':
-
-        if (empty($CFG->enablestats)) {
-            print_error('statsdisable', 'error');
-        }
-
-        require_once($CFG->dirroot.'/lib/statslib.php');
-
-        $statsstatus = stats_check_uptodate($course->id);
-        if ($statsstatus !== NULL) {
-            echo $OUTPUT->notification($statsstatus);
-        }
-
-        $earliestday   = $DB->get_field_sql('SELECT timeend FROM {stats_user_daily} ORDER BY timeend');
-        $earliestweek  = $DB->get_field_sql('SELECT timeend FROM {stats_user_weekly} ORDER BY timeend');
-        $earliestmonth = $DB->get_field_sql('SELECT timeend FROM {stats_user_monthly} ORDER BY timeend');
-
-        if (empty($earliestday)) $earliestday = time();
-        if (empty($earliestweek)) $earliestweek = time();
-        if (empty($earliestmonth)) $earliestmonth = time();
-
-        $now = stats_get_base_daily();
-        $lastweekend = stats_get_base_weekly();
-        $lastmonthend = stats_get_base_monthly();
-
-        $timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
-
-        if (empty($timeoptions)) {
-            print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
-        }
-
-        // use the earliest.
-        $time = array_pop(array_keys($timeoptions));
-
-        $param = stats_get_parameters($time,STATS_REPORT_USER_VIEW,$course->id,STATS_MODE_DETAILED);
-        $params = $param->params;
-
-        $param->table = 'user_'.$param->table;
-
-        $sql = 'SELECT timeend,'.$param->fields.' FROM {stats_'.$param->table.'} WHERE '
-        .(($course->id == SITEID) ? '' : ' courseid = '.$course->id.' AND ')
-            .' userid = '.$user->id.' AND timeend >= '.$param->timeafter .$param->extras
-            .' ORDER BY timeend DESC';
-        $stats = $DB->get_records_sql($sql, $params); //TODO: improve these params!!
-
-        if (empty($stats)) {
-            print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
-        }
-
-        // MDL-10818, do not display broken graph when user has no permission to view graph
-        if ($myreports or has_capability('coursereport/stats:view', $coursecontext)) {
-            echo '<center><img src="'.$CFG->wwwroot.'/course/report/stats/graph.php?mode='.STATS_MODE_DETAILED.'&course='.$course->id.'&time='.$time.'&report='.STATS_REPORT_USER_VIEW.'&userid='.$user->id.'" alt="'.get_string('statisticsgraph').'" /></center>';
-        }
-
-        // What the heck is this about?   -- MD
-        $stats = stats_fix_zeros($stats,$param->timeafter,$param->table,(!empty($param->line2)),(!empty($param->line3)));
-
-        $table = new html_table();
-        $table->align = array('left','center','center','center');
-        $param->table = str_replace('user_','',$param->table);
-        switch ($param->table) {
-            case 'daily'  : $period = get_string('day'); break;
-            case 'weekly' : $period = get_string('week'); break;
-            case 'monthly': $period = get_string('month', 'form'); break;
-            default : $period = '';
-        }
-        $table->head = array(get_string('periodending','moodle',$period),$param->line1,$param->line2,$param->line3);
-        foreach ($stats as $stat) {
-            if (!empty($stat->zerofixed)) {  // Don't know why this is necessary, see stats_fix_zeros above - MD
-                continue;
-            }
-            $a = array(userdate($stat->timeend,get_string('strftimedate'),$CFG->timezone),$stat->line1);
-            $a[] = $stat->line2;
-            $a[] = $stat->line3;
-            $table->data[] = $a;
-        }
-        echo html_writer::table($table);
-        break;
-
-    case "outline" :
-    case "complete" :
-        get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
-        $sections = get_all_sections($course->id);
-        $itemsprinted = false;
-
-        for ($i=0; $i<=$course->numsections; $i++) {
-
-            if (isset($sections[$i])) {   // should always be true
-
-                $section = $sections[$i];
-                $showsection = (has_capability('moodle/course:viewhiddensections', $coursecontext) or $section->visible or !$course->hiddensections);
-
-                if ($showsection) { // prevent hidden sections in user activity. Thanks to Geoff Wilbert!
-                    // Check the section has a sequence. This is the sequence of modules/resources.
-                    // If there is no sequence there is nothing to display.
-                    if ($section->sequence) {
-                        $itemsprinted = true;
-                        echo '<div class="section">';
-                        echo '<h2>';
-                        echo get_section_name($course, $section);
-                        echo "</h2>";
-
-                        echo '<div class="content">';
-
-                        if ($mode == "outline") {
-                            echo "<table cellpadding=\"4\" cellspacing=\"0\">";
-                        }
-
-                        $sectionmods = explode(",", $section->sequence);
-                        foreach ($sectionmods as $sectionmod) {
-                            if (empty($mods[$sectionmod])) {
-                                continue;
-                            }
-                            $mod = $mods[$sectionmod];
-
-                            if (empty($mod->visible)) {
-                                continue;
-                            }
-
-                            $instance = $DB->get_record("$mod->modname", array("id"=>$mod->instance));
-                            $libfile = "$CFG->dirroot/mod/$mod->modname/lib.php";
-
-                            if (file_exists($libfile)) {
-                                require_once($libfile);
-
-                                switch ($mode) {
-                                    case "outline":
-                                        $user_outline = $mod->modname."_user_outline";
-                                        if (function_exists($user_outline)) {
-                                            $output = $user_outline($course, $user, $mod, $instance);
-                                            print_outline_row($mod, $instance, $output);
-                                        }
-                                        break;
-                                    case "complete":
-                                        $user_complete = $mod->modname."_user_complete";
-                                        if (function_exists($user_complete)) {
-                                            $image = $OUTPUT->pix_icon('icon', $mod->modfullname, 'mod_'.$mod->modname, array('class'=>'icon'));
-                                            echo "<h4>$image $mod->modfullname: ".
-                                                 "<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
-                                                 format_string($instance->name,true)."</a></h4>";
-
-                                            ob_start();
-
-                                            echo "<ul>";
-                                            $user_complete($course, $user, $mod, $instance);
-                                            echo "</ul>";
-
-                                            $output = ob_get_contents();
-                                            ob_end_clean();
-
-                                            if (str_replace(' ', '', $output) != '<ul></ul>') {
-                                                echo $output;
-                                            }
-                                        }
-                                        break;
-                                    }
-                                }
-                            }
-
-                        if ($mode == "outline") {
-                            echo "</table>";
-                        }
-                        echo '</div>';  // content
-                        echo '</div>';  // section
-                    }
-                }
-            }
-        }
-
-        if (!$itemsprinted) {
-            echo $OUTPUT->notification(get_string('nothingtodisplay'));
-        }
-
-        break;
-    case "coursecompletion":
-    case "coursecompletions":
-
-        // Display course completion user report
-
-        // Grab all courses the user is enrolled in and their completion status
-        $sql = "
-            SELECT DISTINCT
-                c.id AS id
-            FROM
-                {course} c
-            INNER JOIN
-                {context} con
-             ON con.instanceid = c.id
-            INNER JOIN
-                {role_assignments} ra
-             ON ra.contextid = con.id
-            INNER JOIN
-                {enrol} e
-             ON c.id = e.courseid
-            INNER JOIN
-                {user_enrolments} ue
-             ON e.id = ue.enrolid AND ra.userid = ue.userid
-            AND ra.userid = {$user->id}
-        ";
-
-        // Get roles that are tracked by course completion
-        if ($roles = $CFG->gradebookroles) {
-            $sql .= '
-                AND ra.roleid IN ('.$roles.')
-            ';
-        }
-
-        $sql .= '
-            WHERE
-                con.contextlevel = '.CONTEXT_COURSE.'
-            AND c.enablecompletion = 1
-        ';
-
-
-        // If we are looking at a specific course
-        if ($course->id != 1) {
-            $sql .= '
-                AND c.id = '.(int)$course->id.'
-            ';
-        }
-
-        // Check if result is empty
-        $rs = $DB->get_recordset_sql($sql);
-        if (!$rs->valid()) {
-
-            if ($course->id != 1) {
-                $error = get_string('nocompletions', 'coursereport_completion');
-            } else {
-                $error = get_string('nocompletioncoursesenroled', 'coursereport_completion');
-            }
-
-            echo $OUTPUT->notification($error);
-            $rs->close(); // not going to loop (but break), close rs
-            break;
-        }
-
-        // Categorize courses by their status
-        $courses = array(
-            'inprogress'    => array(),
-            'complete'      => array(),
-            'unstarted'     => array()
-        );
-
-        // Sort courses by the user's status in each
-        foreach ($rs as $course_completion) {
-            $c_info = new completion_info((object)$course_completion);
-
-            // Is course complete?
-            $coursecomplete = $c_info->is_course_complete($user->id);
-
-            // Has this user completed any criteria?
-            $criteriacomplete = $c_info->count_course_user_data($user->id);
-
-            if ($coursecomplete) {
-                $courses['complete'][] = $c_info;
-            } else if ($criteriacomplete) {
-                $courses['inprogress'][] = $c_info;
-            } else {
-                $courses['unstarted'][] = $c_info;
-            }
-        }
-        $rs->close(); // after loop, close rs
-
-        // Loop through course status groups
-        foreach ($courses as $type => $infos) {
-
-            // If there are courses with this status
-            if (!empty($infos)) {
-
-                echo '<h1 align="center">'.get_string($type, 'coursereport_completion').'</h1>';
-                echo '<table class="generalbox boxaligncenter">';
-                echo '<tr class="ccheader">';
-                echo '<th class="c0 header" scope="col">'.get_string('course').'</th>';
-                echo '<th class="c1 header" scope="col">'.get_string('requiredcriteria', 'completion').'</th>';
-                echo '<th class="c2 header" scope="col">'.get_string('status').'</th>';
-                echo '<th class="c3 header" scope="col" width="15%">'.get_string('info').'</th>';
-
-                if ($type === 'complete') {
-                    echo '<th class="c4 header" scope="col">'.get_string('completiondate', 'coursereport_completion').'</th>';
-                }
-
-                echo '</tr>';
-
-                // For each course
-                foreach ($infos as $c_info) {
-
-                    // Get course info
-                    $c_course = $DB->get_record('course', array('id' => $c_info->course_id));
-                    $course_context = get_context_instance(CONTEXT_COURSE, $c_course->id, MUST_EXIST);
-                    $course_name = format_string($c_course->fullname, true, array('context' => $course_context));
-
-                    // Get completions
-                    $completions = $c_info->get_completions($user->id);
-
-                    // Save row data
-                    $rows = array();
-
-                    // For aggregating activity completion
-                    $activities = array();
-                    $activities_complete = 0;
-
-                    // For aggregating prerequisites
-                    $prerequisites = array();
-                    $prerequisites_complete = 0;
-
-                    // Loop through course criteria
-                    foreach ($completions as $completion) {
-                        $criteria = $completion->get_criteria();
-                        $complete = $completion->is_complete();
-
-                        // Activities are a special case, so cache them and leave them till last
-                        if ($criteria->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
-                            $activities[$criteria->moduleinstance] = $complete;
-
-                            if ($complete) {
-                                $activities_complete++;
-                            }
-
-                            continue;
-                        }
-
-                        // Prerequisites are also a special case, so cache them and leave them till last
-                        if ($criteria->criteriatype == COMPLETION_CRITERIA_TYPE_COURSE) {
-                            $prerequisites[$criteria->courseinstance] = $complete;
-
-                            if ($complete) {
-                                $prerequisites_complete++;
-                            }
-
-                            continue;
-                        }
-
-                        $row = array();
-                        $row['title'] = $criteria->get_title();
-                        $row['status'] = $completion->get_status();
-                        $rows[] = $row;
-                    }
-
-                    // Aggregate activities
-                    if (!empty($activities)) {
-
-                        $row = array();
-                        $row['title'] = get_string('activitiescomplete', 'coursereport_completion');
-                        $row['status'] = $activities_complete.' of '.count($activities);
-                        $rows[] = $row;
-                    }
-
-                    // Aggregate prerequisites
-                    if (!empty($prerequisites)) {
-
-                        $row = array();
-                        $row['title'] = get_string('prerequisitescompleted', 'completion');
-                        $row['status'] = $prerequisites_complete.' of '.count($prerequisites);
-                        array_splice($rows, 0, 0, array($row));
-                    }
-
-                    $first_row = true;
-
-                    // Print table
-                    foreach ($rows as $row) {
-
-                        // Display course name on first row
-                        if ($first_row) {
-                            echo '<tr><td class="c0"><a href="'.$CFG->wwwroot.'/course/view.php?id='.$c_course->id.'">'.$course_name.'</a></td>';
-                        } else {
-                            echo '<tr><td class="c0"></td>';
-                        }
-
-                        echo '<td class="c1">';
-                        echo $row['title'];
-                        echo '</td><td class="c2">';
-
-                        switch ($row['status']) {
-                            case 'Yes':
-                                echo get_string('complete');
-                                break;
-
-                            case 'No':
-                                echo get_string('incomplete', 'coursereport_completion');
-                                break;
-
-                            default:
-                                echo $row['status'];
-                        }
-
-                        // Display link on first row
-                        echo '</td><td class="c3">';
-                        if ($first_row) {
-                            echo '<a href="'.$CFG->wwwroot.'/blocks/completionstatus/details.php?course='.$c_course->id.'&user='.$user->id.'">'.get_string('detailedview', 'coursereport_completion').'</a>';
-                        }
-                        echo '</td>';
-
-                        // Display completion date for completed courses on first row
-                        if ($type === 'complete' && $first_row) {
-                            $params = array(
-                                'userid'    => $user->id,
-                                'course'  => $c_course->id
-                            );
-
-                            $ccompletion = new completion_completion($params);
-                            echo '<td class="c4">'.userdate($ccompletion->timecompleted, '%e %B %G').'</td>';
-                        }
-
-                        $first_row = false;
-                        echo '</tr>';
-                    }
-                }
-
-                echo '</table>';
-            }
-
-        }
-
         break;
     default:
         // can not be reached ;-)
@@ -607,31 +135,3 @@ switch ($mode) {
 
 
 echo $OUTPUT->footer();
-
-
-function print_outline_row($mod, $instance, $result) {
-    global $OUTPUT;
-
-    $image = "<img src=\"" . $OUTPUT->pix_url('icon', $mod->modname) . "\" class=\"icon\" alt=\"$mod->modfullname\" />";
-
-    echo "<tr>";
-    echo "<td valign=\"top\">$image</td>";
-    echo "<td valign=\"top\" style=\"width:300\">";
-    echo "   <a title=\"$mod->modfullname\"";
-    echo "   href=\"../mod/$mod->modname/view.php?id=$mod->id\">".format_string($instance->name,true)."</a></td>";
-    echo "<td>&nbsp;&nbsp;&nbsp;</td>";
-    echo "<td valign=\"top\">";
-    if (isset($result->info)) {
-        echo "$result->info";
-    } else {
-        echo "<p style=\"text-align:center\">-</p>";
-    }
-    echo "</td>";
-    echo "<td>&nbsp;&nbsp;&nbsp;</td>";
-    if (!empty($result->time)) {
-        $timeago = format_time(time() - $result->time);
-        echo "<td valign=\"top\" style=\"white-space: nowrap\">".userdate($result->time)." ($timeago)</td>";
-    }
-    echo "</tr>";
-}
-
index 11d6074..2b69aaf 100644 (file)
@@ -117,7 +117,7 @@ class core_enrol_external extends external_api {
                             'name'  => new external_value(PARAM_ALPHANUMEXT, 'option name'),
                             'value' => new external_value(PARAM_RAW, 'option value')
                         )
-                    ), 'method options'),
+                    ), 'method options', VALUE_DEFAULT, array()),
             )
         );
     }
@@ -136,7 +136,7 @@ class core_enrol_external extends external_api {
         require_once($CFG->dirroot . "/user/lib.php");
 
         $params = self::validate_parameters(
-            self::get_users_by_course_id_parameters(),
+            self::get_enrolled_users_parameters(),
             array(
                 'courseid'=>$courseid,
                 'options'=>$options
index 63fb406..156e4e7 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
index 39516e1..ac4a5cf 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
@@ -45,7 +44,7 @@ class enrol_guest_plugin extends enrol_plugin {
      */
     public function get_info_icons(array $instances) {
         foreach ($instances as $instance) {
-            if ($instance->password) {
+            if ($instance->password !== '') {
                 return array(new pix_icon('withpassword', get_string('pluginname', 'enrol_guest'), 'enrol_guest'));
             } else {
                 return array(new pix_icon('withoutpassword', get_string('pluginname', 'enrol_guest'), 'enrol_guest'));
@@ -68,17 +67,27 @@ class enrol_guest_plugin extends enrol_plugin {
      * calling code has to make sure the plugin and instance are active.
      *
      * @param stdClass $instance course enrol instance
-     * @param stdClass $user record
      * @return bool|int false means no guest access, integer means end of cached time
      */
     public function try_guestaccess(stdClass $instance) {
         global $USER, $CFG;
 
-        if (empty($instance->password)) {
+        $allow = false;
+
+        if ($instance->password === '') {
+            $allow = true;
+
+        } else if (isset($USER->enrol_guest_passwords[$instance->id])) { // this is a hack, ideally we should not add stuff to $USER...
+            if ($USER->enrol_guest_passwords[$instance->id] === $instance->password) {
+                $allow = true;
+            }
+        }
+
+        if ($allow) {
             // Temporarily assign them some guest role for this context
             $context = get_context_instance(CONTEXT_COURSE, $instance->courseid);
             load_temp_course_role($context, $CFG->guestroleid);
-            return ENROL_REQUIRE_LOGIN_CACHE_PERIOD + time();
+            return ENROL_MAX_TIMESTAMP;
         }
 
         return false;
@@ -115,7 +124,12 @@ class enrol_guest_plugin extends enrol_plugin {
     public function enrol_page_hook(stdClass $instance) {
         global $CFG, $OUTPUT, $SESSION, $USER;
 
-        if (empty($instance->password)) {
+        if ($instance->password === '') {
+            return null;
+        }
+
+        if (isset($USER->enrol['tempguest'][$instance->courseid]) and $USER->enrol['tempguest'][$instance->courseid] > time()) {
+            // no need to show the guest access when user can already enter course as guest
             return null;
         }
 
@@ -125,13 +139,14 @@ class enrol_guest_plugin extends enrol_plugin {
 
         if ($instance->id == $instanceid) {
             if ($data = $form->get_data()) {
-                // set up primitive require_login() caching
-                unset($USER->enrol['enrolled'][$instance->courseid]);
-                $USER->enrol['tempguest'][$instance->courseid] = time() + 60*60*8; // 8 hours access before asking for pw again
-
                 // add guest role
                 $context = get_context_instance(CONTEXT_COURSE, $instance->courseid);
+                $USER->enrol_guest_passwords[$instance->id] = $data->guestpassword; // this is a hack, ideally we should not add stuff to $USER...
+                if (isset($USER->enrol['tempguest'][$instance->courseid])) {
+                    remove_temp_course_roles($context);
+                }
                 load_temp_course_role($context, $CFG->guestroleid);
+                $USER->enrol['tempguest'][$instance->courseid] = ENROL_MAX_TIMESTAMP;
 
                 // go to the originally requested page
                 if (!empty($SESSION->wantsurl)) {
@@ -271,6 +286,10 @@ class enrol_guest_plugin extends enrol_plugin {
                         }
                     }
                     $this->add_instance($course, $fields);
+                } else {
+                    if ($this->get_config('defaultenrol')) {
+                        $this->add_default_instance($course);
+                    }
                 }
             } else {
                 $instances = $DB->get_records('enrol', array('courseid'=>$course->id, 'enrol'=>'guest'));
@@ -278,12 +297,21 @@ class enrol_guest_plugin extends enrol_plugin {
                     $i = $instance->id;
 
                     if (isset($data->{'enrol_guest_status_'.$i})) {
+                        $reset = ($instance->status != $data->{'enrol_guest_status_'.$i});
+
                         $instance->status       = $data->{'enrol_guest_status_'.$i};
                         $instance->timemodified = time();
                         if ($instance->status == ENROL_INSTANCE_ENABLED) {
+                            if ($instance->password !== $data->{'enrol_guest_password_'.$i}) {
+                                $reset = true;
+                            }
                             $instance->password = $data->{'enrol_guest_password_'.$i};
                         }
                         $DB->update_record('enrol', $instance);
+
+                        if ($reset) {
+                            $context->mark_dirty();
+                        }
                     }
                 }
             }
index de6179e..27e1ede 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
@@ -59,7 +58,7 @@ class enrol_guest_enrol_form extends moodleform {
         $errors = parent::validation($data, $files);
         $instance = $this->instance;
 
-        if ($instance->password) {
+        if ($instance->password !== '') {
             if ($data['guestpassword'] !== $instance->password) {
                 $plugin = enrol_get_plugin('guest');
                 if ($plugin->get_config('showhint')) {
index 2a8d5f9..a9376cb 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
index 90659ca..8e12a37 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,4 +25,5 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version = 2010081800;
+$plugin->version = 2011110600;
+$plugin->component = 'enrol_guest';
index 7f09d88..fe5e74b 100644 (file)
@@ -98,6 +98,7 @@ if ($canconfig and $action and confirm_sesskey()) {
 
             if ($confirm) {
                 $plugin->delete_instance($instance);
+                $context->mark_dirty(); // invalidate all enrol caches
                 redirect($PAGE->url);
             }
 
@@ -115,6 +116,7 @@ if ($canconfig and $action and confirm_sesskey()) {
             if ($instance->status == ENROL_INSTANCE_ENABLED) {
                 $instance->status = ENROL_INSTANCE_DISABLED;
                 $DB->update_record('enrol', $instance);
+                $context->mark_dirty(); // invalidate all enrol caches
                 redirect($PAGE->url);
             }
 
@@ -123,6 +125,7 @@ if ($canconfig and $action and confirm_sesskey()) {
             if ($instance->status == ENROL_INSTANCE_DISABLED) {
                 $instance->status = ENROL_INSTANCE_ENABLED;
                 $DB->update_record('enrol', $instance);
+                $context->mark_dirty(); // invalidate all enrol caches
                 redirect($PAGE->url);
             }
         }
index aa2edd1..24079a9 100644 (file)
@@ -70,12 +70,18 @@ if ($mform->is_cancelled()) {
 
 } else if ($data = $mform->get_data()) {
     if ($instance->id) {
+        $reset = ($instance->status != $data->status);
+
         $instance->status       = $data->status;
         $instance->enrolperiod  = $data->enrolperiod;
         $instance->roleid       = $data->roleid;
         $instance->timemodified = time();
         $DB->update_record('enrol', $instance);
 
+        if ($reset) {
+            $context->mark_dirty();
+        }
+
     } else {
         $fields = array('status'=>$data->status, 'enrolperiod'=>$data->enrolperiod, 'roleid'=>$data->roleid);
         $plugin->add_instance($course, $fields);
index fdac861..91c89e2 100644 (file)
@@ -65,6 +65,8 @@ if ($mform->is_cancelled()) {
 
 } else if ($data = $mform->get_data()) {
     if ($instance->id) {
+        $reset = ($instance->status != $data->status);
+
         $instance->status         = $data->status;
         $instance->name           = $data->name;
         $instance->cost           = $data->cost;
@@ -76,6 +78,10 @@ if ($mform->is_cancelled()) {
         $instance->timemodified   = time();
         $DB->update_record('enrol', $instance);
 
+        if ($reset) {
+            $context->mark_dirty();
+        }
+
     } else {
         $fields = array('status'=>$data->status, 'name'=>$data->name, 'cost'=>$data->cost, 'currency'=>$data->currency, 'roleid'=>$data->roleid,
                         'enrolperiod'=>$data->enrolperiod, 'enrolstartdate'=>$data->enrolstartdate, 'enrolenddate'=>$data->enrolenddate);
index 66d2212..4affcb7 100644 (file)
@@ -65,6 +65,8 @@ if ($mform->is_cancelled()) {
 
 } else if ($data = $mform->get_data()) {
     if ($instance->id) {
+        $reset = ($instance->status != $data->status);
+
         $instance->status         = $data->status;
         $instance->name           = $data->name;
         $instance->password       = $data->password;
@@ -80,6 +82,10 @@ if ($mform->is_cancelled()) {
         $instance->timemodified   = time();
         $DB->update_record('enrol', $instance);
 
+        if ($reset) {
+            $context->mark_dirty();
+        }
+
     } else {
         $fields = array('status'=>$data->status, 'name'=>$data->name, 'password'=>$data->password, 'customint1'=>$data->customint1, 'customint2'=>$data->customint2,
                         'customint3'=>$data->customint3, 'customint4'=>$data->customint4, 'customtext1'=>$data->customtext1,
index 55eecf1..14272ca 100644 (file)
@@ -1,9 +1,16 @@
 This files describes API changes in /enrol/* - plugins,
 information provided here is intended especially for developers.
 
+
 === 2.2 ===
 
 required changes in code:
 * load_temp_role() is deprecated, use load_temp_course_role() instead, temp role not loaded
 * remove_temp_role() is deprecated, use remove_temp_course_roles() instead
 * 'user_unenrol_modified' event was renamed to 'user_enrol_modified'
+
+
+=== 2.0 ===
+
+required changes in code:
+* enrolment plugins need to be rewritten to use new API - see inline phpdocs and official plugins
\ No newline at end of file
index fcb3a95..14d9d33 100644 (file)
@@ -835,6 +835,8 @@ $string['registration'] = 'Registration';
 $string['releasenoteslink'] = 'For information about this version of Moodle, please see the online <a target="_blank" href="{$a}">Release Notes</a>';
 $string['rememberusername'] = 'Remember username';
 $string['rememberusername_desc'] = 'Enable if you want to store permanent cookies with usernames during user login. Permanent cookies may be considered a privacy issue if used without consent.';
+$string['reportsmanage'] = 'Manage reports';
+$string['reportsdeleteconfirm'] = 'You are about to completely delete the report \'{$a}\'. This will completely delete everything in the database associated with this plugin. Are you SURE you want to continue?';
 $string['requiredentrieschanged'] = '<strong>IMPORTANT - PLEASE READ<br/>(This warning message will only be displayed during this upgrade)</strong><br/>Due to a bug fix, the behaviour of database activities using the \'Required entries\' and \'Required entries before viewing settings\' settings will change. A more detailed explanation of the changes can be read on <a href="http://moodle.org/mod/forum/discuss.php?d=110928" target="_blank">the database module forum</a>. The expected behavior of these settings can also be read on <a href="http://docs.moodle.org/en/Adding/editing_a_database#Required_entries" target="_blank">Moodle Docs</a>.
 <br/><br/>This change affects the following databases in your system: (Please save this list now, and after the upgrade, check that these activities still work the way that the teacher intends.)<br/><strong>{$a->text}</strong><br/>';
 $string['requiremodintro'] = 'Require activity description';
index 595c8a1..25c5718 100644 (file)
@@ -92,6 +92,8 @@ $string['confirmcancelquestion'] = 'Are you sure you wish to cancel?
 Any information you have entered will be lost.';
 $string['confirmcancelyes'] = 'Cancel';
 $string['confirmcancelno'] = 'Stay';
+$string['confirmnewcoursecontinue'] = 'New course warning';
+$string['confirmnewcoursecontinuequestion'] = 'A temporary (hidden) course will be created by the course restoration process. To abort restoration click cancel. Do not close the browser while restoring.';
 $string['coursecategory'] = 'Category the course will be restored into';
 $string['courseid'] = 'Original ID';
 $string['coursesettings'] = 'Course settings';
index b9bcdf0..5157014 100644 (file)
@@ -28,6 +28,7 @@ $string['allday'] = 'All day';
 $string['calendar'] = 'Calendar';
 $string['calendarheading'] = '{$a} Calendar';
 $string['calendarpreferences'] = 'Calendar preferences';
+$string['calendarurl'] = 'Calendar URL: {$a}';
 $string['clickhide'] = 'click to hide';
 $string['clickshow'] = 'click to show';
 $string['commontasks'] = 'Options';
index cae5f9c..bb9b476 100644 (file)
@@ -159,6 +159,7 @@ $string['notinxmlrpcserver'] = 'Attempt to access the MNet remote client, not du
 $string['notmoodleapplication'] = 'WARNING: This is not a Moodle application, so some of the inspection methods may not work properly.';
 $string['notPEM'] = 'This key is not in PEM format. It will not work.';
 $string['notpermittedtojump'] = 'You do not have permission to begin a remote session from this Moodle server.';
+$string['notpermittedtojumpas'] = 'You can\'t begin a remote session while you are logged in as another user.';
 $string['notpermittedtoland'] = 'You do not have permission to begin a remote session.';
 $string['off'] = 'Off';
 $string['on'] = 'On';
index 446e8d7..52caf4a 100644 (file)
@@ -902,7 +902,6 @@ $string['liketologin'] = 'Would you like to log in now with a full user account?
 $string['list'] = 'List';
 $string['listfiles'] = 'List of files in {$a}';
 $string['listofallpeople'] = 'List of all people';
-$string['livelogs'] = 'Live logs from the past hour';
 $string['local'] = 'Local';
 $string['localplugindeleteconfirm'] = 'You are about to completely delete the local plugin \'{$a}\'. This will completely delete everything in the database associated with this plugin. Are you SURE you want to continue?';
 $string['localplugins'] = 'Local plugins';
@@ -1175,7 +1174,7 @@ $string['notice'] = 'Notice';
 $string['noticenewerbackup'] = 'This backup file has been created with Moodle {$a->backuprelease} ({$a->backupversion}) and it\'s newer than your currently installed Moodle {$a->serverrelease} ({$a->serverversion}). This could cause some inconsistencies because backwards compatibility of backup files cannot be guaranteed.';
 $string['notifications'] = 'Notifications';
 $string['notifyloginfailuresmessage'] = '{$a->time}, IP: {$a->ip}, User: {$a->info}';
-$string['notifyloginfailuresmessageend'] = 'You can view these logs at {$a}/course/report/log/index.php?id=1&amp;chooselog=1&amp;modid=site_errors.';
+$string['notifyloginfailuresmessageend'] = 'You can view these logs at {$a}/report/log/index.php?id=1&amp;chooselog=1&amp;modid=site_errors.';
 $string['notifyloginfailuresmessagestart'] = 'Here is a list of failed login attempts at {$a} since you were last notified';
 $string['notifyloginfailuressubject'] = '{$a} :: Failed logins notification';
 $string['notincluded'] = 'Not included';
index 7d196a0..62cdfd2 100644 (file)
@@ -31,6 +31,7 @@ $string['page-course-report-x'] = 'Any course report';
 $string['page-mod-x'] = 'Any activity module page';
 $string['page-mod-x-view'] = 'Any main activity module page';
 $string['page-my-index'] = 'My home page';
+$string['page-report-x'] = 'Any report page';
 $string['page-site-index'] = 'The front page only';
 $string['page-site-x'] = 'Any top-level site page';
 $string['page-user-view'] = 'Only user profile pages';
index 74a3eb2..45ded80 100644 (file)
@@ -40,6 +40,7 @@ $string['plugindisable'] = 'Disable';
 $string['plugindisabled'] = 'Disabled';
 $string['pluginenable'] = 'Enable';
 $string['pluginenabled'] = 'Enabled';
+$string['requiredby'] = 'Required by: {$a}';
 $string['requires'] = 'Requires';
 $string['rootdir'] = 'Directory';
 $string['settings'] = 'Settings';
@@ -97,7 +98,7 @@ $string['type_qformat_plural'] = 'Question import/export formats';
 $string['type_qtype'] = 'Question type';
 $string['type_qtype_plural'] = 'Question types';
 $string['type_report'] = 'Site report';
-$string['type_report_plural'] = 'Site reports';
+$string['type_report_plural'] = 'Reports';
 $string['type_repository'] = 'Repository';
 $string['type_repository_plural'] = 'Repositories';
 $string['type_theme'] = 'Theme';
index 4479379..013d1ad 100644 (file)
@@ -1122,7 +1122,9 @@ function load_all_capabilities() {
 
     // Clear to force a refresh
     unset($USER->mycourses);
-    unset($USER->enrol);
+
+    // init/reset internal enrol caches - active course enrolments and temp access
+    $USER->enrol = array('enrolled'=>array(), 'tempguest'=>array());
 }
 
 /**
@@ -1172,15 +1174,18 @@ function reload_all_capabilities() {
  * @return void
  */
 function load_temp_course_role(context_course $coursecontext, $roleid) {
-    global $USER;
-
-    //TODO: this gets removed if there are any dirty contexts, we should probably store list of these temp roles somewhere (skodak)
+    global $USER, $SITE;
 
     if (empty($roleid)) {
         debugging('invalid role specified in load_temp_course_role()');
         return;
     }
 
+    if ($coursecontext->instanceid == $SITE->id) {
+        debugging('Can not use temp roles on the frontpage');
+        return;
+    }
+
     if (!isset($USER->access)) {
         load_all_capabilities();
     }
@@ -1207,7 +1212,12 @@ function load_temp_course_role(context_course $coursecontext, $roleid) {
  * @return void
  */
 function remove_temp_course_roles(context_course $coursecontext) {
-    global $DB, $USER;
+    global $DB, $USER, $SITE;
+
+    if ($coursecontext->instanceid == $SITE->id) {
+        debugging('Can not use temp roles on the frontpage');
+        return;
+    }
 
     if (empty($USER->access['ra'][$coursecontext->path])) {
         //no roles here, weird
@@ -1877,6 +1887,8 @@ function is_viewing(context $context, $user = null, $withcapability = '') {
  * Returns true if user is enrolled (is participating) in course
  * this is intended for students and teachers.
  *
+ * Since 2.2 the result for active enrolments and current user are cached.
+ *
  * @param context $context
  * @param int|stdClass $user, if null $USER is used, otherwise user object or id expected
  * @param string $withcapability extra capability name
@@ -1907,32 +1919,35 @@ function is_enrolled(context $context, $user = null, $withcapability = '', $only
     if ($coursecontext->instanceid == SITEID) {
         // everybody participates on frontpage
     } else {
-        if ($onlyactive) {
-            $sql = "SELECT ue.*
-                      FROM {user_enrolments} ue
-                      JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid)
-                      JOIN {user} u ON u.id = ue.userid
-                     WHERE ue.userid = :userid AND ue.status = :active AND e.status = :enabled AND u.deleted = 0";
-            $params = array('enabled'=>ENROL_INSTANCE_ENABLED, 'active'=>ENROL_USER_ACTIVE, 'userid'=>$userid, 'courseid'=>$coursecontext->instanceid);
-            // this result should be very small, better not do the complex time checks in sql for now ;-)
-            $enrolments = $DB->get_records_sql($sql, $params);
-            $now = time();
-            // make sure the enrol period is ok
-            $result = false;
-            foreach ($enrolments as $e) {
-                if ($e->timestart > $now) {
-                    continue;
+        // try cached info first - the enrolled flag is set only when active enrolment present
+        if ($USER->id == $userid) {
+            $coursecontext->reload_if_dirty();
+            if (isset($USER->enrol['enrolled'][$coursecontext->instanceid])) {
+                if ($USER->enrol['enrolled'][$coursecontext->instanceid] > time()) {
+                    return true;
                 }
-                if ($e->timeend and $e->timeend < $now) {
-                    continue;
-                }
-                $result = true;
-                break;
             }
-            if (!$result) {
+        }
+
+        if ($onlyactive) {
+            // look for active enrolments only
+            $until = enrol_get_enrolment_end($coursecontext->instanceid, $userid);
+
+            if ($until === false) {
                 return false;
             }
 
+            if ($USER->id == $userid) {
+                if ($until == 0) {
+                    $until = ENROL_MAX_TIMESTAMP;
+                }
+                $USER->enrol['enrolled'][$coursecontext->instanceid] = $until;
+                if (isset($USER->enrol['tempguest'][$coursecontext->instanceid])) {
+                    unset($USER->enrol['tempguest'][$coursecontext->instanceid]);
+                    remove_temp_course_roles($coursecontext);
+                }
+            }
+
         } else {
             // any enrolment is good for us here, even outdated, disabled or inactive
             $sql = "SELECT 'x'
@@ -2031,57 +2046,22 @@ function can_access_course(stdClass $course, $user = null, $withcapability = '',
 
     // === from here we deal only with $USER ===
 
-    // verify our caches
-    if (!isset($USER->enrol)) {
-        /**
-         * These flags within the $USER object should NEVER be used outside of this
-         * function can_access_course and the function require_login.
-         * Doing so WILL break future versions!!!!
-         */
-        $USER->enrol = array();
-        $USER->enrol['enrolled'] = array();
-        $USER->enrol['tempguest'] = array();
-    }
+    $coursecontext->reload_if_dirty();
+
     if (isset($USER->enrol['enrolled'][$course->id])) {
-        if ($USER->enrol['enrolled'][$course->id] == 0) {
-            return true;
-        } else if ($USER->enrol['enrolled'][$course->id] > time()) {
+        if ($USER->enrol['enrolled'][$course->id] > time()) {
             return true;
         }
     }
     if (isset($USER->enrol['tempguest'][$course->id])) {
-        if ($USER->enrol['tempguest'][$course->id] == 0) {
-            return true;
-        } else if ($USER->enrol['tempguest'][$course->id] > time()) {
+        if ($USER->enrol['tempguest'][$course->id] > time()) {
             return true;
         }
     }
 
-    if (is_enrolled($coursecontext, $USER, '', true)) {
-        // active participants may always access
-        // TODO: refactor this into some new function
-        $now = time();
-        $sql = "SELECT MAX(ue.timeend)
-                  FROM {user_enrolments} ue
-                  JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid)
-                  JOIN {user} u ON u.id = ue.userid
-                 WHERE ue.userid = :userid AND ue.status = :active AND e.status = :enabled AND u.deleted = 0
-                       AND ue.timestart < :now1 AND (ue.timeend = 0 OR ue.timeend > :now2)";
-        $params = array('enabled'=>ENROL_INSTANCE_ENABLED, 'active'=>ENROL_USER_ACTIVE,
-                        'userid'=>$USER->id, 'courseid'=>$coursecontext->instanceid, 'now1'=>$now, 'now2'=>$now);
-        $until = $DB->get_field_sql($sql, $params);
-        if (!$until or $until > time() + ENROL_REQUIRE_LOGIN_CACHE_PERIOD) {
-            $until = time() + ENROL_REQUIRE_LOGIN_CACHE_PERIOD;
-        }
-
-        $USER->enrol['enrolled'][$course->id] = $until;
-
-        // remove traces of previous temp guest access
-        remove_temp_course_roles($coursecontext);
-
+    if (is_enrolled($coursecontext, $USER, '', $onlyactive)) {
         return true;
     }
-    unset($USER->enrol['enrolled'][$course->id]);
 
     // if not enrolled try to gain temporary guest access
     $instances = $DB->get_records('enrol', array('courseid'=>$course->id, 'status'=>ENROL_INSTANCE_ENABLED), 'sortorder, id ASC');
@@ -2090,14 +2070,17 @@ function can_access_course(stdClass $course, $user = null, $withcapability = '',
         if (!isset($enrols[$instance->enrol])) {
             continue;
         }
-        // Get a duration for the guestaccess, a timestamp in the future or false.
+        // Get a duration for the guest access, a timestamp in the future, 0 (always) or false.
         $until = $enrols[$instance->enrol]->try_guestaccess($instance);
-        if ($until !== false) {
+        if ($until !== false and $until > time()) {
             $USER->enrol['tempguest'][$course->id] = $until;
             return true;
         }
     }
-    unset($USER->enrol['tempguest'][$course->id]);
+    if (isset($USER->enrol['tempguest'][$course->id])) {
+        unset($USER->enrol['tempguest'][$course->id]);
+        remove_temp_course_roles($coursecontext);
+    }
 
     return false;
 }
index d91fa51..1725bea 100644 (file)
@@ -1623,7 +1623,10 @@ function generate_page_type_patterns($pagetype, $parentcontext = null, $currentc
                     $libfile = $directory.'/lib.php';
                     if (file_exists($libfile)) {
                         require_once($libfile);
-                        $function = $pluginname.'_page_type_list';
+                        $function = $possiblecomponent.'_'.$pluginname.'_page_type_list';
+                        if (!function_exists($function)) {
+                            $function = $pluginname.'_page_type_list';
+                        }
                         if (function_exists($function)) {
                             if ($patterns = $function($pagetype, $parentcontext, $currentcontext)) {
                                 break;
index af27c6f..49e14d7 100644 (file)
@@ -89,7 +89,7 @@ class completion_criteria_unenrol extends completion_criteria {
      * @return  string
      */
     public function get_title() {
-        return get_string('unenrol');
+        return get_string('unenrol', 'enrol');
     }
 
     /**
@@ -107,7 +107,7 @@ class completion_criteria_unenrol extends completion_criteria {
      * @return  string
      */
     public function get_type_title() {
-        return get_string('unenrol');
+        return get_string('unenrol', 'enrol');
     }
 
     /**
index 5ddf736..53c8010 100644 (file)
@@ -39,9 +39,12 @@ define('ENROL_USER_ACTIVE', 0);
 /** User participation in course is suspended (used in user_enrolments->status) */
 define('ENROL_USER_SUSPENDED', 1);
 
-/** Enrol info is cached for this number of seconds in require_login() */
+/** @deprecated - enrol caching was reworked, use ENROL_MAX_TIMESTAMP instead */
 define('ENROL_REQUIRE_LOGIN_CACHE_PERIOD', 1800);
 
+/** The timestamp indicating forever */
+define('ENROL_MAX_TIMESTAMP', 2147483647);
+
 /** When user disappears from external source, the enrolment is completely removed */
 define('ENROL_EXT_REMOVED_UNENROL', 0);
 
@@ -72,7 +75,7 @@ define('ENROL_EXT_REMOVED_SUSPENDNOROLES', 3);
 
 /**
  * Returns instances of enrol plugins
- * @param bool $enable return enabled only
+ * @param bool $enabled return enabled only
  * @return array of enrol plugins name=>instance
  */
 function enrol_get_plugins($enabled) {
@@ -804,7 +807,7 @@ function enrol_user_delete($user) {
 
 /**
  * Called when course is about to be deleted.
- * @param stdClass $object
+ * @param stdClass $course
  * @return void
  */
 function enrol_course_delete($course) {
@@ -885,6 +888,88 @@ function enrol_selfenrol_available($courseid) {
     return $result;
 }
 
+/**
+ * This function returns the end of current active user enrolment.
+ *
+ * It deals correctly with multiple overlapping user enrolments.
+ *
+ * @param int $courseid
+ * @param int $userid
+ * @return int|bool timestamp when active enrolment ends, false means no active enrolment now, 0 means never
+ */
+function enrol_get_enrolment_end($courseid, $userid) {
+    global $DB;
+
+    $sql = "SELECT ue.*
+              FROM {user_enrolments} ue
+              JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid)
+              JOIN {user} u ON u.id = ue.userid
+             WHERE ue.userid = :userid AND ue.status = :active AND e.status = :enabled AND u.deleted = 0";
+    $params = array('enabled'=>ENROL_INSTANCE_ENABLED, 'active'=>ENROL_USER_ACTIVE, 'userid'=>$userid, 'courseid'=>$courseid);
+
+    if (!$enrolments = $DB->get_records_sql($sql, $params)) {
+        return false;
+    }
+
+    $changes = array();
+
+    foreach ($enrolments as $ue) {
+        $start = (int)$ue->timestart;
+        $end = (int)$ue->timeend;
+        if ($end != 0 and $end < $start) {
+            debugging('Invalid enrolment start or end in user_enrolment id:'.$ue->id);
+            continue;
+        }
+        if (isset($changes[$start])) {
+            $changes[$start] = $changes[$start] + 1;
+        } else {
+            $changes[$start] = 1;
+        }
+        if ($end === 0) {
+            // no end
+        } else if (isset($changes[$end])) {
+            $changes[$end] = $changes[$end] - 1;
+        } else {
+            $changes[$end] = -1;
+        }
+    }
+
+    // let's sort then enrolment starts&ends and go through them chronologically,
+    // looking for current status and the next future end of enrolment
+    ksort($changes);
+
+    $now = time();
+    $current = 0;
+    $present = null;
+
+    foreach ($changes as $time => $change) {
+        if ($time > $now) {
+            if ($present === null) {
+                // we have just went past current time
+                $present = $current;
+                if ($present < 1) {
+                    // no enrolment active
+                    return false;
+                }
+            }
+            if ($present !== null) {
+                // we are already in the future - look for possible end
+                if ($current + $change < 1) {
+                    return $time;
+                }
+            }
+        }
+        $current += $change;
+    }
+
+    if ($current > 0) {
+        return 0;
+    } else {
+        return false;
+    }
+}
+
+
 /**
  * All enrol plugins should be based on this class,
  * this is also the main source of documentation.
@@ -1051,7 +1136,6 @@ abstract class enrol_plugin {
      * This should return either a timestamp in the future or false.
      *
      * @param stdClass $instance course enrol instance
-     * @param stdClass $user record
      * @return bool|int false means not enrolled, integer means timeend
      */
     public function try_autoenrol(stdClass $instance) {
@@ -1067,7 +1151,6 @@ abstract class enrol_plugin {
      * This should return either a timestamp in the future or false.
      *
      * @param stdClass $instance course enrol instance
-     * @param stdClass $user record
      * @return bool|int false means no guest access, integer means timeend
      */
     public function try_guestaccess(stdClass $instance) {
@@ -1142,10 +1225,12 @@ abstract class enrol_plugin {
             $ue->courseid  = $courseid;
             $ue->enrol     = $name;
             events_trigger('user_enrol_modified', $ue);
+            // resets current enrolment caches
+            $context->mark_dirty();
         }
 
         if ($roleid) {
-            // this must be done after the enrolment event so that the role_assigned event is trigerred aftwerwards
+            // this must be done after the enrolment event so that the role_assigned event is triggered afterwards
             if ($this->roles_protected()) {
                 role_assign($roleid, $userid, $context->id, 'enrol_'.$name, $instance->id);
             } else {
@@ -1153,7 +1238,7 @@ abstract class enrol_plugin {
      &