-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSendDeleteReminders.php
64 lines (49 loc) · 1.1 KB
/
SendDeleteReminders.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace LiamW\AccountDelete\Job;
use XF;
use XF\Job\AbstractJob;
class SendDeleteReminders extends AbstractJob
{
public function run($maxRunTime)
{
$startTime = microtime(true);
$repository = XF::repository('LiamW\AccountDelete:AccountDelete');
$toRemind = $repository->findAccountsToRemind()->fetch();
if (!$toRemind->count())
{
$nextRemindTime = $repository->getNextRemindTime();
if ($nextRemindTime)
{
$resume = $this->resume();
$resume->continueDate = $nextRemindTime;
return $resume;
}
else
{
// This job will be queued when an account deletion is initiated.
return $this->complete();
}
}
foreach ($toRemind AS $item)
{
XF::service('LiamW\AccountDelete:AccountDelete', $item->User)->sendReminderEmail();
if (microtime(true) - $startTime >= $maxRunTime)
{
break;
}
}
return $this->resume();
}
public function getStatusMessage()
{
return \XF::phrase('liamw_accountdelete_sending_user_deletion_reminders');
}
public function canCancel()
{
return false;
}
public function canTriggerByChoice()
{
return false;
}
}