Users can now choose to hide their email address. In this initial version
authormartin <martin>
Wed, 21 Aug 2002 13:29:25 +0000 (13:29 +0000)
committermartin <martin>
Wed, 21 Aug 2002 13:29:25 +0000 (13:29 +0000)
there are three options:

0) Hide the email address from everyone (except the teacher of their course)
1) Allow everyone to see the email address, all the time.
2) Allow only participants in the same course to see the email address

Note, new field maildisplay in 'user'

lang/en/moodle.php
user/edit.html
user/lib.php
user/view.php
version.php

index 4ffce5e9ff8e18e4f491073266fff4a653d10b67..8945e0e4a2a58101f366a2e8037f816cdc43dfee 100644 (file)
@@ -99,6 +99,10 @@ line at the top of your web browser window.
 Cheers from the '\$a->sitename' administrator,
 \$a->admin";
 
+$string[emaildisplay] = "Email display";
+$string[emaildisplayno] = "Hide my real email address from everyone";
+$string[emaildisplayyes] = "Allow everyone to see my email address";
+$string[emaildisplaycourse] = "Allow only other course members to see my email address";
 $string[emailexists] = "This email address is already registered.";
 $string[emailmustbereal] = "Note: your email address must be a real one";
 $string[enrolmentkey] = "Enrolment key";
index 4e80e86636f4add066bd998350a3bb51654f3db1..159e51fc48ed145fdf92c9da89c97ab7642c4e84 100644 (file)
@@ -66,6 +66,15 @@ if (isadmin()) {
     choose_from_menu ($choices, "mailformat", $user->mailformat, "") ?>
        </td>
 </tr>
+<tr valign=top>
+       <td><P><? print_string("emaildisplay") ?>:</td>
+       <td><? 
+    $choices["0"] = get_string("emaildisplayno");
+    $choices["1"] = get_string("emaildisplayyes");
+    $choices["2"] = get_string("emaildisplaycourse");
+    choose_from_menu ($choices, "maildisplay", $user->maildisplay, "") ?>
+       </td>
+</tr>
 <tr valign=top>
        <td><P><? print_string("webpage") ?>:</td>
        <td><input type="text" name="url" size=30 value="<? p($user->url) ?>">
index 3220e6ba62bb3252d595f5565e38c10b5f1cbd58..7f253a9f05b7ad119145226f4c222e1deadbfd2a 100644 (file)
@@ -58,7 +58,9 @@ function print_user($user, $course, $string) {
     echo "<FONT SIZE=-1>";
     echo "<FONT SIZE=3><B>$user->firstname $user->lastname</B></FONT>";
     echo "<P>";
-    echo "$string->email: <A HREF=\"mailto:$user->email\">$user->email</A><BR>";
+    if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category) or isteacher($course->id)) {
+        echo "$string->email: <A HREF=\"mailto:$user->email\">$user->email</A><BR>";
+    }
     echo "$string->location: $user->city, ".$COUNTRIES["$user->country"]."<BR>";
     echo "$string->lastaccess: ".userdate($user->lastaccess);
     echo "&nbsp (".format_time(time() - $user->lastaccess).")";
index 5c36475bdb4336ec24ce2c265c750ae099fd0f49..17e67cb5fc452b96b71a76a803c95d7bd1ab9b82 100644 (file)
@@ -94,7 +94,9 @@
         }
     }
 
-    print_row(get_string("email").":", "<A HREF=\"mailto:$user->email\">$user->email</A>");
+    if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category) or isteacher($course->id)) {
+        print_row(get_string("email").":", "<A HREF=\"mailto:$user->email\">$user->email</A>");
+    }
 
     if ($user->url) {
         print_row(get_string("webpage").":", "<A HREF=\"$user->url\">$user->url</A>");
index 9c75019172b8e44231c6702b83fec04273538ac5..78a9d6b0d38867e1ce40094048cceb9d58648c48 100644 (file)
@@ -17,7 +17,7 @@
 // If there's something it cannot do itself, it 
 // will tell you what you need to do.
 
-$version = 2002082100;
+$version = 2002082101;
 
 function upgrade_moodle($oldversion=0) {
 
@@ -51,6 +51,10 @@ function upgrade_moodle($oldversion=0) {
         execute_sql(" ALTER TABLE `course` CHANGE `guest` `guest` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL ");
     }
 
+    if ($oldversion < 2002082101) {
+        execute_sql("  ALTER TABLE `user` ADD `maildisplay` TINYINT(2) UNSIGNED DEFAULT '2' NOT NULL AFTER `mailformat` ");
+    }
+
     return true;
 }