]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17372 admin reports: Added full plugin support for admin reports; added specail...
authorskodak <skodak>
Wed, 26 Nov 2008 19:27:39 +0000 (19:27 +0000)
committerskodak <skodak>
Wed, 26 Nov 2008 19:27:39 +0000 (19:27 +0000)
21 files changed:
admin/report/backups/index.php
admin/report/courseoverview/index.php
admin/report/courseoverview/settings.php [new file with mode: 0644]
admin/report/log/index.php
admin/report/log/settings.php [new file with mode: 0644]
admin/report/questioninstances/index.php
admin/report/questioninstances/settings.php [new file with mode: 0644]
admin/report/stats/index.php
admin/report/stats/settings.php
admin/report/unittest/db/access.php [new file with mode: 0644]
admin/report/unittest/dbtest.php
admin/report/unittest/index.php
admin/report/unittest/settings.php
admin/report/unittest/version.php [new file with mode: 0644]
admin/settings/report.php [new file with mode: 0644]
admin/settings/top.php
admin/settings/users.php
lang/en_utf8/report_unittest.php [new file with mode: 0644]
lib/accesslib.php
lib/adminlib.php
version.php

index 612501c4ddd85509b5f5233f1d033345b8d5a45f..d380cbb6d75bd3cfee8918bfe45ac0e529beaf03 100644 (file)
@@ -5,13 +5,10 @@
     require_once($CFG->libdir.'/adminlib.php');
     require_once($CFG->dirroot.'/backup/lib.php');
 
-    admin_externalpage_setup('reportbackups');
-
-    admin_externalpage_print_header();
-
     $courseid = optional_param('courseid', 0, PARAM_INT);
 
-    require_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM));
+    admin_externalpage_setup('reportbackups');
+    admin_externalpage_print_header();
 
 /// Scheduled backups are disabled by the server admin
     if (!empty($CFG->disablescheduledbackups)) {
index 6e0792f0e47425aaf3a2fa6e7dee322890789a45..712b32adc1ee9ac7fb6aae640e0a9d876f40f28f 100644 (file)
@@ -4,15 +4,12 @@
     require_once($CFG->dirroot.'/lib/statslib.php');
     require_once($CFG->libdir.'/adminlib.php');
 
-    admin_externalpage_setup('reportcourseoverview');
-
-    admin_externalpage_print_header();
-
     $report     = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT);
     $time       = optional_param('time', 0, PARAM_INT);
     $numcourses = optional_param('numcourses', 20, PARAM_INT);
 
