mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-14627 if you do not have capability to view activity the continue button should point to course not the activity
This commit is contained in:
parent
bc499733f8
commit
848fe203df
1 changed files with 8 additions and 1 deletions
|
@ -146,7 +146,14 @@ class webservice_parameter_exception extends moodle_exception {
|
||||||
class required_capability_exception extends moodle_exception {
|
class required_capability_exception extends moodle_exception {
|
||||||
function __construct($context, $capability, $errormessage, $stringfile) {
|
function __construct($context, $capability, $errormessage, $stringfile) {
|
||||||
$capabilityname = get_capability_string($capability);
|
$capabilityname = get_capability_string($capability);
|
||||||
parent::__construct($errormessage, $stringfile, get_context_url($context), $capabilityname);
|
if ($context->contextlevel == CONTEXT_MODULE and preg_match('/:view$/', $capability)) {
|
||||||
|
// we can not go to mod/xx/view.php because we most probably do not have cap to view it, let's go to course instead
|
||||||
|
$paranetcontext = get_context_instance_by_id(get_parent_contextid($context));
|
||||||
|
$link = get_context_url($paranetcontext);
|
||||||
|
} else {
|
||||||
|
$link = get_context_url($context);
|
||||||
|
}
|
||||||
|
parent::__construct($errormessage, $stringfile, $link, $capabilityname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue