Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
target.php
1
<?php
2
namespace
Bitrix\Landing\Note
;
3
4
use \Bitrix\Landing\Rights;
5
use \Bitrix\Landing\Landing;
6
use \Bitrix\Landing\Site;
7
use \Bitrix\Landing\Site\Type;
8
9
class
Target
10
{
14
const
UO_CODE_NOTES_LAST
=
'notes_last'
;
15
21
public
static
function
rememberLastSite
(
int
$landingId): void
22
{
23
$res =
Landing::getList
([
24
'select'
=> [
25
'SITE_ID'
,
26
'SITE_TITLE'
=>
'SITE.TITLE'
,
27
'SITE_TYPE'
=>
'SITE.TYPE'
28
],
29
'filter'
=> [
30
'ID'
=> $landingId
31
],
32
'limit'
=> 1
33
]);
34
if
($row = $res->fetch())
35
{
36
$option = \CUserOptions::getOption(
'landing'
, self::UO_CODE_NOTES_LAST, []);
37
foreach
($option as $item)
38
{
39
if
($item[
'SITE_ID'
] == $row[
'SITE_ID'
])
40
{
41
return
;
42
}
43
}
44
$option[] = $row;
45
if
(count($option) > 5)
46
{
47
unset($option[0]);
48
}
49
\CUserOptions::setOption(
'landing'
, self::UO_CODE_NOTES_LAST, array_values($option));
50
}
51
}
52
57
public
static
function
getShortList
(): array
58
{
59
$data = [];
60
$option = \CUserOptions::getOption(
'landing'
, self::UO_CODE_NOTES_LAST, []);
61
$option = array_reverse($option);
62
63
// check every item in short list on accessibility
64
foreach
($option as $item)
65
{
66
Type::setScope
($item[
'SITE_TYPE'
]);
67
// because every item may by in different scopes
68
$check =
Rights::hasAccessForSite
(
69
$item[
'SITE_ID'
],
70
Rights::ACCESS_TYPES
[
'edit'
]
71
);
72
if
($check)
73
{
74
$res = Site::getList([
75
'select'
=> [
76
'ID'
,
'TITLE'
,
'TYPE'
77
],
78
'filter'
=> [
79
'ID'
=> $item[
'SITE_ID'
]
80
]
81
]);
82
if
($row = $res->fetch())
83
{
84
$data[] = $row;
85
}
86
}
87
}
88
89
$data = \Bitrix\Landing\Binding\Group::recognizeSiteTitle(
90
$data
91
);
92
93
return
$data;
94
}
95
}
Bitrix\Landing\Note\Target
Definition
target.php:10
Bitrix\Landing\Note\Target\rememberLastSite
static rememberLastSite(int $landingId)
Definition
target.php:21
Bitrix\Landing\Note\Target\UO_CODE_NOTES_LAST
const UO_CODE_NOTES_LAST
Definition
target.php:14
Bitrix\Landing\Note\Target\getShortList
static getShortList()
Definition
target.php:57
Bitrix\Landing\Rights\ACCESS_TYPES
const ACCESS_TYPES
Definition
rights.php:20
Bitrix\Landing\Rights\hasAccessForSite
static hasAccessForSite($siteId, $accessType, $deleted=false)
Definition
rights.php:544
Bitrix\Main\Engine\Controller\setScope
setScope($scope)
Definition
controller.php:369
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Definition
datamanager.php:441
Bitrix\Landing\Note
Definition
source.php:2
modules
landing
lib
note
target.php
Создано системой
1.10.0