-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto-lock-user.php
More file actions
34 lines (27 loc) · 978 Bytes
/
Copy pathauto-lock-user.php
File metadata and controls
34 lines (27 loc) · 978 Bytes
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
<?php
class Am_Plugin_AutoLockUser extends Am_Plugin
{
const PLUGIN_STATUS = self::STATUS_PRODUCTION;
const PLUGIN_VERSION = '5.5.4';
protected $_configPrefix = 'misc.';
public function _initSetupForm(Am_Form_Setup $form)
{
$form->addText('auto_lock_user.interval')
->setLabel("Invoice lifetime\nhow long (in days) keep invoice");
}
public function getTitle()
{
return 'Auto Lock User';
}
public function onDaily(Am_Event $event)
{
$day = $this->getConfig('auto_lock_user.interval');
$date = date('Y-m-d', strtotime("-{$day} days"));
$expired_bills = $this->getDi()->invoiceTable->findForRebill($date);
foreach ($expired_bills as $invoice) {
$user = $invoice->getUser();
$user->lock(true);
$this->logDebug(sprintf("USER %s HAS LOCKED ON %s, INVOICE : %s", $user->login, date('Y-m-d H:i:s'), $invoice->public_id));
}
}
}