So I did the following:
First I added capability at system level:
$ADMIN->add('reports',
new admin_externalpage('reportgnp', get_string('pluginname','report_myreport'),
$url, 'report/myreport:view'));
and then I added capability in `db/access.php`:
$capabilities = array(
'report/myreport:view' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:viewreports',
)
);
But now it does not appear anymore in reports and I get the error:
Capability "repository/myreport:view" was not found! This has to be fixed in code.
line 4376 of /lib/navigationlib.php: call to admin_externalpage->check_access()
line 4408 of /lib/navigationlib.php: call to settings_navigation->load_administration_settings()
line 4359 of /lib/navigationlib.php: call to settings_navigation->load_administration_settings()
line 4214 of /lib/navigationlib.php: call to settings_navigation->load_administration_settings()
line 769 of /lib/pagelib.php: call to settings_navigation->initialise()
line 830 of /lib/pagelib.php: call to moodle_page->magic_get_settingsnav()
line 8498 of /lib/adminlib.php: call to moodle_page->__get()
line 24 of /admin/search.php: call to admin_externalpage_setup()
But why is that? I have created the capability under `/reports/myreport/db/access.php`. I also cleared the cache.