From: gustav_delius Date: Sun, 6 Jun 2004 12:49:55 +0000 (+0000) Subject: Fixed bug 1535. Unless $CFG->forum_replytouser is set to 1 AND the user has set maild... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6e506bf902f5c71d25711ec56a2b9d16d09c4b96;p=moodle.git Fixed bug 1535. Unless $CFG->forum_replytouser is set to 1 AND the user has set maildisplay nonzero, the address $CFG->noreplyaddress is sent instead of the user's address. --- diff --git a/admin/config.html b/admin/config.html index c3b87ecf89..1e98aad0f4 100644 --- a/admin/config.html +++ b/admin/config.html @@ -2,8 +2,8 @@ - - + - - + - - + - - + - + - - + + - - + - - + - - + - + - - + + + + + + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + @@ -507,7 +516,7 @@ + ">

lang:

+

lang:

lang, "", "", ""); ?> @@ -11,8 +11,8 @@

langmenu:

+

langmenu:

langlist:

+

langlist:

@@ -35,8 +35,8 @@

locale:

+

locale:

@@ -44,7 +44,7 @@

timezone:

timezone:

timezone) > 13) { $config->timezone = 99; @@ -71,16 +71,16 @@

country:

country, get_string("selectacountry"), "") ?> -

country:

country, get_string("selectacountry"), "") ?> +

smtphosts:

+

smtphosts:

@@ -88,8 +88,8 @@

smtpuser:

+

smtpuser:

@@ -97,14 +97,23 @@

smtppass:

+

smtppass:

gdversion:

+

noreplyaddress:

+ + + +

gdversion:

maxeditingtime:

+

maxeditingtime:

longtimenosee:

+

longtimenosee:

deleteunconfirmed:

+

deleteunconfirmed:

loglifetime:

+

loglifetime:

sessiontimeout:

+

sessiontimeout:

sessioncookie:

+

sessioncookie:

@@ -255,8 +264,8 @@

zip:

+

zip:

@@ -264,8 +273,8 @@

unzip:

+

unzip:

@@ -273,8 +282,8 @@

slasharguments:

+

slasharguments:

proxyhost:

+

proxyhost:

@@ -296,14 +305,14 @@

proxyport:

+

proxyport:

debug:

+

debug:

framename:

+

framename:

framename)) { $config->framename = "_top"; @@ -331,8 +340,8 @@

secureforms:

+

secureforms:

teacherassignteachers:

+

teacherassignteachers:

allowunenroll:

+

allowunenroll:

maxbytes:

+

maxbytes:

maxbytes, ""); @@ -388,8 +397,8 @@

fullnamedisplay:

+

fullnamedisplay:

extendedusernamechars:

+

extendedusernamechars:

forcelogin:

+

forcelogin:

forceloginforprofiles:

+

forceloginforprofiles:

opentogoogle:

+

opentogoogle:

digestmailtime:

