diff --git a/blocks/admin/block_admin.php b/blocks/admin/block_admin.php
index a3dab444e85..accf193651f 100644
--- a/blocks/admin/block_admin.php
+++ b/blocks/admin/block_admin.php
@@ -143,16 +143,14 @@ class block_admin extends block_list {
}
/// Authorize hooks
- if (has_capability('enrol/authorize:managepayments', $context)) {
- if ($course->enrol == 'authorize' || (empty($course->enrol) && $CFG->enrol == 'authorize')) {
- require_once($CFG->dirroot.'/enrol/authorize/const.php');
- $paymenturl = ''.get_string('payments').' ';
- if ($cnt = count_records('enrol_authorize', 'status', AN_STATUS_AUTH, 'courseid', $course->id)) {
- $paymenturl .= ''.get_string('paymentpending', 'moodle', $cnt).'';
- }
- $this->content->items[] = $paymenturl;
- $this->content->icons[] = '
';
+ if ($course->enrol == 'authorize' || (empty($course->enrol) && $CFG->enrol == 'authorize')) {
+ require_once($CFG->dirroot.'/enrol/authorize/const.php');
+ $paymenturl = ''.get_string('payments').' ';
+ if ($cnt = count_records('enrol_authorize', 'status', AN_STATUS_AUTH, 'courseid', $course->id)) {
+ $paymenturl .= ''.get_string('paymentpending', 'moodle', $cnt).'';
}
+ $this->content->items[] = $paymenturl;
+ $this->content->icons[] = '
';
}
/// View course grades (or just your own grades, same link)
@@ -162,14 +160,16 @@ class block_admin extends block_list {
$this->content->icons[]='
';
}
- /// Person can unenrol themselves from this course
- if (has_capability('moodle/role:unassignself', $context, NULL, false) and empty($course->metacourse)) {
- $this->content->items[]=''.get_string('unenrolme', '', $course->shortname).'';
- $this->content->icons[]='
';
+ if (empty($course->metacourse)) {
+ if (has_capability('moodle/legacy:guest', $context, NULL, false)) { // Are a guest now
+ $this->content->items[]=''.get_string('enrolme', '', $course->shortname).'';
+ $this->content->icons[]='
';
+ } else if (has_capability('moodle/role:unassignself', $context, NULL, false)) { // Have some role
+ $this->content->items[]=''.get_string('unenrolme', '', $course->shortname).'';
+ $this->content->icons[]='
';
+ }
}
-
-
/// Should the following two be in this block?
diff --git a/enrol/manual/enrol.php b/enrol/manual/enrol.php
index 27726ba1483..0673fd93393 100644
--- a/enrol/manual/enrol.php
+++ b/enrol/manual/enrol.php
@@ -75,7 +75,7 @@ function print_entry($course) {
print_error('couldnotassignrole');
}
- if ($SESSION->wantsurl) {
+ if (!empty($SESSION->wantsurl)) {
$destination = $SESSION->wantsurl;
unset($SESSION->wantsurl);
} else {
@@ -86,7 +86,13 @@ function print_entry($course) {
} else if (!empty($_GET['cancel'])) {
unset($SESSION->wantsurl);
- redirect($CFG->wwwroot);
+ if (!empty($SESSION->enrolcancel)) {
+ $destination = $SESSION->enrolcancel;
+ unset($SESSION->enrolcancel);
+ } else {
+ $destination = $CFG->wwwroot;
+ }
+ redirect($destination);
}
}
diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php
index d326eb5ba18..547c1ea2af9 100644
--- a/lang/en_utf8/moodle.php
+++ b/lang/en_utf8/moodle.php
@@ -1469,9 +1469,10 @@ $string['yahooid'] = 'Yahoo ID';
$string['yes'] = 'Yes';
$string['youareabouttocreatezip'] = 'You are about to create a zip file containing';
$string['youaregoingtorestorefrom'] = 'You are about to start the restore process for';
+$string['youneedtoenrol'] = 'To perform that action you need to enrol in this course.';
$string['yourlastlogin'] = 'Your last login was';
$string['yourself'] = 'yourself';
$string['yourteacher'] = 'your $a';
$string['zippingbackup'] = 'Zipping backup';
-?>
\ No newline at end of file
+?>
diff --git a/mod/forum/post.php b/mod/forum/post.php
index 59cf6eb1a7a..dcbbe51b8bc 100644
--- a/mod/forum/post.php
+++ b/mod/forum/post.php
@@ -376,10 +376,17 @@
if (! $course = get_record("course", "id", $discussion->course)) {
error("The course number was incorrect ($discussion->course)");
}
+
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
if (! forum_user_can_post($forum)) {
- error("Sorry, but you can not post in this forum.");
+ if (has_capability('moodle/legacy:guest', $coursecontext, NULL, false)) { // User is a guest here!
+ $SESSION->wantsurl = $FULLME;
+ $SESSION->enrolcancel = $_SERVER['HTTP_REFERER'];
+ redirect($CFG->wwwroot.'/course/enrol.php?id='.$course->id, get_string('youneedtoenrol'));
+ } else {
+ print_error('nopostforum', 'forum');
+ }
}
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {