--- admin/settings/security.php	2010-09-09 11:41:29.000000000 +0100
+++ admin/settings/security.php	2010-09-09 11:43:35.000000000 +0100
@@ -53,6 +53,7 @@
     $temp->add(new admin_setting_configtext('minpasswordupper', get_string('minpasswordupper', 'admin'), get_string('configminpasswordupper', 'admin'), 1, PARAM_INT));
     $temp->add(new admin_setting_configtext('minpasswordnonalphanum', get_string('minpasswordnonalphanum', 'admin'), get_string('configminpasswordnonalphanum', 'admin'), 1, PARAM_INT));
     $temp->add(new admin_setting_configcheckbox('disableuserimages', get_string('disableuserimages', 'admin'), get_string('configdisableuserimages', 'admin'), 0));
+    $temp->add(new admin_setting_configcheckbox('displaydeleteduserimages', get_string('displaydeleteduserimages', 'admin'), get_string('configdisplaydeleteduserimages', 'admin'), 0));
     $temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', get_string('emailchangeconfirmation', 'admin'), get_string('configemailchangeconfirmation', 'admin'), 1));
     $temp->add(new admin_setting_configcheckbox('enablenotes', get_string('enablenotes', 'notes'), get_string('configenablenotes', 'notes'), 1));
     $ADMIN->add('security', $temp);
--- lang/en_utf8/admin.php	2010-09-09 11:47:52.000000000 +0100
+++ lang/en_utf8/admin.php	2010-09-09 11:46:41.000000000 +0100
@@ -102,6 +102,7 @@
 $string['configdenyemailaddresses'] = 'To deny email addresses from particular domains list them here in the same way.  All other domains will be accepted. To deny subdomains add the domain with a preceding \'.\'. eg <strong>hotmail.com yahoo.co.uk .live.com</strong>';
 $string['configdigestmailtime'] = 'People who choose to have emails sent to them in digest form will be emailed the digest daily. This setting controls which time of day the daily mail will be sent (the next cron that runs after this hour will send it).';
 $string['configdisableuserimages'] = 'Disable the ability for users to change user profile images.';
+$string['configdisplaydeleteduserimages'] = 'Display the user profile image of deleted users.';
 $string['configdisplayloginfailures'] = 'This will display information to selected users about previous failed logins.';
 $string['configdocroot'] = 'Defines the path to the Moodle Docs. You can change this if you wish to have your own custom online documentation. However, if you do that make sure that the paths in your documentation follow the same format as http://docs.moodle.org.';
 $string['configdoctonewwindow'] = 'If you enable this, then links to Moodle Docs will be shown in a new window.';
@@ -332,6 +333,7 @@
 $string['digestmailtime'] = 'Hour to send digest emails';
 $string['disablecourseajax'] = 'Disable AJAX course editing';
 $string['disableuserimages'] = 'Disable User Profile Images';
+$string['displaydeleteduserimages'] = 'Display Deleted User Profile Images';
 $string['displayerrorswarning'] = 'Enabling the PHP setting <em>display_errors</em> is not recommended on production sites because some error messages may reveal sensitive information about your server.';
 $string['displayloginfailures'] = 'Display login failures to';
 $string['docroot'] = 'Moodle Docs document root';
--- user/pix.php	2010-09-09 12:04:06.000000000 +0100
+++ user/pix.php	2010-09-09 12:05:53.000000000 +0100
@@ -21,12 +21,13 @@
 
     if (count($args) == 2) {
         $userid   = (integer)$args[0];
-        // do not serve images of deleted users
-        if ($user = get_record('user', 'id', $userid, 'deleted', 0, 'picture', 1)) {
-            $image    = $args[1];
-            $pathname = make_user_directory($userid, true) . "/$image";
-            if (file_exists($pathname) and !is_dir($pathname)) {
-                send_file($pathname, $image);
+        if ($user = get_record('user', 'id', $userid, 'picture', 1)) {
+            if (!$user->deleted || ($user->deleted && $CFG->displaydeleteduserimages)) {
+                $image    = $args[1];
+                $pathname = make_user_directory($userid, true) . "/$image";
+                if (file_exists($pathname) and !is_dir($pathname)) {
+                    send_file($pathname, $image);
+                }
             }
         }
     }
