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.
This commit is contained in:
Kumi 2024-11-20 17:38:16 +01:00
parent d58349069d
commit 79aa7978bb
Signed by: kumi
GPG key ID: ECBCC9082395383F
3 changed files with 14 additions and 2 deletions

12
db/access.php Normal file
View file

@ -0,0 +1,12 @@
<?php
$capabilities = array(
'report/usergrades:view' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW,
),
),
);

View file

@ -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
{

View file

@ -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';