1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
agent.php
См. документацию.
1
<?php
2
namespace
Bitrix\Socialservices\EncryptedToken
;
3
4
use
Bitrix\Main\Application
;
5
use
Bitrix\Main\Config\Option
;
6
use Bitrix\Main\Entity\ReferenceField;
7
use
Bitrix\Socialservices\EncryptedToken\UserTable
as EncryptedTokenUserTable;
8
use
Bitrix\Socialservices\UserTable
;
9
10
class
Agent
11
{
12
public
static
function
init
()
13
{
14
Option::set(
"socialservices"
,
"allow_encrypted_tokens"
,
true
);
15
$interval =
IsModuleInstalled
(
'bitrix24'
) ? 600 : 0;
16
\CAgent::AddAgent(
17
__CLASS__.
'::runAgent();'
,
18
"socialservices"
,
19
"N"
,
20
60,
21
""
,
22
"Y"
,
23
ConvertTimeStamp((time() + \CTimeZone::GetOffset() + $interval),
'FULL'
)
24
);
25
}
26
27
public
static
function
runAgent
()
28
{
29
if
(self::run())
30
{
31
return
__CLASS__.
'::runAgent();'
;
32
}
33
34
UserTable::enableCrypto(
'OATOKEN'
);
35
UserTable::enableCrypto(
'OASECRET'
);
36
UserTable::enableCrypto(
'REFRESH_TOKEN'
);
37
return
''
;
38
}
39
40
public
static
function
run
()
41
{
42
$limit = Option::get(
"socialservices"
,
"encrypt_tokens_step_limit"
, 500);
43
$lastEncryptedUserId = Option::get(
"socialservices"
,
"last_encrypted_user_id"
, 0);
44
$users = UserTable::getList([
45
'order'
=> [
'ID'
=>
'ASC'
],
46
'select'
=> [
47
'ID'
,
'OATOKEN'
,
'OASECRET'
,
'REFRESH_TOKEN'
48
],
49
'filter'
=> [
'>ID'
=> $lastEncryptedUserId],
50
'limit'
=> $limit
51
]);
52
$found = 0;
53
while
(
$user
= $users->fetch())
54
{
55
$found++;
56
57
UserTable::update(
$user
[
'ID'
], [
58
'OATOKEN'
=>
$user
[
'OATOKEN'
],
59
'OASECRET'
=>
$user
[
'OASECRET'
],
60
'REFRESH_TOKEN'
=>
$user
[
'REFRESH_TOKEN'
],
61
]);
62
63
$lastEncryptedUserId =
$user
[
'ID'
];
64
}
65
Option::set(
"socialservices"
,
"last_encrypted_user_id"
, $lastEncryptedUserId);
66
return
($found >= $limit);
67
}
68
}
Bitrix\Main\Application
Определения
application.php:30
Bitrix\Main\Config\Option
Определения
option.php:15
Bitrix\Main\UserTable
Определения
user.php:48
Bitrix\Socialservices\EncryptedToken\Agent
Определения
agent.php:11
Bitrix\Socialservices\EncryptedToken\Agent\runAgent
static runAgent()
Определения
agent.php:27
Bitrix\Socialservices\EncryptedToken\Agent\init
static init()
Определения
agent.php:12
Bitrix\Socialservices\EncryptedToken\Agent\run
static run()
Определения
agent.php:40
IsModuleInstalled
IsModuleInstalled($module_id)
Определения
tools.php:5301
Bitrix\Main\$user
$user
Определения
mysql_to_pgsql.php:33
Bitrix\Socialservices\EncryptedToken
Определения
agent.php:2
bitrix
modules
socialservices
lib
encryptedtoken
agent.php
Создано системой
1.14.0