# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/lib/db/upgrade.php
--- moodle/lib/db/upgrade.php Base (1.503)
+++ moodle/lib/db/upgrade.php Locally Modified (Based On 1.503)
@@ -5399,3 +5399,5 @@
 //TODO: Cleanup before the 2.0 release - we do not want to drag along these dev machine fixes forever
 // 1/ drop block_pinned_old table here and in install.xml
 // 2/ drop block_instance_old table here and in install.xml
+
+//TODO: AFTER 2.0 remove the column user->emailstop and the user preference "message_showmessagewindow"
Index: moodle/lib/messagelib.php
--- moodle/lib/messagelib.php Base (1.31)
+++ moodle/lib/messagelib.php Locally Modified (Based On 1.31)
@@ -296,25 +296,34 @@
 function message_set_default_message_preferences($user) {
     global $DB;
 
-    $defaultonlineprocessor = 'email';
-    $defaultofflineprocessor = 'email';
-    $offlineprocessortouse = $onlineprocessortouse = null;
+    //check for the pre 2.0 disable email setting
+    $useemail = empty($user->emailstop);
 
     //look for the pre-2.0 preference if it exists
     $oldpreference = get_user_preferences('message_showmessagewindow', -1, $user->id);
     //if they elected to see popups or the preference didnt exist
     $usepopups = (intval($oldpreference)==1 || intval($oldpreference)==-1);
 
+    $defaultonlineprocessor = 'none';
+    $defaultofflineprocessor = 'none';
 
+    if ($useemail) {
+        $defaultonlineprocessor = 'email';
+        $defaultofflineprocessor = 'email';
+    } else if ($usepopups) {
+        $defaultonlineprocessor = 'popup';
+        $defaultofflineprocessor = 'popup';
+    }
+
+    $offlineprocessortouse = $onlineprocessortouse = null;
+
     $providers = $DB->get_records('message_providers');
     $preferences = array();
 
     foreach ($providers as $providerid => $provider) {
 
-        //force some specific defaults for some types of message
-
-        //if old popup preference was set to 1 or is missing use popups for IMs
-        if ($provider->name=='instantmessage' && $usepopups) {
+        //force some specific defaults for IMs
+        if ($provider->name=='instantmessage' && $usepopups && $useemail) {
             $onlineprocessortouse = 'popup';
             $offlineprocessortouse = 'email,popup';
         } else {
Index: moodle/lib/moodlelib.php
--- moodle/lib/moodlelib.php Base (1.1496)
+++ moodle/lib/moodlelib.php Locally Modified (Based On 1.1496)
@@ -4762,10 +4762,6 @@
         return true;
     }
 
-    if (!empty($user->emailstop)) {
-        return 'emailstop';
-    }
-
     if (over_bounce_threshold($user)) {
         $bouncemsg = "User $user->id (".fullname($user).") is over bounce threshold! Not sending.";
         error_log($bouncemsg);
Index: moodle/message/output/email/message_output_email.php
--- moodle/message/output/email/message_output_email.php Base (1.16)
+++ moodle/message/output/email/message_output_email.php Locally Modified (Based On 1.16)
@@ -56,7 +56,7 @@
         $result = email_to_user($eventdata->userto, $eventdata->userfrom,
             $eventdata->subject, $eventdata->fullmessage, $eventdata->fullmessagehtml);
 
-        return ($result===true || $result=='emailstop'); //email_to_user() can return true, false or "emailstop"
+        return $result;
     }
 
     /**
Index: moodle/user/profile.php
--- moodle/user/profile.php Base (1.15)
+++ moodle/user/profile.php Locally Modified (Based On 1.15)
@@ -249,49 +249,9 @@
    or ($user->maildisplay == 2 && !isguestuser())
    or has_capability('moodle/course:useremail', $context)) {
 
-    $emailswitch = '';
-
-    if ($currentuser or has_capability('moodle/course:useremail', $context)) {   /// Can use the enable/disable email stuff
-        if (!empty($enable) and confirm_sesskey()) {     /// Recieved a parameter to enable the email address
-            $DB->set_field('user', 'emailstop', 0, array('id'=>$user->id));
-            $user->emailstop = 0;
+    print_row(get_string("email").":", obfuscate_mailto($user->email, '', $user->emailstop));
         }
-        if (!empty($disable) and confirm_sesskey()) {     /// Recieved a parameter to disable the email address
-            $DB->set_field('user', 'emailstop', 1, array('id'=>$user->id));
-            $user->emailstop = 1;
-        }
-    }
 
-    if (has_capability('moodle/course:useremail', $context)) {   /// Can use the enable/disable email stuff
-        if ($user->emailstop) {
-            $switchparam = 'enable';
-            $switchtitle = get_string('emaildisable');
-            $switchclick = get_string('emailenableclick');
-            $switchpix   = 't/emailno';
-        } else {
-            $switchparam = 'disable';
-            $switchtitle = get_string('emailenable');
-            $switchclick = get_string('emaildisableclick');
-            $switchpix   = 't/email';
-        }
-        $emailswitch = "&nbsp;<a title=\"$switchclick\" ".
-                       "href=\"profile.php?id=$user->id&amp;$switchparam=1&amp;sesskey=".sesskey()."\">".
-                       "<img src=\"" . $OUTPUT->pix_url("$switchpix") . "\" alt=\"$switchclick\" /></a>";
-
-    } else if ($currentuser) {         /// Can only re-enable an email this way
-        if ($user->emailstop) {   // Include link that tells how to re-enable their email
-            $switchparam = 'enable';
-            $switchtitle = get_string('emaildisable');
-            $switchclick = get_string('emailenableclick');
-
-            $emailswitch = "&nbsp;(<a title=\"$switchclick\" ".
-                           "href=\"profile.php?id=$user->id&amp;enable=1&amp;sesskey=".sesskey()."\">$switchtitle</a>)";
-        }
-    }
-
-    print_row(get_string("email").":", obfuscate_mailto($user->email, '', $user->emailstop)."$emailswitch");
-}
-
 if ($user->url && !isset($hiddenfields['webpage'])) {
     $url = $user->url;
     if (strpos($user->url, '://') === false) {
