Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
target.php
1<?php
2namespace Bitrix\Landing\Note;
3
4use \Bitrix\Landing\Rights;
5use \Bitrix\Landing\Landing;
6use \Bitrix\Landing\Site;
7use \Bitrix\Landing\Site\Type;
8
9class 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
69 $item['SITE_ID'],
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}
static rememberLastSite(int $landingId)
Definition target.php:21
static hasAccessForSite($siteId, $accessType, $deleted=false)
Definition rights.php:544
static getList(array $parameters=array())