Skip to content

Commit

Permalink
MDL-29030 migrate outline report to new type
Browse files Browse the repository at this point in the history
AMOS BEGIN
 MOV [outline:view,coursereport_outline],[outline:view,report_outline]
 MOV [pluginpagetype,coursereport_outline],[pluginpagetype,report_outline]
 MOV [pluginname,coursereport_outline],[pluginname,report_outline]
AMOS END
  • Loading branch information
skodak committed Nov 6, 2011
1 parent d9298dc commit 275cbac
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 120 deletions.
42 changes: 0 additions & 42 deletions course/report/outline/db/access.php

This file was deleted.

13 changes: 0 additions & 13 deletions course/report/outline/mod.php

This file was deleted.

29 changes: 0 additions & 29 deletions course/report/outline/version.php

This file was deleted.

2 changes: 1 addition & 1 deletion lang/en/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
$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';
Expand Down
18 changes: 14 additions & 4 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2286,8 +2286,8 @@ public function add_course_essentials($coursenode, stdClass $course) {

// View course reports
if (has_capability('moodle/site:viewreports', $this->page->context)) { // basic capability for listing of reports
$reportnav = $coursenode->add(get_string('reports'), new moodle_url('/course/report.php', array('id'=>$course->id)), self::TYPE_CONTAINER, null, null, new pix_icon('i/stats', ''));
$coursereports = get_plugin_list('coursereport');
$reportnav = $coursenode->add(get_string('reports'), null, self::TYPE_CONTAINER, null, null, new pix_icon('i/stats', ''));
$coursereports = get_plugin_list('coursereport'); // deprecated
foreach ($coursereports as $report=>$dir) {
$libfile = $CFG->dirroot.'/course/report/'.$report.'/lib.php';
if (file_exists($libfile)) {
Expand All @@ -2298,6 +2298,11 @@ public function add_course_essentials($coursenode, stdClass $course) {
}
}
}

$reports = get_plugin_list_with_function('report', 'extend_navigation_course', 'lib.php');
foreach ($reports as $reportfunction) {
$reportfunction($reportnav, $course, $this->page->context);
}
}
return true;
}
Expand Down Expand Up @@ -2356,8 +2361,8 @@ public function add_front_page_course_essentials(navigation_node $coursenode, st

// View course reports
if (has_capability('moodle/site:viewreports', $this->page->context)) { // basic capability for listing of reports
$reportnav = $coursenode->add(get_string('reports'), new moodle_url('/course/report.php', array('id'=>$course->id)), self::TYPE_CONTAINER, null, null, new pix_icon('i/stats', ''));
$coursereports = get_plugin_list('coursereport');
$reportnav = $coursenode->add(get_string('reports'), null, self::TYPE_CONTAINER, null, null, new pix_icon('i/stats', ''));
$coursereports = get_plugin_list('coursereport'); // deprecated
foreach ($coursereports as $report=>$dir) {
$libfile = $CFG->dirroot.'/course/report/'.$report.'/lib.php';
if (file_exists($libfile)) {
Expand All @@ -2368,6 +2373,11 @@ public function add_front_page_course_essentials(navigation_node $coursenode, st
}
}
}

$reports = get_plugin_list_with_function('report', 'extend_navigation_course', 'lib.php');
foreach ($reports as $reportfunction) {
$reportfunction($reportnav, $course, $this->page->context);
}
}
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/pluginlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public static function standard_plugins_list($type) {
),

'coursereport' => array(
'completion', 'log', 'outline', 'participation', 'progress', 'stats'
'completion', 'log', 'participation', 'progress', 'stats'
),

'datafield' => array(
Expand Down Expand Up @@ -407,7 +407,7 @@ public static function standard_plugins_list($type) {

'report' => array(
'backups', 'configlog', 'courseoverview',
'log', 'questioninstances', 'security', 'stats'
'log', 'outline', 'questioninstances', 'security', 'stats'
),

'repository' => array(
Expand Down
42 changes: 42 additions & 0 deletions report/outline/db/access.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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/>.

/**
* Capabilities
*
* @package report
* @subpackage outline
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$capabilities = array(

'report/outline:view' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),

'clonepermissionsfrom' => 'coursereport/outline:view',
)
);


33 changes: 33 additions & 0 deletions report/outline/db/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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/>.

/**
* Post installation and migration code.
*
* @package report
* @subpackage outline
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

function xmldb_report_outline_install() {
// this is a hack which is needed for cleanup of original coursereport_outline stuff
unset_all_config_for_plugin('coursereport_online');
capabilities_cleanup('coursereport_online');
}

39 changes: 29 additions & 10 deletions course/report/outline/index.php → report/outline/index.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
<?php

// Display user activity reports for a course (totals)

require_once('../../../config.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/>.

/**
* Display user activity reports for a course (totals)
*
* @package report
* @subpackage outline
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require('../../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');
}
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);

$PAGE->set_url('/course/report/outline/index.php', array('id'=>$id));
$PAGE->set_url('/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);
require_capability('report/outline:view', $context);

add_to_log($course->id, 'course', 'report outline', "report/outline/index.php?id=$course->id", $course->id);

Expand All @@ -27,7 +46,7 @@
$showlastaccess = false;
}

$stractivityreport = get_string('activityreport');
$stractivityreport = get_string('pluginname', 'report_outline');
$stractivity = get_string('activity');
$strlast = get_string('lastaccess');
$strreports = get_string('reports');
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,13 +15,14 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Strings for component 'coursereport_outline', language 'en', branch 'MOODLE_20_STABLE'
* Strings
*
* @package coursereport_outline
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package report
* @subpackage outline
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['outline:view'] = 'View course activity report';
$string['outline:view'] = 'View activity report';
$string['pluginpagetype'] = 'Activity course report';
$string['pluginname'] = 'Course activity';
$string['pluginname'] = 'Activity report';
26 changes: 14 additions & 12 deletions course/report/outline/lib.php → report/outline/lib.php
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,24 +17,26 @@
/**
* 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
* @package report
* @subpackage outline
* @copyright 2009 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

/**
* This function extends the navigation with the report items
* This function extends the course 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) {
function report_outline_extend_navigation_course($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', ''));
if (has_capability('report/outline:view', $context)) {
$url = new moodle_url('/report/outline/index.php', array('id'=>$course->id));
$navigation->add(get_string('pluginname', 'report_outline'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
}
}

Expand All @@ -44,12 +45,13 @@ function outline_report_extend_navigation($navigation, $course, $context) {
* @param string $pagetype current page type
* @param stdClass $parentcontext Block's parent context
* @param stdClass $currentcontext Current context of block
* @return array
*/
function outline_page_type_list($pagetype, $parentcontext, $currentcontext) {
function report_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')
'course-report-outline-index' => get_string('pluginpagetype', 'report_outline')
);
return $array;
}
Loading

0 comments on commit 275cbac

Please sign in to comment.