Skip to content

Commit

Permalink
chore: fix indenting
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhilton committed Jun 17, 2024
1 parent 69972a7 commit 630a4fa
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ class helper {
* Purges emails logged older than $maxdays
* @param int $maxdays the number of days old a log should be before being purged
*/
static function purge($maxdays) {
global $DB;
static function purge($maxdays) {
global $DB;

$olderthantime = time() - $maxdays * DAYSECS;
$olderthantime = time() - $maxdays * DAYSECS;

// We can straight up delete records without attachments. This is very efficient.
$DB->delete_records_select('mail_log', 'timesent < ? AND attachment IS NULL', [$olderthantime]);
// We can straight up delete records without attachments. This is very efficient.
$DB->delete_records_select('mail_log', 'timesent < ? AND attachment IS NULL', [$olderthantime]);

// The remaining have attachments which need to also be deleted.
// The remaining have attachments which need to also be deleted.
// Delete these in chunks of 1k, as to not exceed the query parameter limit.
// Do this until there are no more records to delete (or ran out of iterations as a fail safe);
for ($i = 0; $i < 1000; $i++) {
Expand Down Expand Up @@ -122,30 +122,30 @@ static function log_mail($success, $msg, $user, $from, $subject, $messagetext, $
* Note the size of the $ids param must not exceed the maximum db query parameter limit.
* @param array $ids
*/
static function delete($ids) {
global $DB;
static function delete($ids) {
global $DB;

$context = \context_system::instance();
$context = \context_system::instance();

list($sqlin, $params) = $DB->get_in_or_equal($ids);
$sql = "SELECT * FROM {mail_log}
WHERE id {$sqlin}";
$logitems = $DB->get_records_sql($sql, $params);
list($sqlin, $params) = $DB->get_in_or_equal($ids);
$sql = "SELECT * FROM {mail_log}
WHERE id {$sqlin}";
$logitems = $DB->get_records_sql($sql, $params);

// Delete any attachment files
$fs = \get_file_storage();
foreach ($logitems as $item) {
if (empty($item->attachment)) {
continue;
}
$fs->delete_area_files($context->id, 'local_maillog', 'queuefiles', $item->id);
}
// Delete any attachment files
$fs = \get_file_storage();
foreach ($logitems as $item) {
if (empty($item->attachment)) {
continue;
}
$fs->delete_area_files($context->id, 'local_maillog', 'queuefiles', $item->id);
}

// Delete log records
$sql = "DELETE FROM {mail_log}
WHERE id {$sqlin}";
return $DB->execute($sql, $params);
}
// Delete log records
$sql = "DELETE FROM {mail_log}
WHERE id {$sqlin}";
return $DB->execute($sql, $params);
}

static function schedule_send($ids) {
global $DB;
Expand Down

0 comments on commit 630a4fa

Please sign in to comment.