Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
dashboardrow.php
1<?php
2
4
5use Bitrix\Main\Entity\Query;
9
10
17class DashboardRow extends Model
18{
19 protected $gId;
20 protected $boardId;
21 protected $weight;
22 protected $layoutMap = '';
23
25 protected $widgets = array();
26
28 protected $dashboard;
29
33 public static function getTableClassName()
34 {
36 }
37
44 public static function getMapAttributes()
45 {
46 $attributes = parent::getMapAttributes();
47 $attributes['GID'] = 'gId';
48 $attributes['BOARD_ID'] = 'boardId';
49 $attributes['WEIGHT'] = 'weight';
50 $attributes['LAYOUT_MAP'] = 'layoutMap';
51 return $attributes;
52 }
53
57 public static function getMapReferenceAttributes()
58 {
59 return array(
60 'widgets' => array(
61 'type' => Common::ONE_TO_MANY,
62 'targetEntity' => Widget::getClassName(),
63 'mappedBy' => 'row'
64 ),
65 'dashboard' => array(
66 'type' => Common::MANY_TO_ONE,
67 'targetEntity' => Dashboard::getClassName(),
68 'inversedBy' => 'rows',
69 'join' => array(
70 'field' => array('boardId', 'id')
71 )
72 ),
73 );
74 }
75
79 public function getCopyForCurrentUser()
80 {
81 $coreRow = clone $this;
82 $copyRow = new DashboardRow();
83 $copyRow->setBoardId($coreRow->getBoardId());
84 $copyRow->setGId($coreRow->getGId());
85 $copyRow->setWeight($coreRow->getWeight());
86 $copyRow->setLayoutMap($coreRow->getLayoutMap());
87
88 $widgets = $coreRow->getWidgets();
89 if (is_array($widgets))
90 {
91 foreach ($widgets as $widget)
92 {
93 $copyRow->addWidgets($widget->getCopyForCurrentUser());
94 }
95 }
96
97
98 return $copyRow;
99 }
100
101
105 public function getWidgets()
106 {
107 return $this->widgets;
108 }
109
113 public function getBoardId()
114 {
115 return $this->boardId;
116 }
117
124 public function setBoardId($boardId)
125 {
126 $this->boardId = $boardId;
127 }
128
132 public function getWeight()
133 {
134 return $this->weight;
135 }
136
143 public function setWeight($weight)
144 {
145 $this->weight = $weight;
146 }
147
155 public static function getRowsByGIdsAndBoardId(array $gIds, $boardId)
156 {
157 return static::getModelList(array(
158 'select' => array('*'),
159 'filter' => Query::filter()->where('BOARD_ID', $boardId)->logic('and')->whereIn('GID', $gIds)
160 ));
161 }
162
169 public static function getRowsWithWidgetsByBoard($boardId)
170 {
171 $rows = static::getModelList(array(
172 'select' => array('*'),
173 'filter' => array('=BOARD_ID' => $boardId),
174 'with' => array('widgets', 'widgets.configurations'),
175 'order' => array('WEIGHT' => 'ASC'),
176 ));
177 return $rows;
178 }
179
186 public static function loadByGId($gId)
187 {
188 return static::load(array('GID' => $gId));
189 }
190
197 public static function getCurrentUserRowByGId($rowGId)
198 {
199 global $USER;
200 if ($USER)
201 {
202 $row = static::load(
203 array(
204 'GID' => $rowGId,
205 'DASHBOARD.USER_ID' => $USER->getId()
206 )
207 );
208 return $row;
209 }
210 return null;
211 }
212
219 public static function getRowsWithReportsByBoard($boardId)
220 {
221 $rows = static::getModelList(array(
222 'select' => array('*'),
223 'filter' => Query::filter()->where('BOARD_ID', $boardId),
224 'with' => array('widgets', 'widgets.configurations', 'widgets.reports.configurations'),
225 'order' => array('WEIGHT' => 'ASC'),
226 ));
227 return $rows;
228 }
229
233 public function getLayoutMap()
234 {
235 return unserialize($this->layoutMap, ['allowed_classes' => false]);
236 }
237
244 public function setLayoutMap($layoutMap)
245 {
246 $this->layoutMap = serialize($layoutMap);
247 }
248
252 public function getDashboard()
253 {
254 return $this->dashboard;
255 }
256
260 public function getGId()
261 {
262 return $this->gId;
263 }
264
271 public function setGId($gId)
272 {
273 $this->gId = $gId;
274 }
275
276}
static getRowsByGIdsAndBoardId(array $gIds, $boardId)