]> git.mjollnir.org Git - moodle.git/commitdiff
Fixing notices
authorvyshane <vyshane>
Wed, 16 Aug 2006 03:24:43 +0000 (03:24 +0000)
committervyshane <vyshane>
Wed, 16 Aug 2006 03:24:43 +0000 (03:24 +0000)
mod/forum/post.html
mod/forum/post.php

index 06d3d1e6abcb1709826867a911bdaf421f359e24..ac46c8e80bc065796acaabd80d0bb7c053dd9539 100644 (file)
@@ -1,8 +1,11 @@
 <?php
-/**
- * This file is required by post.php. Therefore, the context objects
- * $modcontext and $coursecontext are available to the script.
- */
+
+
+if (!isset($coursecontext)) {
+    // Has not yet been set by post.php.
+    $coursecontext = get_context_instance(CONTEXT_COURSE, $forum->course);
+}
+
 
 if (!isset($discussion->timestart)) {
     $discussion->timestart = 0;
index 3bcec90a1b0f810f33ef7ad2b1a3e5d3d9672454..bf6ca6c54b81fb4b03d200f2906e3d3029e2e201 100644 (file)
@@ -14,8 +14,6 @@
     $confirm = optional_param('confirm',0,PARAM_INT);
     
     
-    $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
-    
     
     if (isguest()) {
         $wwwroot = $CFG->wwwroot.'/login/index.php';
@@ -41,6 +39,7 @@
         if (! $course = get_record('course', 'id', $forum->course)) {
             error('The course number was incorrect');
         }
+        
         if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { // For the logs
             // Teacher forum?
             $cm->id = 0;
@@ -75,7 +74,7 @@
         if (!$course = get_record('course', 'id', $post->course)) {
             error('Could not find specified course!');
         }
-
+        
         if (!empty($course->lang)) {           // Override current language
             $CFG->courselang = $course->lang;
         }
@@ -95,6 +94,7 @@
         if (!$cm = get_coursemodule_from_instance("forum", $post->forum, $course->id)) { // For the logs
             $cm->id = 0;
         }
+        $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
 
         if (!$post->subject or !$post->message) {
             $post->error = get_string("emptymessage", "forum");
         if (! $course = get_record("course", "id", $forum->course)) {
             error("The course number was incorrect ($forum->course)");
         }
-
+        $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+        
         if (! forum_user_can_post_discussion($forum)) {
             error("Sorry, but you can not post a new discussion in this forum.");
         }
-
+        
         if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
             if (!$cm->visible and !has_capability('moodle/course:manageactivities', $coursecontext)) {
                 error(get_string("activityiscurrentlyhidden"));
         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 ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
             if (groupmode($course, $cm)) {   // Make sure user can post here
                 $mygroupid = mygroupid($course->id);
         if (! $forum = get_record("forum", "id", $discussion->forum)) {
             error("The forum number was incorrect ($discussion->forum)");
         }
+        if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) {
+            $cm->id = 0;
+        } else {
+            $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+        }
         if ( !(($post->userid == $USER->id && has_capability('mod/forum:deleteownpost', $modcontext))
                     || has_capability('mod/forum:deleteanypost', $modcontext)) ) {
             error("You can't delete this post!");
                         forum_go_back_to("discuss.php?d=$post->discussion"));
 
             } else {
-                if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) { // For the logs
-                    $cm->id = 0;
-                }
                 if (! $post->parent) {  // post is a discussion topic as well, so delete discussion
                     if ($forum->type == "single") {
                         notice("Sorry, but you are not allowed to delete that discussion!",
     print_footer($course);
 
 
-?>
+?>
\ No newline at end of file