From 55e078c0fa48ca63bbd841f42c6a9aa3cf574d25 Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 21 Aug 2002 13:29:25 +0000 Subject: [PATCH] Users can now choose to hide their email address. In this initial version 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 | 4 ++++ user/edit.html | 9 +++++++++ user/lib.php | 4 +++- user/view.php | 4 +++- version.php | 6 +++++- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 4ffce5e9ff8..8945e0e4a2a 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -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"; diff --git a/user/edit.html b/user/edit.html index 4e80e86636f..159e51fc48e 100644 --- a/user/edit.html +++ b/user/edit.html @@ -66,6 +66,15 @@ if (isadmin()) { choose_from_menu ($choices, "mailformat", $user->mailformat, "") ?> + +

: + maildisplay, "") ?> + +

: diff --git a/user/lib.php b/user/lib.php index 3220e6ba62b..7f253a9f05b 100644 --- a/user/lib.php +++ b/user/lib.php @@ -58,7 +58,9 @@ function print_user($user, $course, $string) { echo ""; echo "$user->firstname $user->lastname"; echo "

"; - echo "$string->email: email\">$user->email
"; + if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category) or isteacher($course->id)) { + echo "$string->email: email\">$user->email
"; + } echo "$string->location: $user->city, ".$COUNTRIES["$user->country"]."
"; echo "$string->lastaccess: ".userdate($user->lastaccess); echo "  (".format_time(time() - $user->lastaccess).")"; diff --git a/user/view.php b/user/view.php index 5c36475bdb4..17e67cb5fc4 100644 --- a/user/view.php +++ b/user/view.php @@ -94,7 +94,9 @@ } } - print_row(get_string("email").":", "email\">$user->email"); + if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category) or isteacher($course->id)) { + print_row(get_string("email").":", "email\">$user->email"); + } if ($user->url) { print_row(get_string("webpage").":", "url\">$user->url"); diff --git a/version.php b/version.php index 9c75019172b..78a9d6b0d38 100644 --- a/version.php +++ b/version.php @@ -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; }