MDL-75441 mod_forum: Show add new post button to guest users

This commit is contained in:
Amaia Anabitarte 2022-11-25 12:03:47 +01:00
parent 40a89d8a9a
commit 31d84aaa2c
8 changed files with 456 additions and 6 deletions

View file

@ -1235,7 +1235,12 @@ function enrol_selfenrol_available($courseid) {
if ($instance->enrol === 'guest') {
continue;
}
if ($plugins[$instance->enrol]->show_enrolme_link($instance)) {
if ((isguestuser() || !isloggedin()) &&
($plugins[$instance->enrol]->is_self_enrol_available($instance) === true)) {
$result = true;
break;
}
if ($plugins[$instance->enrol]->show_enrolme_link($instance) === true) {
$result = true;
break;
}
@ -2011,6 +2016,17 @@ abstract class enrol_plugin {
return false;
}
/**
* Does this plugin support some way to self enrol?
* This function doesn't check user capabilities. Use can_self_enrol to check capabilities.
*
* @param stdClass $instance enrolment instance
* @return bool - true means "Enrol me in this course" link could be available.
*/
public function is_self_enrol_available(stdClass $instance) {
return false;
}
/**
* Attempt to automatically enrol current user in course without any interaction,
* calling code has to make sure the plugin and instance are active.