From 1015ffa46d7d58c339837f884120ade9f478a064 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Fri, 2 Jun 2017 12:42:04 +0800 Subject: [PATCH] #85 Added new capability for viewing the course report --- db/access.php | 11 +++++++++++ lang/en/customcert.php | 1 + report.php | 2 +- version.php | 4 ++-- view.php | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/db/access.php b/db/access.php index 60a36d1..5be7c8e 100644 --- a/db/access.php +++ b/db/access.php @@ -60,6 +60,17 @@ $capabilities = array( ) ), + 'mod/customcert:viewreport' => array( + + 'captype' => 'read', + 'contextlevel' => CONTEXT_MODULE, + 'archetypes' => array( + 'teacher' => CAP_ALLOW, + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ) + ), + 'mod/customcert:viewallcertificates' => array( 'captype' => 'read', 'contextlevel' => CONTEXT_SYSTEM, diff --git a/lang/en/customcert.php b/lang/en/customcert.php index 7ee5bfc..ec8bd43 100644 --- a/lang/en/customcert.php +++ b/lang/en/customcert.php @@ -36,6 +36,7 @@ $string['customcertreport'] = 'Custom certificate report'; $string['customcert:addinstance'] = 'Add a new custom certificate instance'; $string['customcert:manage'] = 'Manage a custom certificate'; $string['customcert:view'] = 'View a custom certificate'; +$string['customcert:viewreport'] = 'View course report'; $string['customcert:viewallcertificates'] = 'View all certificates'; $string['customcert:verifycertificate'] = 'Verify a certificate'; $string['deletecertpage'] = 'Delete certificate page'; diff --git a/report.php b/report.php index 85a7751..9728be6 100644 --- a/report.php +++ b/report.php @@ -44,7 +44,7 @@ require_login($course, false, $cm); // Check capabilities. $context = context_module::instance($cm->id); -require_capability('mod/customcert:manage', $context); +require_capability('mod/customcert:viewreport', $context); // Check if we requested to download another user's certificate. if ($downloadcert) { diff --git a/version.php b/version.php index f073283..e99c549 100644 --- a/version.php +++ b/version.php @@ -24,10 +24,10 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); -$plugin->version = 2016052312; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2016052313; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2016052300; // Requires this Moodle version (3.1). $plugin->cron = 0; // Period for cron to check this module (secs). $plugin->component = 'mod_customcert'; $plugin->maturity = MATURITY_STABLE; -$plugin->release = "3.1 release (Build: 2016052312)"; // User-friendly version number. +$plugin->release = "3.1 release (Build: 2016052313)"; // User-friendly version number. diff --git a/view.php b/view.php index 64653e2..3708f28 100644 --- a/view.php +++ b/view.php @@ -68,7 +68,7 @@ if (empty($action)) { // Generate the link to the report if there are issues to display. $reportlink = ''; - if (has_capability('mod/customcert:manage', $context)) { + if (has_capability('mod/customcert:viewreport', $context)) { // Get the total number of issues. $numissues = \mod_customcert\certificate::get_number_of_issues($customcert->id, $cm, $groupmode); $href = new moodle_urL('/mod/customcert/report.php', array('id' => $cm->id));