]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed bug 1535. Unless $CFG->forum_replytouser is set to 1 AND the user has set maild...
authorgustav_delius <gustav_delius>
Sun, 6 Jun 2004 12:49:55 +0000 (12:49 +0000)
committergustav_delius <gustav_delius>
Sun, 6 Jun 2004 12:49:55 +0000 (12:49 +0000)
admin/config.html
lang/en/forum.php
lang/en/moodle.php
lib/defaults.php
lib/moodlelib.php
mod/forum/config.html
mod/forum/lib.php

index c3b87ecf89ecf89a43f13393f1b0411d95a5db28..1e98aad0f4eca3c0f4b50592933a6e88c45e8269 100644 (file)
@@ -2,8 +2,8 @@
 
 <table cellpadding=9 cellspacing=0 >
 <tr valign=top>
-       <td align=right><p>lang:</td>
-       <td>
+    <td align=right><p>lang:</td>
+    <td>
     <?php choose_from_menu (get_list_of_languages(), "lang", $config->lang, "", "", ""); ?>
     </td>
     <td>
@@ -11,8 +11,8 @@
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>langmenu:</td>
-       <td>
+    <td align=right><p>langmenu:</td>
+    <td>
     <?php
        unset($options);
        $options[0] = get_string("no");
@@ -26,8 +26,8 @@
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>langlist:</td>
-       <td>
+    <td align=right><p>langlist:</td>
+    <td>
     <input name=langlist type=text size=40 value="<?php p($config->langlist) ?>">
     </td>
     <td>
@@ -35,8 +35,8 @@
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>locale:</td>
-       <td>
+    <td align=right><p>locale:</td>
+    <td>
     <input name=locale type=text size=10 value="<?php p($config->locale) ?>">
     </td>
     <td>