-    require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM));  // needed?
+    admin_externalpage_setup('reportcourseoverview');
+    admin_externalpage_print_header();
 
     if (empty($CFG->enablestats)) {
         redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
diff --git a/admin/report/courseoverview/settings.php b/admin/report/courseoverview/settings.php
new file mode 100644 (file)
index 0000000..cb54298
--- /dev/null
@@ -0,0 +1,3 @@
+<?php  // $Id$
+$ADMIN->add('reports', new admin_externalpage('reportcourseoverview', get_string('courseoverview', 'admin'), "$CFG->wwwroot/$CFG->admin/report/courseoverview/index.php",'moodle/site:viewreports'));
+?>
\ No newline at end of file
index df808f31b572d08d6891ef3feed08ba4eb998973..2878ee76c0da422ae380cc07c19c96a80e9a55fe 100644 (file)
@@ -6,7 +6,6 @@
     require_once($CFG->libdir.'/adminlib.php');
 
     admin_externalpage_setup('reportlog');
-
     admin_externalpage_print_header();
 
 
diff --git a/admin/report/log/settings.php b/admin/report/log/settings.php
new file mode 100644 (file)
index 0000000..1f11339
--- /dev/null
@@ -0,0 +1,3 @@
+<?php  // $Id$
+$ADMIN->add('reports', new admin_externalpage('reportlog', get_string('log', 'admin'), "$CFG->wwwroot/$CFG->admin/report/log/index.php",'moodle/site:viewreports'));
+?>
\ No newline at end of file
index 598d4f4eb12d1130c6bcd75b025067e8ac6fb387..d4852422ca447285462c48681afc2b680c2ec586 100644 (file)
@@ -11,21 +11,16 @@ require_once(dirname(__FILE__).'/../../../config.php');
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/questionlib.php');
 
-// Check permissions.
-require_login();
-$systemcontext = get_context_instance(CONTEXT_SYSTEM);
-require_capability('moodle/site:viewreports', $systemcontext);
-
 // Get URL parameters.
 $requestedqtype = optional_param('qtype', '', PARAM_SAFEDIR);
 
-// Log.
-add_to_log(SITEID, "admin", "report questioninstances", "report/questioninstances/index.php?qtype=$requestedqtype", $requestedqtype);
-
-// Print the header.
+// Print the header & check permissions.
 admin_externalpage_setup('reportquestioninstances');
 admin_externalpage_print_header();
 
+// Log.
+add_to_log(SITEID, "admin", "report questioninstances", "report/questioninstances/index.php?qtype=$requestedqtype", $requestedqtype);
+
 // Prepare the list of capabilites to choose from
 $qtypechoices = array();
 foreach ($QTYPES as $qtype) {
diff --git a/admin/report/questioninstances/settings.php b/admin/report/questioninstances/settings.php
new file mode 100644 (file)
index 0000000..fea0d3c
--- /dev/null
@@ -0,0 +1,3 @@
+<?php  // $Id$
+$ADMIN->add('reports', new admin_externalpage('reportquestioninstances', get_string('questioninstances', 'report_questioninstances'), "$CFG->wwwroot/$CFG->admin/report/questioninstances/index.php", 'moodle/site:viewreports'));
+?>
\ No newline at end of file
index 86ce469ff0b6ee3502efc977e7133a1fb71d227a..8f0e86853ee32c940bdd050ef88df72a84d4a94f 100644 (file)
@@ -6,11 +6,6 @@
 
     require_once($CFG->libdir.'/adminlib.php');
 
-    admin_externalpage_setup('reportstats');
-
-    admin_externalpage_print_header();
-
-
     $courseid = optional_param('course', SITEID, PARAM_INT);
     $report   = optional_param('report', 0, PARAM_INT);
     $time     = optional_param('time', 0, PARAM_INT);
     $userid   = optional_param('userid', 0, PARAM_INT);
     $roleid   = 0;
 
+    admin_externalpage_setup('reportstats');
+    admin_externalpage_print_header();
+
+    if (empty($CFG->enablestats)) {
+        redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
+    }
+
     if ($report > 50) {
         $roleid = substr($report,1);
         $report = 5;
         }
     }
 
-    require_login();
-
-    if (empty($CFG->enablestats)) {
-        redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
-    }
-
-    require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM));
-
     add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
 
     stats_check_uptodate($course->id);
index beb5c038bb43309a9a83e74b0ea3aebd37794696..5eca48c38efc8b921ae80d0d79bf59b804c99fa8 100644 (file)
@@ -1,5 +1,3 @@
 <?php  // $Id$
-if (!empty($CFG->enablestats)) {
-    $ADMIN->add('reports', new admin_externalpage('reportstats', get_string('stats', 'admin'), "$CFG->wwwroot/$CFG->admin/report/stats/index.php",'moodle/site:viewreports'));
-}
+$ADMIN->add('reports', new admin_externalpage('reportstats', get_string('stats', 'admin'), "$CFG->wwwroot/$CFG->admin/report/stats/index.php",'moodle/site:viewreports'));
 ?>
\ No newline at end of file
diff --git a/admin/report/unittest/db/access.php b/admin/report/unittest/db/access.php
new file mode 100644 (file)
index 0000000..dd9915f
--- /dev/null
@@ -0,0 +1,40 @@
+<?php  // $Id$
+
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// 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                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+$report_unittest_capabilities = array(
+
+    'report/unittest:view' => array(
+        'riskbitmask' => RISK_DATALOSS,
+        'captype' => 'read',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'legacy' => array(
+            'admin' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:config',
+    )
+);
+
+?>
index 506b9d005134360475cc5dd26e8a641d84016b5c..dd58e152354faaade31e881aca2eba9c0d6c3616 100644 (file)
@@ -11,12 +11,13 @@ require_once($CFG->libdir.'/simpletestlib.php');
 require_once('ex_simple_test.php');
 require_once('ex_reporter.php');
 
