From 79aa7978bb48f00978882de612785f1c9a68b55e Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 20 Nov 2024 17:38:16 +0100 Subject: [PATCH] feat: Add capability for viewing user grades Defines a new capability 'report/usergrades:view' with associated risks and context level. Grants managers permission to access this report. Updates page setup to check the new capability, ensuring appropriate access control. Increments plugin version to reflect these changes. Enhances security and manages user access more effectively. --- db/access.php | 12 ++++++++++++ index.php | 2 +- version.php | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 db/access.php diff --git a/db/access.php b/db/access.php new file mode 100644 index 0000000..fa0d9ba --- /dev/null +++ b/db/access.php @@ -0,0 +1,12 @@ + array( + 'riskbitmask' => RISK_PERSONAL, + 'captype' => 'read', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + 'manager' => CAP_ALLOW, + ), + ), +); diff --git a/index.php b/index.php index f72398d..e017c62 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,7 @@ require_once($CFG->libdir . '/formslib.php'); require_once($CFG->dirroot . '/user/selector/lib.php'); // Set up the page context and other configurations -admin_externalpage_setup('report_usergrades'); +admin_externalpage_setup('report_usergrades', '', null, '', array('capability' => 'report/usergrades:view')); class user_selector extends user_selector_base { diff --git a/version.php b/version.php index 01d9cad..9ca7d37 100644 --- a/version.php +++ b/version.php @@ -2,7 +2,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'report_usergrades'; -$plugin->version = 2024112000; +$plugin->version = 2024112001; $plugin->requires = 2022041900; $plugin->maturity = MATURITY_ALPHA; $plugin->release = 'v1.0';