]> git.mjollnir.org Git - moodle.git/commitdiff
GUI to allow disabling of user email addresses (from user profile)
authormoodler <moodler>
Fri, 20 Feb 2004 10:27:24 +0000 (10:27 +0000)
committermoodler <moodler>
Fri, 20 Feb 2004 10:27:24 +0000 (10:27 +0000)
lib/moodlelib.php
lib/weblib.php
user/view.php

index 82975cdea47bff99527ba6571fc6ef153616e03b..190d0653c252d89839d69c62a251815d9ab5ed9e 100644 (file)
@@ -1239,7 +1239,11 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a
 
     include_once("$CFG->libdir/phpmailer/class.phpmailer.php");
 
-    if (!$user) {
+    if (empty($user)) {
+        return false;
+    }
+
+    if (!empty($user->emailstop)) {
         return false;
     }
     
index f7dd9fe14f89772c159e1e2d91f349c6e513ce2f..f504b24a65713273b417a0cdcd9e1ec3645a7a27 100644 (file)
@@ -2059,17 +2059,23 @@ function obfuscate_text($plaintext) {
     return $obfuscated;
 }
 
-function obfuscate_mailto($email, $label="") {
+function obfuscate_mailto($email, $label="", $dimmed=false) {
 /// This function uses the above two functions to generate a fully
 /// obfuscated email link, ready to use.
 
     if (empty($label)) {
         $label = $email;
     }
-    return sprintf('<a href="%s:%s" title="%s">%s</a>', obfuscate_text('mailto'),
-                                                        obfuscate_email($email),
-                                                        obfuscate_text($email),
-                                                        obfuscate_text($label));
+    if ($dimmed) {
+        $title = get_string('emaildisable');
+        $dimmed = ' class="dimmed"';
+    } else {
+        $title = '';
+        $dimmed = '';
+    }
+    return sprintf("<a href=\"%s:%s\" $dimmed title=\"$title\">%s</a>", 
+                    obfuscate_text('mailto'), obfuscate_email($email),
+                    obfuscate_text($label));
 }
 
 function print_paging_bar($totalcount, $page, $perpage, $baseurl) {
index 6836f66e9123fdb032c93bb3088ede4aafd7fa53..5f1aad0cc4549a00cfb8069a826b3989ed778da1 100644 (file)
@@ -7,6 +7,8 @@
 
     require_variable($id);
     require_variable($course);
+    optional_variable($enable, "");
+    optional_variable($disable, "");
 
 
     if (! $user = get_record("user", "id", $id) ) {
     }
 
     if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category) or isteacher($course->id)) {
-        print_row(get_string("email").":", obfuscate_mailto($user->email));
+
+        if (isteacheredit($course->id) or $currentuser) {   /// Can use the enable/disable email stuff
+            if (!empty($_GET['enable'])) {     /// Recieved a paramter to enable the email address
+                set_field('user', 'emailstop', 0, 'id', $user->id);
+                $user->emailstop = 0;
+            }
+            if (!empty($_GET['disable'])) {     /// Recieved a paramter to disable the email address
+                set_field('user', 'emailstop', 1, 'id', $user->id);
+                $user->emailstop = 1;
+            }
+            if ($user->emailstop) {
+                $switchparam = 'enable';
+                $switchtitle = get_string('emaildisable');
+                $switchpix   = 'show.gif';
+            } else {
+                $switchparam = 'disable';
+                $switchtitle = get_string('emailenable');
+                $switchpix   = 'hide.gif';
+            }
+            $emailswitch = "&nbsp<a title=\"$switchtitle\" ".
+                           "href=\"view.php?id=$user->id&course=$course->id&$switchparam=$user->id\">".
+                           "<img border=\"0\" width=11 height=11 src=\"$CFG->pixpath/t/$switchpix\"></a>";
+        } else {
+            $emailswitch = '';
+        }
+
+        print_row(get_string("email").":", obfuscate_mailto($user->email, '', $user->emailstop)."$emailswitch");
     }
 
     if ($user->url) {