@@ -44,7 +44,7 @@
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>timezone:</td>
+    <td align=right><p>timezone:</td>
     <td><?php
        if (abs($config->timezone) > 13) {
            $config->timezone = 99;
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>country:</td>
-       <td><?php choose_from_menu (get_list_of_countries(), "country", $config->country, get_string("selectacountry"), "") ?>
-       </td>
+    <td align=right><p>country:</td>
+    <td><?php choose_from_menu (get_list_of_countries(), "country", $config->country, get_string("selectacountry"), "") ?>
+    </td>
     <td>
     <?php print_string("configcountry") ?>
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>smtphosts:</td>
-       <td>
+    <td align=right><p>smtphosts:</td>
+    <td>
     <input name=smtphosts type=text size=30 value="<?php p($config->smtphosts)?>">
     </td>
     <td>
@@ -88,8 +88,8 @@
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>smtpuser:</td>
-       <td>
+    <td align=right><p>smtpuser:</td>
+    <td>
     <input name=smtpuser type=text size=10 value="<?php p($config->smtpuser)?>">
     </td>
     <td rowspan=2>
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>smtppass:</td>
-       <td>
+    <td align=right><p>smtppass:</td>
+    <td>
     <input name=smtppass type=text size=10 value="<?php p($config->smtppass)?>">
     </td>
-</TR>
+</tr>
 <tr valign=top>
-       <td align=right><p>gdversion:</td>
-       <td>
+    <td align=right><p>noreplyaddress:</td>
+    <td>
+    <input name=noreplyaddress type=text size=30 value="<?php p($config->noreplyaddress)?>">
+    </td>
+    <td>
+    <?php print_string("confignoreplyaddress") ?>
+    </td>
+</tr>
+<tr valign=top>
+    <td align=right><p>gdversion:</td>
+    <td>
     <?php
        unset($options);
        $options[0] = get_string("gdnot");
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>maxeditingtime:</td>
-       <td>
+    <td align=right><p>maxeditingtime:</td>
+    <td>
     <?php
        unset($options);
        $options[3600] = get_string("numminutes", "", 60);
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>longtimenosee:</td>
-       <td>
+    <td align=right><p>longtimenosee:</td>
+    <td>
     <?php
        unset($options);
        $options[1000] = get_string("numdays", "", 1000);
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>deleteunconfirmed:</td>
-       <td>
+    <td align=right><p>deleteunconfirmed:</td>
+    <td>
     <?php
        unset($options);
        $options[0]    = get_string("never");
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>loglifetime:</td>
-       <td>
+    <td align=right><p>loglifetime:</td>
+    <td>
     <?php
        unset($options);
        $options[0]    = get_string("neverdeletelogs");
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>sessiontimeout:</td>
-       <td>
+    <td align=right><p>sessiontimeout:</td>
+    <td>
     <?php
        unset($options);
        $options[14400] = get_string("numhours", "", 4);
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>sessioncookie:</td>
-       <td>
+    <td align=right><p>sessioncookie:</td>
+    <td>
     <input name=sessioncookie type=text size=10 value="<?php p($config->sessioncookie)?>">
     </td>
     <td>
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>zip:</td>
-       <td>
+    <td align=right><p>zip:</td>
+    <td>
     <input name=zip type=text size=30 value="<?php p($config->zip) ?>">
     </td>
     <td>
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>unzip:</td>
-       <td>
+    <td align=right><p>unzip:</td>
+    <td>
     <input name=unzip type=text size=30 value="<?php p($config->unzip) ?>">
     </td>
     <td>
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>slasharguments:</td>
-       <td>
+    <td align=right><p>slasharguments:</td>
+    <td>
     <?php unset($options);
        $options[0] = "file.php?file=/pic.jpg";
        $options[1] = "file.php/pic.jpg";
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>proxyhost:</td>
-       <td>
+    <td align=right><p>proxyhost:</td>
+    <td>
     <input name=proxyhost type=text size=30 value="<?php p($config->proxyhost) ?>">
     </td>
     <td rowspan=2>
     </td>
 </TR>
 <tr valign=top>
-       <td align=right><p>proxyport:</td>
-       <td>
+    <td align=right><p>proxyport:</td>
+    <td>
     <input name=proxyport type=text size=5 value="<?php p($config->proxyport) ?>">
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>debug:</td>
-       <td>
+    <td align=right><p>debug:</td>
+    <td>
     <?php
        unset($options);
        $options[7]  = get_string("no");
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>framename:</td>
-       <td>
+    <td align=right><p>framename:</td>
+    <td>
     <?php
        if (empty($config->framename)) {
            $config->framename = "_top";
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>secureforms:</td>
-       <td>
+    <td align=right><p>secureforms:</td>
+    <td>
     <?php
        unset($options);
        $options[0]  = get_string("no");
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>teacherassignteachers:</td>
-       <td>
+    <td align=right><p>teacherassignteachers:</td>
+    <td>
     <?php
        unset($options);
        $options[0]  = get_string("no");
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>allowunenroll:</td>
-       <td>
+    <td align=right><p>allowunenroll:</td>
+    <td>
     <?php
        unset($options);
        $options[0]  = get_string("no");
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>maxbytes:</td>
-       <td>
+    <td align=right><p>maxbytes:</td>
+    <td>
     <?php
        $options = get_max_upload_sizes();
        choose_from_menu ($options, "maxbytes", $config->maxbytes, "");
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>fullnamedisplay:</td>
-       <td>
+    <td align=right><p>fullnamedisplay:</td>
+    <td>
     <?php
        unset($options);
        $options['language']  = get_string('language');
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>extendedusernamechars:</td>
-       <td>
+    <td align=right><p>extendedusernamechars:</td>
+    <td>
     <?php
        unset($options);
        $options[0] = get_string("no");
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>forcelogin:</td>
-       <td>
+    <td align=right><p>forcelogin:</td>
+    <td>
     <?php
        unset($options);
        $options[0]  = get_string('no');
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>forceloginforprofiles:</td>
-       <td>
+    <td align=right><p>forceloginforprofiles:</td>
+    <td>
     <?php
        unset($options);
        $options[0]  = get_string('no');
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>opentogoogle:</td>
-       <td>
+    <td align=right><p>opentogoogle:</td>
+    <td>
     <?php
        unset($options);
        $options[0] = get_string("no");
         <td align=right><p>digestmailtime:</td>
         <td>
     <?php
-       $hours = array();
-       for ($i=0; $i<=23; $i++) {
-               $hours[$i] = sprintf("%02d",$i);
-       }
+        $hours = array();
+        for ($i=0; $i<=23; $i++) {
+            $hours[$i] = sprintf("%02d",$i);
+        }
         choose_from_menu($hours, 'digestmailtime', $config->digestmailtime, "");
     ?>
     </td>
 
 <tr>
     <td colspan=3 align=center>
-       <input type="submit" value="<?php print_string("savechanges") ?>"></td>
+    <input type="submit" value="<?php print_string("savechanges") ?>"></td>
 </tr>
 </table>
 
index 28ad319dae432a93453f082ef4f39494a6e8db0e..93c36395ac36ab50265e04373c053bc5a7729bb2 100644 (file)
@@ -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.';
index 6d160f23612563504f98cb17766c9d0e593dddc3..797084e5e7e7e1ffc83940da24dcfc4bb5f14d87 100644 (file)
@@ -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 <B>server</B> 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\'.';
index 9cf1c8903f08fc0203b0dc35c250fcb952ce93d6..c36ee08c34dc1f8ee82f778eb39c0e1f9f75361e 100644 (file)
@@ -30,6 +30,7 @@
        "longtimenosee"    =>  100,
        "maxbytes"         =>  0,
        "maxeditingtime"   =>  1800,
+       "noreplyaddress"   => 'noreply@'.$_SERVER['HTTP_HOST'],
        "opentogoogle"     =>  false,
        "prefix"           => "",
        "proxyhost"        => "",
index 94409c2a9241d37b4c5a13eaa007eda1ad303ba9..9219f2024c3719d17a9061796826fe63f9cf934a 100644 (file)
@@ -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) );
index 783cabe9cd05838c32819b91448838bb9b854c13..84eea3e122b017e498fc08d7331ca4d6566a3975 100644 (file)
@@ -2,8 +2,8 @@
 
 <table cellpadding=9 cellspacing=0 >
 <tr valign=top>
