Skip to content

Commit 9542750

Browse files
Add evasys manager role and capability
1 parent 70e46e2 commit 9542750

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

db/access.php

+4
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,8 @@
5858
'manager' => CAP_ALLOW,
5959
),
6060
),
61+
'block/evasys_sync:managecourses' => array(
62+
'captype' => 'write',
63+
'contextlevel' => CONTEXT_COURSECAT
64+
)
6165
);

db/install.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
// This file replaces:
3+
// * STATEMENTS section in db/install.xml
4+
// * lib.php/modulename_install() post installation hook
5+
// * partially defaults.php
6+
defined('MOODLE_INTERNAL') || die();
7+
8+
/**
9+
* install.php
10+
*
11+
* @package block_evasys_sync
12+
* @copyright 2022 Justus Dieckmann
13+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
14+
*/
15+
16+
function xmldb_block_evasys_sync_install() {
17+
xmldb_block_evasys_sync_create_role();
18+
}
19+
20+
function xmldb_block_evasys_sync_create_role() {
21+
global $DB;
22+
23+
if ($DB->record_exists('role', ['shortname' => 'evasysmanager'])) {
24+
return;
25+
}
26+
27+
// Set up the course manager role.
28+
$rid = create_role('EvaSys course manager', 'evasysmanager', '');
29+
assign_capability('block/evasys_sync:managecourses', CAP_ALLOW, $rid, context_system::instance());
30+
set_role_contextlevels($rid, [CONTEXT_COURSECAT, CONTEXT_COURSE]);
31+
}

db/upgrade.php

+7
Original file line numberDiff line numberDiff line change
@@ -237,5 +237,12 @@ function xmldb_block_evasys_sync_upgrade ($oldversion) {
237237
upgrade_block_savepoint(true, 2019203100, 'evasys_sync');
238238
}
239239

240+
if ($oldversion < 2022091000) {
241+
require_once(__DIR__ . '/install.php');
242+
xmldb_block_evasys_sync_create_role();
243+
// Evasys_sync savepoint reached.
244+
upgrade_block_savepoint(true, 2022091000, 'evasys_sync');
245+
}
246+
240247
return true;
241248
}

lang/en/block_evasys_sync.php

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
$string['evasys_sync:mayevaluate'] = 'Evaluate a course using EvaSys';
154154
$string['evasys_sync:synchronize'] = 'Export participants to EvaSys';
155155
$string['evasys_sync:modifymapping'] = 'Modify mapping of EvaSys courses to moodle course';
156+
$string['evasys_sync:managecourses'] = 'EvaSys manage course';
156157

157158
// Settings.
158159
$string['settings'] = 'EvaSys Sync Block Settings';

version.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
defined('MOODLE_INTERNAL') || die();
1919

2020
$plugin->component = 'block_evasys_sync';
21-
$plugin->version = 2019203100; // YYYYMMDDHH (year, month, day, 24-hr time).
22-
$plugin->requires = 2017111300; // YYYmoYMMDDHH (This is the release version for Moodle 2.0).
21+
$plugin->version = 2022091000; // YYYYMMDDHH (year, month, day, 24-hr time).
22+
$plugin->requires = 2017111300; // YYYYMMDDHH (This is the release version for Moodle 2.0).
2323
$plugin->maturity = MATURITY_RC;

0 commit comments

Comments
 (0)