]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16182 Loosening the api a bit, solves the issue.
authornicolasconnault <nicolasconnault>
Sat, 23 Aug 2008 07:01:44 +0000 (07:01 +0000)
committernicolasconnault <nicolasconnault>
Sat, 23 Aug 2008 07:01:44 +0000 (07:01 +0000)
mod/forum/lib.php

index ebf3ec92a57b19b02d1a2a436844ed9ef180b193..508a239ac4db628181ddb66d8d0b2f0dbef6aaea 100644 (file)
@@ -74,7 +74,9 @@ function forum_add_instance($forum) {
         $discussion->mailnow  = false;
         $discussion->groupid  = -1;
 
-        if (! forum_add_discussion($discussion, $discussion->intro)) {
+        $message = '';
+
+        if (! forum_add_discussion($discussion, null, $message)) {
             error('Could not add the discussion for this forum');
         }
     }
@@ -3971,10 +3973,13 @@ function forum_pluginfile($course, $cminfo, $context, $filearea, $args) {
  * @param $newfile is a full upload array from $_FILES
  * @param $message is a string to hold the messages.
  */
-function forum_add_attachment($post, $cm, $mform, &$message, $remove_previous=true) {
+function forum_add_attachment($post, $cm, $mform=null, &$message=null, $remove_previous=true) {
     global $CFG, $DB, $USER;
 
     //TODO: add message when overwriting
+    if (empty($mform)) {
+        return false;
+    }
 
     $filename = $mform->get_new_filename('attachment');
     $filearea = 'forum_attachment';
@@ -4077,7 +4082,7 @@ function forum_update_post($post, $mform, &$message) {
  * Given an object containing all the necessary data,
  * create a new discussion and return the id
  */
-function forum_add_discussion($discussion, $mform, &$message) {
+function forum_add_discussion($discussion, $mform=null, &$message=null) {
     global $USER, $CFG, $DB;
 
     $timenow = time();