I have created a local plugin called local_interview for which I would like to to give access to only logged in user with manager or admin roles. I have added access.php and settings.php, however the link (http://localhost/moodle/local/interview/manage.php and also http://localhost/moodle/local/interview/edit.php) is accessible to anyone including the guest.
settings.php
<?phpaccess.php
/**
* @package local_interview
*/
defined('MOODLE_INTERNAL') || die();
if (has_capability('local/interview:view', context_system::instance())) {
$ADMIN->add('root', new admin_category('local_interview', new lang_string('pluginname', 'local_interview')));
$ADMIN->add(
'local_interview',
new admin_externalpage(
'local_interview_index',
new lang_string('pluginname', 'local_interview'),
new moodle_url('/local/interview/manage.php'),
'local/interview:view'
)
);
$ADMIN->add(
'local_interview',
new admin_externalpage(
'local_interview_admin',
new lang_string('edit', 'local_interview'),
new moodle_url('/local/interview/edit.php'),
'local/interview:view'
)
);
}
<?phpKindly help me with any pointers on how to fix this issue.
/**
* @package local_interview
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'local/interview:edit' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW,
'student' => CAP_PROHIBIT,
'guest' => CAP_PROHIBIT,
),
),
'local/interview:view' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW,
'student' => CAP_PROHIBIT,
'guest' => CAP_PROHIBIT,
),
),
);