From c299f69e9fcf16e26d47242713dc1398fc421ed0 Mon Sep 17 00:00:00 2001 From: meirzamoodle Date: Tue, 1 Oct 2024 20:18:51 +0700 Subject: [PATCH] MDL-61232 core: Remove process_email.php and anything related to it --- .upgradenotes/MDL-61232-2024100101072668.yml | 6 ++ admin/process_email.php | 80 -------------------- lang/en/deprecated.txt | 2 + lang/en/moodle.php | 8 +- lib/deprecatedlib.php | 37 +++++++++ lib/moodlelib.php | 29 ------- 6 files changed, 49 insertions(+), 113 deletions(-) create mode 100644 .upgradenotes/MDL-61232-2024100101072668.yml delete mode 100644 admin/process_email.php diff --git a/.upgradenotes/MDL-61232-2024100101072668.yml b/.upgradenotes/MDL-61232-2024100101072668.yml new file mode 100644 index 00000000000..5030d1bf22b --- /dev/null +++ b/.upgradenotes/MDL-61232-2024100101072668.yml @@ -0,0 +1,6 @@ +issueNumber: MDL-61232 +notes: + core: + - message: | + moodle_process_email() has been deprecated with the removal of the unused and non-functioning admin/process_email.php. + type: removed diff --git a/admin/process_email.php b/admin/process_email.php deleted file mode 100644 index 6d7ed7181ae..00000000000 --- a/admin/process_email.php +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/php -f -noreplyaddress) { - $user = new stdClass(); - $user->email = $_ENV['SENDER']; - - if (!validate_email($user->email)) { - die(); - } - - $site = get_site(); - $subject = get_string('noreplybouncesubject','moodle',format_string($site->fullname)); - $body = get_string('noreplybouncemessage','moodle',format_string($site->fullname))."\n\n"; - - $fd = fopen('php://stdin','r'); - if ($fd) { - while(!feof($fd)) { - $body .= fgets($fd); - } - fclose($fd); - } - - $user->id = 0; // to prevent anything annoying happening - - $from->firstname = null; - $from->lastname = null; - $from->email = '<>'; - $from->maildisplay = true; - - email_to_user($user,$from,$subject,$body); - die (); -} -/// ALL OTHER PROCESSING -// we need to split up the address -$prefix = substr($address,0,4); -$mod = substr($address,4,2); -$modargs = substr($address,6,-16); -$hash = substr($address,-16); - -if (substr(md5($prefix.$mod.$modargs.$CFG->siteidentifier),0,16) != $hash) { - die("HASH DIDN'T MATCH!\n"); -} -list(,$modid) = unpack('C',base64_decode($mod.'==')); - -if ($modid == '0') { // special - $modname = 'moodle'; -} -else { - $modname = $DB->get_field("modules", "name", array("id"=>$modid)); - include_once('mod/'.$modname.'/lib.php'); -} -$function = $modname.'_process_email'; - -if (!function_exists($function)) { - die(); -} -$fd = fopen('php://stdin','r'); -if (!$fd) { - exit(); -} - -while(!feof($fd)) { - $body .= fgets($fd); -} - -$function($modargs,$body); - -fclose($fd); - - - - diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index 5d8b2e53361..dfaadb3a558 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -134,3 +134,5 @@ filterbothactive,core_grades filterbyname,core_grades filterfirstactive,core_grades filterlastactive,core_grades +noreplybouncemessage,core +noreplybouncesubject,core diff --git a/lang/en/moodle.php b/lang/en/moodle.php index dd4bfcc2557..713788bc6ed 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1551,10 +1551,6 @@ $string['nopotentialcreators'] = 'No potential course creators'; $string['nopotentialstudents'] = 'No potential students'; $string['nopotentialteachers'] = 'No potential teachers'; $string['norecentactivity'] = 'No recent activity'; -$string['noreplybouncemessage'] = 'You have replied to a no-reply email address. If you were attempting to reply to a forum post, please instead reply using the {$a} forums. - -Following is the content of your email:'; -$string['noreplybouncesubject'] = '{$a} - bounced email.'; $string['noreplyname'] = 'Do not reply to this email'; $string['noresetrecord'] = 'There is no record of that reset request. Please initiate a new password reset request.'; $string['noresults'] = 'No results'; @@ -2522,5 +2518,9 @@ line at the top of your web browser window. Cheers from the \'{$a->sitename}\' administrator, {$a->signoff}'; +$string['noreplybouncemessage'] = 'You have replied to a no-reply email address. If you were attempting to reply to a forum post, please instead reply using the {$a} forums. + +Following is the content of your email:'; +$string['noreplybouncesubject'] = '{$a} - bounced email.'; $string['registrationcontactno'] = 'No, I do not want to be contacted by other people'; $string['registrationcontactyes'] = 'Yes, provide a form for other Moodlers to contact me'; diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index b55e87cf00f..bff504c0899 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -785,3 +785,40 @@ function plagiarism_get_file_results(): void { function plagiarism_update_status(): void { \core\deprecation::emit_deprecation_if_present(__FUNCTION__); } + +/** + * ? + * + * @param string $modargs + * @param string $body Currently unused + * + * @deprecated Since Moodle 5.0 + * @todo Final deprecation on Moodle 6.0. See MDL-83366. + */ +#[\core\attribute\deprecated( + replacement: null, + since: '5.0', + mdl: 'MDL-83366', + reason: 'The function is no longer used with the removal of the unused and non-functioning admin/process_email.php.', +)] +function moodle_process_email($modargs, $body) { + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); + global $DB; + + // The first char should be an unencoded letter. We'll take this as an action. + switch ($modargs[0]) { + case 'B': { // Bounce. + list(, $userid) = unpack('V', base64_decode(substr($modargs, 1, 8))); + if ($user = $DB->get_record("user", array('id' => $userid), "id,email")) { + // Check the half md5 of their email. + $md5check = substr(md5($user->email), 0, 16); + if ($md5check == substr($modargs, -16)) { + set_bounce_count($user); + } + // Else maybe they've already changed it? + } + } + break; + // Maybe more later? + } +} diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 1c24f74c5ec..9bb601c258c 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5355,35 +5355,6 @@ function generate_email_processing_address($modid, $modargs) { return $header . substr(md5($header.get_site_identifier()), 0, 16).'@'.$CFG->maildomain; } -/** - * ? - * - * @todo Finish documenting this function - * - * @param string $modargs - * @param string $body Currently unused - */ -function moodle_process_email($modargs, $body) { - global $DB; - - // The first char should be an unencoded letter. We'll take this as an action. - switch ($modargs[0]) { - case 'B': { // Bounce. - list(, $userid) = unpack('V', base64_decode(substr($modargs, 1, 8))); - if ($user = $DB->get_record("user", array('id' => $userid), "id,email")) { - // Check the half md5 of their email. - $md5check = substr(md5($user->email), 0, 16); - if ($md5check == substr($modargs, -16)) { - set_bounce_count($user); - } - // Else maybe they've already changed it? - } - } - break; - // Maybe more later? - } -} - // CORRESPONDENCE. /**