Skip to content

Commit

Permalink
Fix MyBBStuff#364: The language strings for the task are misleading/m…
Browse files Browse the repository at this point in the history
…issing

Resolves MyBBStuff#364
  • Loading branch information
lairdshaw committed May 19, 2024
1 parent 5311e48 commit d9db885
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion inc/languages/english/admin/myalerts.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
$l['setting_myalerts_bc_mode'] = "Backwards compatibility mode";
$l['setting_myalerts_bc_mode_desc'] = "To support client plugins which do not yet register their alerts formatters via this plugin's `myalerts_register_client_alert_formatters` hook. Turning this mode on will resolve the problem of empty alerts rows in the modal dialogue for some client alert types after clicking, for example, 'Mark All Read'.";

$l['myalerts_task_cleanup_ran'] = 'Read alerts over a week old were deleted successfully!';
// For the task when run from the ACP.
// Duplicated in the user language file for when the task runs in a user context via the task image bottom of page.
$l['myalerts_task_cleanup_ran'] = 'Read alerts over {1} days old and unread alerts over {2} days old were deleted successfully!';
$l['myalerts_task_cleanup_error'] = 'Something went wrong while cleaning up the alerts...';

$l['myalerts_task_title'] = 'MyAlerts Cleanup';
Expand Down
5 changes: 5 additions & 0 deletions inc/languages/english/myalerts.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,8 @@
$l['myalerts_error_alert_not_found'] = 'Alert not found.';

$l['myalerts_delete'] = 'Delete';

// For the task when run from a user context via the task image bottom of page.
// Duplicated in the admin language file for when the task runs from the ACP.
$l['myalerts_task_cleanup_ran'] = 'Read alerts over {1} days old and unread alerts over {2} days old were deleted successfully!';
$l['myalerts_task_cleanup_error'] = 'Something went wrong while cleaning up the alerts...';
10 changes: 6 additions & 4 deletions inc/tasks/myalerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
function task_myalerts($task)
{
global $db, $lang;


$read_days = 90; // 90 days for read alerts
$unread_days = 120; // 120 days for unread alerts
// Read/unread alerts older than X seconds will be deleted to save some space in DB
$read_time = 90*24*60*60; // 90 days for read alerts (formula: days X hours X minutes X seconds)
$unread_time = 120*24*60*60; // 120 days for unread alerts (formula: days X hours X minutes X seconds)
$read_time = $read_days*24*60*60; // Formula: days X hours X minutes X seconds
$unread_time = $unread_days*24*60*60; //Formula: days X hours X minutes X seconds

if (!isset($lang->myalerts)) {
$lang->load('myalerts');
}

if ($db->delete_query('alerts', '(dateline <= \''.date('Y-m-d H:i:s', TIME_NOW-$unread_time).'\' AND unread = 1) OR (dateline <= \''.date('Y-m-d H:i:s', TIME_NOW-$read_time).'\' AND unread = 0)')) {
add_task_log($task, $lang->myalerts_task_cleanup_ran);
add_task_log($task, $lang->sprintf($lang->myalerts_task_cleanup_ran, $read_days, $unread_days));
} else {
add_task_log($task, $lang->myalerts_task_cleanup_error);
}
Expand Down

0 comments on commit d9db885

Please sign in to comment.