Merge branch 'MDL-41851-master' of git://github.com/andrewnicols/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 3 Feb 2015 11:36:00 +0000 (12:36 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 3 Feb 2015 11:36:00 +0000 (12:36 +0100)
1  2 
mod/forum/lib.php

diff --combined mod/forum/lib.php
@@@ -789,10 -789,7 +789,7 @@@ function forum_cron() 
  
                  // 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;
+                     $eventdata->userfrom = core_user::get_noreply_user();
                  }
  
                  $smallmessagestrings = new stdClass();
@@@ -1209,6 -1206,7 +1206,6 @@@ function forum_make_mail_text($course, 
  
      $posttext .= "\n";
      $posttext .= $CFG->wwwroot.'/mod/forum/discuss.php?d='.$discussion->id;
 -    $posttext .= "\n---------------------------------------------------------------------\n";
      $posttext .= format_string($post->subject,true);
      if ($bare) {
          $posttext .= " ($CFG->wwwroot/mod/forum/discuss.php?d=$discussion->id#p$post->id)";
      $posttext .= format_text_email($post->message, $post->messageformat);
      $posttext .= "\n\n";
      $posttext .= forum_print_attachments($post, $cm, "text");
 +    $posttext .= "\n---------------------------------------------------------------------\n";
  
      if (!$bare) {
          if ($canreply) {
 -            $posttext .= "---------------------------------------------------------------------\n";
              $posttext .= get_string("postmailinfo", "forum", $shortname)."\n";
              $posttext .= "$CFG->wwwroot/mod/forum/post.php?reply=$post->id\n";
          }
          if ($canunsubscribe) {
              if (\mod_forum\subscriptions::is_subscribed($userto->id, $forum, null, $cm)) {
                  // If subscribed to this forum, offer the unsubscribe link.
 -                $posttext .= "\n---------------------------------------------------------------------\n";
                  $posttext .= get_string("unsubscribe", "forum");
                  $posttext .= ": $CFG->wwwroot/mod/forum/subscribe.php?id=$forum->id\n";
              }
              // Always offer the unsubscribe from discussion link.
 -            $posttext .= "\n---------------------------------------------------------------------\n";
              $posttext .= get_string("unsubscribediscussion", "forum");
              $posttext .= ": $CFG->wwwroot/mod/forum/subscribe.php?id=$forum->id&d=$discussion->id\n";
          }
      }
  
 -    $posttext .= "\n---------------------------------------------------------------------\n";
      $posttext .= get_string("digestmailpost", "forum");
      $posttext .= ": {$CFG->wwwroot}/mod/forum/index.php?id={$forum->course}\n";
  
@@@ -2148,9 -2149,21 +2145,9 @@@ function forum_search_posts($searchterm
  
      if ($lexer->parse($searchstring)) {
          $parsearray = $parser->get_parsed_array();
 -    // Experimental feature under 1.8! MDL-8830
 -    // Use alternative text searches if defined
 -    // This feature only works under mysql until properly implemented for other DBs
 -    // Requires manual creation of text index for forum_posts before enabling it:
 -    // CREATE FULLTEXT INDEX foru_post_tix ON [prefix]forum_posts (subject, message)
 -    // Experimental feature under 1.8! MDL-8830
 -        if (!empty($CFG->forum_usetextsearches)) {
 -            list($messagesearch, $msparams) = search_generate_text_SQL($parsearray, 'p.message', 'p.subject',
 -                                                 'p.userid', 'u.id', 'u.firstname',
 -                                                 'u.lastname', 'p.modified', 'd.forum');
 -        } else {
 -            list($messagesearch, $msparams) = search_generate_SQL($parsearray, 'p.message', 'p.subject',
 -                                                 'p.userid', 'u.id', 'u.firstname',
 -                                                 'u.lastname', 'p.modified', 'd.forum');
 -        }
 +        list($messagesearch, $msparams) = search_generate_SQL($parsearray, 'p.message', 'p.subject',
 +                                                              'p.userid', 'u.id', 'u.firstname',
 +                                                              'u.lastname', 'p.modified', 'd.forum');
          $params = array_merge($params, $msparams);
      }