Merge branch 'wip-mdl-29534' of git://github.com/rajeshtaneja/moodle
authorDan Poltawski <dan@moodle.com>
Thu, 17 Jan 2013 05:47:25 +0000 (13:47 +0800)
committerDan Poltawski <dan@moodle.com>
Thu, 17 Jan 2013 05:47:25 +0000 (13:47 +0800)
1  2 
mod/forum/lib.php

diff --combined mod/forum/lib.php
@@@ -705,6 -705,14 +705,14 @@@ function forum_cron() 
                  $eventdata->fullmessagehtml  = $posthtml;
                  $eventdata->notification = 1;
  
+                 // If forum_replytouser is not set then send mail using the noreplyaddress.
+                 if (empty($CFG->forum_replytouser)) {
+                     // Clone userfrom as it is referenced by $users.
+                     $cloneduserfrom = clone($userfrom);
+                     $cloneduserfrom->email = $CFG->noreplyaddress;
+                     $eventdata->userfrom = $cloneduserfrom;
+                 }
                  $smallmessagestrings = new stdClass();
                  $smallmessagestrings->user = fullname($userfrom);
                  $smallmessagestrings->forumname = "$shortname: ".format_string($forum->name,true).": ".$discussion->name;
                  $eventdata->contexturl = "{$CFG->wwwroot}/mod/forum/discuss.php?d={$discussion->id}#p{$post->id}";
                  $eventdata->contexturlname = $discussion->name;
  
-                 // If forum_replytouser is not set then send mail using the noreplyaddress.
-                 if (empty($CFG->forum_replytouser)) {
-                     $eventdata->userfrom->email = $CFG->noreplyaddress;
-                 }
                  $mailresult = message_send($eventdata);
                  if (!$mailresult){
                      mtrace("Error: mod/forum/lib.php forum_cron(): Could not send out mail for id $post->id to user $userto->id".
@@@ -5683,7 -5686,7 +5686,7 @@@ function forum_print_latest_discussions
                      $link = true;
                  } else {
                      $modcontext = context_module::instance($cm->id);
 -                    $link = forum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext);
 +                    $link = forum_user_can_see_discussion($forum, $discussion, $modcontext, $USER);
                  }
  
                  $discussion->forum = $forum->id;
@@@ -7196,7 -7199,7 +7199,7 @@@ function forum_reset_userdata($data) 
      if( $removeposts || !empty($data->reset_forum_ratings) ) {
          $forumssql      = "$allforumssql $typesql";
          $forums = $forums = $DB->get_records_sql($forumssql, $params);
 -        $rm = new rating_manager();;
 +        $rm = new rating_manager();
          $ratingdeloptions = new stdClass;
          $ratingdeloptions->component = 'mod_forum';
          $ratingdeloptions->ratingarea = 'post';