forked from VitaliiSestrenskyi/bitrix24_migrations
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setUserOptions.php
55 lines (44 loc) · 1.51 KB
/
setUserOptions.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
<?php
class CreateUfTestDealField extends AbstractMigration
{
private $guid = "deal_details";
public function commit()
{
global $USER;
$oldUserOptions = CUserOptions::GetOption('crm.entity.editor', $this->guid);
$issetSection = false;
foreach ($oldUserOptions as $key => $items)
{
if($items['name'] == 'testSectionName')
{
$issetSection = true;
}
}
if(!$issetSection)
{
$arrSection = [
'name'=>'testSectionName',
'title'=>'Тестовый раздел',
'type'=>'section'
];
array_push($oldUserOptions, $arrSection);
CUserOptions::SetOption('crm.entity.editor', $this->guid, $oldUserOptions, false, $USER->GetID());
CUserOptions::SetOption('crm.entity.editor', $this->guid, $oldUserOptions, true);
}
}
public function rollback()
{
global $USER;
$oldUserOptions = CUserOptions::GetOption('crm.entity.editor', $this->guid);
$arrNewUserOptions = [];
foreach ($oldUserOptions as $key => $items)
{
if($items['name'] != 'testSectionName')
{
$arrNewUserOptions[$key] = $items;
}
}
CUserOptions::SetOption('crm.entity.editor', $this->guid, $arrNewUserOptions, false, $USER->GetID());
CUserOptions::SetOption('crm.entity.editor', $this->guid, $arrNewUserOptions, true);
}
}