-require_login();
-require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
-
 $showpasses = optional_param('showpasses', 0, PARAM_BOOL);
 $selected   = optional_param('selected', array(), PARAM_INT);
 
+// Print the header and check access.
+admin_externalpage_setup('reportdbtest');
+admin_externalpage_print_header();
+
 global $UNITTEST;
 $UNITTEST = new object();
 
@@ -27,9 +28,6 @@ if (!data_submitted()) {
     }
 }
 
-// Print the header.
-admin_externalpage_setup('reportdbtest');
-admin_externalpage_print_header();
 
 $dbinfos     = array();
 $tests       = array();
index 10adcfd6b9b368adb8b924eb7ec7aaadf0099cdb..47a350f900f041705f5bd859ed6d33307643b38b 100644 (file)
@@ -16,12 +16,6 @@ require_once($CFG->libdir.'/simpletestlib.php');
 require_once('ex_simple_test.php');
 require_once('ex_reporter.php');
 
-require_login();
-require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
-
-$langfile = 'simpletest';
-$unittest = true;
-
 // CGI arguments
 $path = optional_param('path', null, PARAM_PATH);
 $showpasses = optional_param('showpasses', false, PARAM_BOOL);
@@ -35,13 +29,17 @@ $continuesetuptesttables = optional_param('continuesetuptesttables', false, PARA
 $droptesttables = optional_param('droptesttables', false, PARAM_BOOL);
 $testtablesok = optional_param('testtablesok', false, PARAM_BOOL);
 
+admin_externalpage_setup('reportsimpletest');
+admin_externalpage_print_header();
+
+$langfile = 'simpletest';
+$unittest = true;
+
 global $UNITTEST;
 $UNITTEST = new object();
 
 // Print the header.
-admin_externalpage_setup('reportsimpletest');
 $strtitle = get_string('unittests', $langfile);
-admin_externalpage_print_header();
 
 if ($testtablesok) {
     print_heading(get_string('testtablesok', 'simpletest'));
index 2c2d3f0538a1420b6152cac96ddc00a72f292598..8bccf04f755f15c6d2f9cf349714e4455e74725d 100644 (file)
@@ -1,6 +1,6 @@
 <?php  //$Id$
 if ($hassiteconfig) {
-    $ADMIN->add('development', new admin_externalpage('reportsimpletest', get_string('simpletest', 'admin'), "$CFG->wwwroot/$CFG->admin/report/unittest/index.php",'moodle/site:config'));
-    $ADMIN->add('development', new admin_externalpage('reportdbtest', get_string('dbtest', 'admin'), "$CFG->wwwroot/$CFG->admin/report/unittest/dbtest.php",'moodle/site:config'));
+    $ADMIN->add('development', new admin_externalpage('reportsimpletest', get_string('simpletest', 'admin'), "$CFG->wwwroot/$CFG->admin/report/unittest/index.php",'report/unittest:view'));
+    $ADMIN->add('development', new admin_externalpage('reportdbtest', get_string('dbtest', 'admin'), "$CFG->wwwroot/$CFG->admin/report/unittest/dbtest.php",'report/unittest:view'));
 }
 ?>
\ No newline at end of file
diff --git a/admin/report/unittest/version.php b/admin/report/unittest/version.php
new file mode 100644 (file)
index 0000000..645c20a
--- /dev/null
@@ -0,0 +1,29 @@
+<?PHP // $Id$
+
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// 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  = 2008112601;
+$plugin->requires = 2008112600;
+
+?>
diff --git a/admin/settings/report.php b/admin/settings/report.php
new file mode 100644 (file)
index 0000000..790d0d7
--- /dev/null
@@ -0,0 +1,18 @@
+<?php //$Id$
+
+foreach (get_list_of_plugins($CFG->admin.'/report') as $plugin) {
+    $settings_path = "$CFG->dirroot/$CFG->admin/report/$plugin/settings.php";
+    if (file_exists($settings_path)) {
+        include($settings_path);
+        continue;
+    }
+
+    $index_path = "$CFG->dirroot/$CFG->admin/report/$plugin/index.php";
+    if (!file_exists($index_path)) {
+        continue;
+    }
+    // old style 3rd party plugin without settings.php
+    $ADMIN->add('reports', new admin_externalpage('report'.$plugin, $plugin, $index_path, 'moodle/site:viewreports'));
+}
+
+?>
index e295eae03510e220becb9205791203aa3f29db1c..b09703ee1b0fdc5f2a4200aa815a65a0f3f31d98 100644 (file)
@@ -24,6 +24,9 @@ if ($hassiteconfig) {
 }
 
 $ADMIN->add('root', new admin_category('users', get_string('users','admin')));
+  $ADMIN->add('users', new admin_category('authsettings', get_string('authentication','admin')));
+  $ADMIN->add('users', new admin_category('accounts', get_string('accounts', 'admin')));
+  $ADMIN->add('users', new admin_category('roles', get_string('permissions', 'role')));
 $ADMIN->add('root', new admin_category('courses', get_string('courses','admin')));
 $ADMIN->add('root', new admin_category('grades', get_string('grades')));
 $ADMIN->add('root', new admin_category('location', get_string('location','admin')));
@@ -36,8 +39,10 @@ $ADMIN->add('root', new admin_category('server', get_string('server','admin')));
 $ADMIN->add('root', new admin_category('mnet', get_string('net','mnet'), (isset($CFG->mnet_dispatcher_mode) and $CFG->mnet_dispatcher_mode === 'off')));
 $ADMIN->add('root', new admin_category('reports', get_string('reports')));
 $ADMIN->add('root', new admin_category('development', get_string('development', 'admin')));
+
 // hidden unsupported category
 $ADMIN->add('root', new admin_category('unsupported', get_string('unsupported', 'admin'), true));
+
 // hidden search script
 $ADMIN->add('root', new admin_externalpage('search', get_string('searchresults'), "$CFG->wwwroot/$CFG->admin/search.php", 'moodle/site:config', true));
 
index f703294c9ddd632129f4615c01e22f6f7936d416..17de059d2e63f5e171dc9649ac4490773422e6f2 100644 (file)
@@ -11,8 +11,6 @@ if ($hassiteconfig
  or has_capability('moodle/role:assign', $systemcontext)) { // speedup for non-admins, add all caps used on this page
 
 
-    $ADMIN->add('users', new admin_category('authsettings', get_string('authentication','admin')));
-
     $temp = new admin_settingpage('manageauths', get_string('authsettings', 'admin'));
     $temp->add(new admin_setting_manageauths());
     $temp->add(new admin_setting_heading('manageauthscommonheading', get_string('commonsettings', 'admin'), ''));
@@ -70,7 +68,6 @@ if ($hassiteconfig
         $securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
     }
     // stuff under the "accounts" subcategory
-    $ADMIN->add('users', new admin_category('accounts', get_string('accounts', 'admin')));
     $ADMIN->add('accounts', new admin_externalpage('editusers', get_string('userlist','admin'), "$CFG->wwwroot/$CFG->admin/user.php", array('moodle/user:update', 'moodle/user:delete')));
     $ADMIN->add('accounts', new admin_externalpage('userbulk', get_string('userbulk','admin'), "$CFG->wwwroot/$CFG->admin/user/user_bulk.php", array('moodle/user:update', 'moodle/user:delete')));
     $ADMIN->add('accounts', new admin_externalpage('addnewuser', get_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create'));
@@ -80,7 +77,6 @@ if ($hassiteconfig
 
 
     // stuff under the "roles" subcategory
-    $ADMIN->add('users', new admin_category('roles', get_string('permissions', 'role')));
 
     // "userpolicies" settingpage
     $temp = new admin_settingpage('userpolicies', get_string('userpolicies', 'admin'));
diff --git a/lang/en_utf8/report_unittest.php b/lang/en_utf8/report_unittest.php
new file mode 100644 (file)
index 0000000..2227cf0
--- /dev/null
@@ -0,0 +1,5 @@
+<?PHP // $Id$
+
+$string['unittest:view'] = 'Execute unit tests';
+
+?>
index 8160cced27efa9d7e1bd6eab30e16debe04a590c..b3c36b8cc8a51cc41a7421d80003bab16351d7e5 100755 (executable)
@@ -3028,7 +3028,11 @@ function load_capability_def($component) {
     } else {
         $compparts = explode('/', $component);
 
-        if ($compparts[0] == 'block') {
+        if ($compparts[0] == 'report') {
+            $defpath = $CFG->dirroot.'/'.$CFG->admin.'/report/'.$compparts[1].'/db/access.php';
+            $varprefix = $compparts[0].'_'.$compparts[1];
+
+        } else if ($compparts[0] == 'block') {
             // Blocks are an exception. Blocks directory is 'blocks', and not
             // 'block'. So we need to jump through hoops.
             $defpath = $CFG->dirroot.'/'.$compparts[0].
@@ -3884,6 +3888,10 @@ function get_capability_string($capabilityname) {
     $componentname = $components[0];               // choice
 
     switch ($names[0]) {
+        case 'report':
+            $string = get_string($stringname, 'report_'.$componentname);
+        break;
+
         case 'mod':
             $string = get_string($stringname, $componentname);
         break;
@@ -3952,6 +3960,8 @@ function get_component_string($component, $contextlevel) {
             } else if (preg_match('|^local|', $component)) {
                 $langname = str_replace('/', '_', $component);
                 $string = get_string('local');
+            } else if (preg_match('|^report/|', $component)) {
+                $string = get_string('reports');
             } else {
                 $string = get_string('coresystem');
             }
@@ -5547,7 +5557,10 @@ function component_level_changed($cap, $comp, $contextlevel) {
         $compsa = explode('/', $cap->component);
         $compsb = explode('/', $comp);
 
-
+        // list of system reports
+        if (($compsa[0] == 'report') &&($compsb[0] == 'report')) {
+            return false;
+        }
 
         // we are in gradebook, still
         if (($compsa[0] == 'gradeexport' || $compsa[0] == 'gradeimport' || $compsa[0] == 'gradereport') &&
index 89d0ac81c87b253863d7b2703f88b06873b0e85d..9cfb22f143267842da1b77392912722408146ea3 100644 (file)
@@ -5380,21 +5380,6 @@ function &admin_get_root($reload=false, $requirefulltree=true) {
             }
         }
 
-        // Add all the report plugings. Do this last so they can choose where in the tree
-        // they want to be added.
-        foreach (get_list_of_plugins($CFG->admin.'/report') as $plugin) {
-            $settingsfile = "$CFG->dirroot/$CFG->admin/report/$plugin/settings.php";
-            if (file_exists($settingsfile)) {
-                include($settingsfile);
-            } else {
-                $reportname = get_string($plugin, 'report_' . $plugin);
-                if ($reportname[1] == '[') {
-                    $reportname = get_string($plugin, 'admin');
-                }
-                $ADMIN->add('reports', new admin_externalpage('report'.$plugin, $reportname, "$CFG->wwwroot/$CFG->admin/report/$plugin/index.php",'moodle/site:viewreports'));
-            }
-        }
-
         if (file_exists($CFG->dirroot.'/local/settings.php')) {
             include_once($CFG->dirroot.'/local/settings.php');
         }
index 9f793bb7e0886395743e7ef8de9084c7c4f892a6..0bc166ba5cccb4ed4abce2be666d1b37cd0b543a 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-    $version = 2008112400;  // YYYYMMDD   = date of the last version bump
+    $version = 2008112600;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20081126)';  // Human-friendly version name