-
Notifications
You must be signed in to change notification settings - Fork 2
/
setUserGroup.php
67 lines (63 loc) · 2.34 KB
/
setUserGroup.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
65
66
67
<?php
class Migration
{
public function commit(){
if(\Bitrix\Main\Loader::includeModule('main')){
$arGroupAdm = \Bitrix\Main\GroupTable::query()
->setFilter(['STRING_ID'=>'test'])
->setSelect(['ID'])
->exec()
->fetch();
if($arGroupAdm){
$db = \Bitrix\Main\UserTable::query()
->setFilter([
'EMAIL'=>[
'test@test.ru',
],
])
->setSelect(['ID'])
->exec();
while ($resUser = $db->fetch()){
$arGroupsDb = \CUser::GetUserGroupList( $resUser['ID'] );
while ($arGroup = $arGroupsDb->Fetch()){
$arGroups[] = $arGroup;
}
$arGroups[] = [
'GROUP_ID' => $arGroupAdm['ID'],
'DATE_ACTIVE_FROM'=>'',
'DATE_ACTIVE_TO'=>''
];
\CUser::SetUserGroup($resUser['ID'], $arGroups);
}
}
}
}
public function rollback(){
if(\Bitrix\Main\Loader::includeModule('main')){
$arGroupAdm = \Bitrix\Main\GroupTable::query()
->setFilter(['STRING_ID'=>'test'])
->setSelect(['ID'])
->exec()
->fetch();
if($arGroupAdm){
$db = \Bitrix\Main\UserTable::query()
->setFilter([
'EMAIL'=>[
'test@test.ru',
],
])
->setSelect(['*'])
->exec();
while ($resUser = $db->fetch()){
$arGroupsDb = \CUser::GetUserGroupList( $resUser['ID'] );
while ($arGroup = $arGroupsDb->Fetch()){
if($arGroup['GROUP_ID'] !== $arGroupAdm['ID']){
$arGroups[] = $arGroup;
}
}
\CUser::SetUserGroup($resUser['ID'], $arGroups);
}
}
}
}
}