Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
userdontauth.php
1<?
2
4
9
10Loc::loadMessages(__FILE__);
11
13{
14 public function getName()
15 {
16 return Loc::getMessage('sender_trigger_user_dontauth_name');
17 }
18
19 public function getCode()
20 {
21 return "user_dontauth";
22 }
23
25 public static function canBeTarget()
26 {
27 return false;
28 }
29
31 public static function canRunForOldData()
32 {
33 return true;
34 }
35
36 public function filter()
37 {
38 $daysDontAuth = $this->getFieldValue('DAYS_DONT_AUTH');
39 if(!is_numeric($daysDontAuth))
40 $daysDontAuth = 90;
41
42 $dateFrom = new DateTime;
43 $dateTo = new DateTime;
44
45 $dateFrom->setTime(0, 0, 0)->add('-' . $daysDontAuth . ' days');
46 $dateTo->setTime(0, 0, 0)->add('1 days')->add('-' . $daysDontAuth . ' days');
47
48 if($this->isRunForOldData())
49 {
50 $filter = array(
51 '!LAST_LOGIN' => null,
52 '<LAST_LOGIN' => $dateTo,
53 );
54 }
55 else
56 {
57 $filter = array(
58 '>LAST_LOGIN' => $dateFrom,
59 '<LAST_LOGIN' => $dateTo,
60 );
61 }
62
63 $filter['=ACTIVE'] = true;
64 $userListDb = UserTable::getList(array(
65 'select' => array('EMAIL', 'ID', 'NAME'),
66 'filter' => $filter,
67 'order' => array('ID' => 'ASC')
68 ));
69 if($userListDb->getSelectedRowsCount() > 0)
70 {
71 $userListDb->addFetchDataModifier(array($this, 'getFetchDataModifier'));
72 $this->recipient = $userListDb;
73 return true;
74 }
75 else
76 return false;
77 }
78
79 public function getRecipient()
80 {
81 return $this->recipient;
82 }
83
84 public function getForm()
85 {
86 $daysDontAuth = ' <input size=3 type="text" name="'.$this->getFieldName('DAYS_DONT_AUTH').'" value="'.htmlspecialcharsbx($this->getFieldValue('DAYS_DONT_AUTH', 90)).'"> ';
87
88 return '
89 <table>
90 <tr>
91 <td>'.Loc::getMessage('sender_trigger_user_dontauth_days').'</td>
92 <td>'.$daysDontAuth.'</td>
93 </tr>
94 </table>
95 ';
96 }
97
98 public function getFetchDataModifier($fields)
99 {
100 if(isset($fields['ID']))
101 {
102 $fields['USER_ID'] = $fields['ID'];
103 unset($fields['ID']);
104 }
105
106 return $fields;
107 }
108}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
setTime($hour, $minute, $second=0, $microseconds=0)
Definition datetime.php:144
getFieldValue($name, $defaultValue=null)
Definition base.php:195