]> git.mjollnir.org Git - moodle.git/commitdiff
Merged enrolment-related fixes from stable
authormoodler <moodler>
Fri, 20 Oct 2006 17:53:50 +0000 (17:53 +0000)
committermoodler <moodler>
Fri, 20 Oct 2006 17:53:50 +0000 (17:53 +0000)
blocks/admin/block_admin.php
enrol/manual/enrol.php
lang/en_utf8/moodle.php
mod/forum/post.php

index a3dab444e8538295d941765c2ce5ddb8374e81e4..accf193651fdbfd4fd24ffd5c0469ec4a90d18a1 100644 (file)
@@ -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 = '<a href="'.$CFG->wwwroot.'/enrol/authorize/index.php?course='.$course->id.'">'.get_string('payments').'</a> ';
-                if ($cnt = count_records('enrol_authorize', 'status', AN_STATUS_AUTH, 'courseid', $course->id)) {
-                    $paymenturl .= '<a href="'.$CFG->wwwroot.'/enrol/authorize/index.php?status='.AN_STATUS_AUTH.'&amp;course='.$course->id.'">'.get_string('paymentpending', 'moodle', $cnt).'</a>';
-                }
-                $this->content->items[] = $paymenturl;
-                $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/payment.gif" alt="" />';
+        if ($course->enrol == 'authorize' || (empty($course->enrol) && $CFG->enrol == 'authorize')) {
+            require_once($CFG->dirroot.'/enrol/authorize/const.php');
+            $paymenturl = '<a href="'.$CFG->wwwroot.'/enrol/authorize/index.php?course='.$course->id.'">'.get_string('payments').'</a> ';
+            if ($cnt = count_records('enrol_authorize', 'status', AN_STATUS_AUTH, 'courseid', $course->id)) {
+                $paymenturl .= '<a href="'.$CFG->wwwroot.'/enrol/authorize/index.php?status='.AN_STATUS_AUTH.'&amp;course='.$course->id.'">'.get_string('paymentpending', 'moodle', $cnt).'</a>';
             }
+            $this->content->items[] = $paymenturl;
+            $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/payment.gif" alt="" />';
         }
 
     /// View course grades (or just your own grades, same link)
@@ -162,14 +160,16 @@ class block_admin extends block_list {
             $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" alt="" />';
         }
 
-    /// Person can unenrol themselves from this course
-        if (has_capability('moodle/role:unassignself', $context, NULL, false) and empty($course->metacourse)) {
-            $this->content->items[]='<a href="unenrol.php?id='.$this->instance->pageid.'">'.get_string('unenrolme', '', $course->shortname).'</a>';
-            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
+        if (empty($course->metacourse)) {
+            if (has_capability('moodle/legacy:guest', $context, NULL, false)) {   // Are a guest now
+                $this->content->items[]='<a href="enrol.php?id='.$this->instance->pageid.'">'.get_string('enrolme', '', $course->shortname).'</a>';
+                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
+            } else if (has_capability('moodle/role:unassignself', $context, NULL, false)) {  // Have some role
+                $this->content->items[]='<a href="unenrol.php?id='.$this->instance->pageid.'">'.get_string('unenrolme', '', $course->shortname).'</a>';
+                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
+            }
         }
 
-
-
     /// Should the following two be in this block?
 
 
index 27726ba1483c6c7ad8242f875da897532161773c..0673fd93393f1263dbfea496ec3a7bc1f864d04e 100644 (file)
@@ -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);
         }
     }
 
index d326eb5ba181ec5aef17a80a84dcdbe59a6371d4..547c1ea2af9206dc18ad0f02d40e9d291fa15808 100644 (file)
@@ -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
+?>
index 59cf6eb1a7a9d3d0b63dff18218a5bb2cf672406..dcbbe51b8bc98b41c12ed21a216149cd80616896 100644 (file)
         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)) {