25 $userId = $USER->getId();
27 if (!$dashboardForUser)
32 $dashboardForUser = $defaultDashboard->getCopyForCurrentUser();
33 $dashboardForUser->setVersion(
'');
34 $dashboardForUser->setUserId($userId);
35 $dashboardForUser->save();
37 return $dashboardForUser;
50 $dashboardIds = array();
51 foreach ($dashboards as $dashboard)
53 $cellId =
'cell_' . randString(4);
55 'cellIds' => array($cellId)
57 $widget->setWeight($cellId);
58 $widget->setBoardId($boardKey);
59 $row->addWidgets($widget->getCopyForCurrentUser());
60 $dashboard->addRows($row);
62 $dashboardIds[] = $dashboard->getId();
80 $board->addFilter(
'boardKey', $boardKey);
81 $board = $board->execute()->getFirstResult();
84 if (!$board->getVersion())
86 throw new SystemException(
"To renew default dashboard in db state, version of dashboard should exist");
91 if ($boardFromDb && $boardFromDb->getVersion() !== $board->getVersion())
93 $boardFromDb->delete();
96 elseif (!$boardFromDb)
110 $boardModes = \CUserOptions::GetOption(
'report_dashboard',
'IS_DEMO_MODE_MARKERS', array());
111 if (isset($boardModes[$boardKey]))
113 return $boardModes[$boardKey];
115 return self::getBoardCustomDefaultModeIsDemo($boardKey);
120 $boardModes = \CUserOptions::GetOption(
'report_dashboard',
'IS_DEMO_MODE_MARKERS', array());
121 $boardModes[$boardKey] = $mode;
122 \CUserOptions::SetOption(
'report_dashboard',
'IS_DEMO_MODE_MARKERS', $boardModes);
127 if (self::checkBoardCustomDefaultModeIsExist($boardKey))
129 if (self::getBoardCustomDefaultModeIsDemo($boardKey) != $demo)
131 self::setBoardCustomDefaultModeIsDemo($boardKey, $demo);
137 self::setBoardCustomDefaultModeIsDemo($boardKey, $demo);
141 private static function setBoardCustomDefaultModeIsDemo($boardKey, $demo =
false)
143 $modes = Option::get(
'report',
'BOARD_CUSTOM_DEFAULT_MODES', serialize(array()));
144 $modes = unserialize($modes, [
'allowed_classes' =>
false]);
145 $modes[$boardKey] = $demo ? 1 : 0;
146 Option::set(
'report',
'BOARD_CUSTOM_DEFAULT_MODES', serialize($modes));
149 private static function checkBoardCustomDefaultModeIsExist($boardKey)
151 $modes = Option::get(
'report',
'BOARD_CUSTOM_DEFAULT_MODES', serialize(array()));
152 $modes = unserialize($modes, [
'allowed_classes' =>
false]);
153 return isset($modes[$boardKey]);
156 private static function getBoardCustomDefaultModeIsDemo($boardKey)
158 $modes = Option::get(
'report',
'BOARD_CUSTOM_DEFAULT_MODES', serialize(array()));
159 $modes = unserialize($modes, [
'allowed_classes' =>
false]);
160 return !empty($modes[$boardKey]);