$options->folderid = $trash->id; $success = true; $mails = email_get_mails($USER->id, $course->id, NULL, '', '', $options); // Delete reference mails if (!delete_records('block_email_list_foldermail', 'folderid', $trash->id)) { $success = false; } // Get all trash mails if ($mails) { foreach ($mails as $mail) { // if mailid exist, continue ... if (get_records('block_email_list_foldermail', 'mailid', $mail->id)) { continue; } else { // Mail is not reference by never folder (not possibility readed) if (email_delete_attachments($mail->id) and delete_records('block_email_list_mail', 'id', $mail->id)) { $success = true; } } } } $url = email_build_url($options); // Notify if ($success) { notify(get_string('cleantrashok', 'block_email_list')); } else { notify(get_string('cleantrashfail', 'block_email_list')); } $options->folderid = $id; $options->folderoldid = 0; email_showmails($USER->id, '', 0, 10, $options);
$trash = email_get_root_folder($USER->id, EMAIL_TRASH); /// If necessary, delete mail and delete attachments $options->folderid = $trash->id; $success = true; $mails = email_get_mails($USER->id, $course->id, NULL, '', '', $options); // Delete reference mails $DB->delete_records('block_email_list_foldermail', array('folderid' => $trash->id)); // Get all trash mails if ($mails) { foreach ($mails as $mail) { // if mailid exist, continue ... if ($DB->get_records('block_email_list_foldermail', array('mailid' => $mail->id))) { continue; } else { // Mail is not reference by never folder (not possibility readed) if (email_delete_attachments($mail->id) and $DB->delete_records('block_email_list_mail', array('id' => $mail->id))) { $success = true; } } } } $url = email_build_url($options); // Notify if ($success) { echo $OUTPUT->notification(get_string('cleantrashok', 'block_email_list'), ''); } else { echo $OUTPUT->notification(get_string('cleantrashfail', 'block_email_list'), ''); } $options->folderid = $id; $options->folderoldid = 0; email_showmails($USER->id, '', 0, 10, $options);
$options->folderid = $trash->id; $success = true; $mails = email_get_mails($USER->id, $course->id, NULL, '', '', $options); // Delete reference mails if (!delete_records('email_foldermail', 'folderid', $trash->id)) { $success = false; } // Get all trash mails if ($mails) { foreach ($mails as $mail) { // if mailid exist, continue ... if (get_records('email_foldermail', 'mailid', $mail->id)) { continue; } else { // Mail is not reference by never folder (not possibility readed) if (email_delete_attachments($mail->id) and delete_records('email_mail', 'id', $mail->id)) { $success = true; } } } } $url = email_build_url($options); // Notify if ($success) { notify(get_string('cleantrashok', 'block_email_list')); } else { notify(get_string('cleantrashfail', 'block_email_list')); } $options->folderid = $id; $options->folderoldid = 0; email_showmails($USER->id, '', 0, 10, $options);