digestmailtime, ""); ?>
- ">
diff --git a/lang/en/forum.php b/lang/en/forum.php index 28ad319dae..93c36395ac 100644 --- a/lang/en/forum.php +++ b/lang/en/forum.php @@ -16,6 +16,7 @@ $string['configenablerssfeeds'] = 'This switch will enable the possibility of RS $string['configlongpost'] = 'Any post over this length (not including HTML) is considered long.'; $string['configmanydiscussions'] = 'Maximum number of discussions shown in a forum per page'; $string['configmaxbytes'] = 'Default maximum size for all forum attachments on the site (subject to course limits and other local settings)'; +$string['configreplytouser'] = 'When a forum post is mailed out, should it contain the user\'s email address so that recipients can reply personally rather than via the forum? Even if set to \'Yes\' users can choose in their profile to keep their email address secret.'; $string['configshortpost'] = 'Any post under this length (not including HTML) is considered short.'; $string['couldnotadd'] = 'Could not add your post due to an unknown error'; $string['couldnotdeleteratings'] = 'Sorry, that cannot be deleted as people have already rated it'; @@ -78,6 +79,7 @@ $string['nomorepostscontaining'] = 'No more posts containing \'$a\' were found'; $string['nonews'] = 'No news has been posted yet'; $string['noposts'] = 'No posts'; $string['nopostscontaining'] = 'No posts containing \'$a\' were found'; +$string['noreply'] = ''; $string['nosubscribers'] = 'There are no subscribers yet for this forum'; $string['notingroup'] = 'Sorry, but you need to be part of a group to see this forum.'; $string['nownotsubscribed'] = '$a->name will NOT receive copies of \'$a->forum\' by email.'; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 6d160f2361..797084e5e7 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -167,6 +167,7 @@ $string['configloglifetime'] = 'This specifies the length of time you want to ke $string['configlongtimenosee'] = 'If students haven\'t logged in for a very long time, then they are automatically unsubscribed from courses. This parameter specifies that time limit.'; $string['configmaxbytes'] = 'This specifies a maximum size that uploaded files can be throughout the whole site. This setting is limited by the PHP setting upload_max_filesize and the Apache setting LimitRequestBody. In turn, maxbytes limits the range of sizes that can be chosen at course level or module level.'; $string['configmaxeditingtime'] = 'This specifies the amount of time people have to re-edit forum postings, journal feedback etc. Usually 30 minutes is a good value.'; +$string['confignoreplyaddress'] = 'When Moodle sends out emails on behalf of a user then this address is used as the return address in cases where the recipients should not reply to the user directly.'; $string['configopentogoogle'] = 'If you enable this setting, then Google will be allowed to enter your site as a Guest. In addition, people coming in to your site via a Google search will automatically be logged in as a Guest. Note that this only provides transparent access to courses that already allow guest access.'; $string['configproxyhost'] = 'If this server needs to use a proxy computer (eg a firewall) to access the Internet, then provide the proxy hostname and port here. Otherwise leave it blank.'; $string['configsecureforms'] = 'Moodle can use an additional level of security when accepting data from web forms. If this is enabled, then the browser\'s HTTP_REFERER variable is checked against the current form address. In a very few cases this can cause problems if the user is using a firewall (eg Zonealarm) configured to strip HTTP_REFERER from their web traffic. Symptoms are getting \'stuck\' on a form. If your users are having problems with the login page (for example) you might want to disable this setting, although it might leave your site more open to brute-force password attacks. If in doubt, leave this set to \'Yes\'.'; diff --git a/lib/defaults.php b/lib/defaults.php index 9cf1c8903f..c36ee08c34 100644 --- a/lib/defaults.php +++ b/lib/defaults.php @@ -30,6 +30,7 @@ "longtimenosee" => 100, "maxbytes" => 0, "maxeditingtime" => 1800, + "noreplyaddress" => 'noreply@'.$_SERVER['HTTP_HOST'], "opentogoogle" => false, "prefix" => "", "proxyhost" => "", diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 94409c2a92..9219f2024c 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1214,7 +1214,7 @@ function setup_and_print_groups($course, $groupmode, $urlroot) { /// CORRESPONDENCE //////////////////////////////////////////////// -function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $attachment="", $attachname="") { +function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $attachment="", $attachname="", $usetrueaddress=true) { /// user - a user record as an object /// from - a user record as an object /// subject - plain text subject line of the email @@ -1222,6 +1222,8 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a /// messagehtml - complete html version of the message (optional) /// attachment - a file on the filesystem, relative to $CFG->dataroot /// attachname - the name of the file (extension indicates MIME) +/// usetrueaddress - determines whether $from email address should be sent out. +/// Will be overruled by user profile setting for maildisplay global $CFG, $_SERVER; @@ -1275,8 +1277,13 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a $mail->Sender = "$adminuser->email"; - $mail->From = "$from->email"; - $mail->FromName = fullname($from); + if ($usetrueaddress and $from->maildisplay) { + $mail->From = "$from->email"; + $mail->FromName = fullname($from); + } else { + $mail->From = "$CFG->noreplyaddress"; + $mail->FromName = fullname($from).' '.get_string('noreply', 'forum'); + } $mail->Subject = stripslashes($subject); $mail->AddAddress("$user->email", fullname($user) ); diff --git a/mod/forum/config.html b/mod/forum/config.html index 783cabe9cd..84eea3e122 100644 --- a/mod/forum/config.html +++ b/mod/forum/config.html @@ -2,8 +2,8 @@ - - + - - + + + + + + - - + - - + - + + ">

forum_displaymode:

+

forum_displaymode:

forum_displaymode, "", "", ""); ?> @@ -11,8 +11,22 @@

forum_shortpost:

+

forum_replytouser:

+ forum_replytouser, "", "", ""); + ?> + + +

forum_shortpost:

@@ -20,8 +34,8 @@

forum_longpost:

+

forum_longpost:

@@ -29,8 +43,8 @@

forum_manydiscussions:

+

forum_manydiscussions:

@@ -38,7 +52,7 @@

forum_maxbytes:

forum_maxbytes:

maxbytes); choose_from_menu ($choices, "forum_maxbytes", $CFG->forum_maxbytes, ""); @@ -75,7 +89,7 @@
- ">
diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 10488f6415..a712c589a0 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -294,7 +294,7 @@ function forum_cron () { $posttext = forum_make_mail_text($course, $forum, $discussion, $post, $userfrom, $userto); $posthtml = forum_make_mail_html($course, $forum, $discussion, $post, $userfrom, $userto); - if (! email_to_user($userto, $userfrom, $postsubject, $posttext, $posthtml)) { + if (! email_to_user($userto, $userfrom, $postsubject, $posttext, $posthtml, '', '', $CFG->forum_replytouser)) { echo "Error: mod/forum/cron.php: Could not send out mail for id $post->id to user $userto->id ($userto->email) .. not trying again.\n"; add_to_log($course->id, 'forum', 'mail error', "discuss.php?d=$discussion->id#$post->id", substr($post->subject,0,15), $cm->id, $userto->id); $errorcount++; @@ -450,7 +450,7 @@ function forum_cron () { $posthtml .= '

'; } - if (! email_to_user($userto, $userfrom, $postsubject, $posttext, $posthtml)) { + if (! email_to_user($userto, $userfrom, $postsubject, $posttext, $posthtml, '', '', $CFG->forum_replytouser)) { echo "ERROR!\n"; echo "Error: mod/forum/cron.php: Could not send out digest mail to user $userto->id ($userto->email)... not trying again.\n"; add_to_log($course->id, 'forum', 'mail digest error', '', '', $cm->id, $userto->id);