-       <td align=right><p>forum_displaymode:</td>
-       <td>
+    <td align=right><p>forum_displaymode:</td>
+    <td>
     <?php choose_from_menu ($FORUM_LAYOUT_MODES, "forum_displaymode", $CFG->forum_displaymode, "", "", ""); ?>
     </td>
     <td>
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>forum_shortpost:</td>
-       <td>
+    <td align=right><p>forum_replytouser:</td>
+    <td>
+    <?php
+       unset($options);
+       $options[0] = get_string("no");
+       $options[1] = get_string("yes");
+       choose_from_menu ($options, "forum_replytouser", $CFG->forum_replytouser, "", "", "");
+    ?>
+    </td>
+    <td>
+    <?php print_string("configreplytouser", "forum") ?>
+    </td>
+</tr>
+<tr valign=top>
+    <td align=right><p>forum_shortpost:</td>
+    <td>
     <input name=forum_shortpost type=text size=5 value="<?php p($CFG->forum_shortpost) ?>">
     </td>
     <td>
@@ -20,8 +34,8 @@
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>forum_longpost:</td>
-       <td>
+    <td align=right><p>forum_longpost:</td>
+    <td>
     <input name=forum_longpost type=text size=5 value="<?php p($CFG->forum_longpost) ?>">
     </td>
     <td>
@@ -29,8 +43,8 @@
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>forum_manydiscussions:</td>
-       <td>
+    <td align=right><p>forum_manydiscussions:</td>
+    <td>
     <input name=forum_manydiscussions type=text size=5 value="<?php p($CFG->forum_manydiscussions) ?>">
     </td>
     <td>
@@ -38,7 +52,7 @@
     </td>
 </tr>
 <tr valign=top>
-       <td align=right><p>forum_maxbytes:</td>
+    <td align=right><p>forum_maxbytes:</td>
     <td><?php
     $choices = get_max_upload_sizes($CFG->maxbytes);
     choose_from_menu ($choices, "forum_maxbytes", $CFG->forum_maxbytes, "");
@@ -75,7 +89,7 @@
 
 <tr>
     <td colspan=3 align=center>
-       <input type="submit" value="<?php print_string("savechanges") ?>"></td>
+    <input type="submit" value="<?php print_string("savechanges") ?>"></td>
 </tr>
 </table>
 
index 10488f6415ba3b9cccc529a9605f4afa67ea3529..a712c589a00c93c37718a9fd91e5721460a2f096 100644 (file)
@@ -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 .= '<hr size="1" noshade="noshade" /></p>';
                 }
 
-                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);