protected function doAction()
 {
     $show_discovery_widget = $this->getUserType() >= USER_TYPE_ZABBIX_ADMIN && (bool) API::DRule()->get(['output' => [], 'filter' => ['status' => DRULE_STATUS_ACTIVE], 'limit' => 1]);
     $data = ['fullscreen' => $this->getInput('fullscreen', 0), 'filter_enabled' => CProfile::get('web.dashconf.filter.enable', 0), 'favourite_graphs' => getFavouriteGraphs(), 'favourite_maps' => getFavouriteMaps(), 'favourite_screens' => getFavouriteScreens(), 'show_status_widget' => $this->getUserType() == USER_TYPE_SUPER_ADMIN, 'show_discovery_widget' => $show_discovery_widget];
     $response = new CControllerResponseData($data);
     $response->setTitle(_('Dashboard'));
     $this->setResponse($response);
 }
Exemplo n.º 2
0
/*
 * Display
 */
$dashboardWidget = new CWidget(null, 'dashboard');
$dashboardWidget->setClass('header');
$dashboardWidget->addHeader(_('PERSONAL DASHBOARD'), array(new CIcon(_s('Configure (Filter %s)', $dashboardConfig['filterEnable'] ? _('Enabled') : _('Disabled')), $dashboardConfig['filterEnable'] ? 'iconconfig_hl' : 'iconconfig', 'document.location = "dashconf.php";'), SPACE, get_icon('fullscreen', array('fullscreen' => getRequest('fullscreen')))));
/*
 * Dashboard grid
 */
$dashboardGrid = array(array(), array(), array());
$widgetRefreshParams = array();
// favourite graphs
$icon = new CIcon(_('Menu'), 'iconmenu');
$icon->setAttribute('id', 'favouriteGraphs');
$icon->setMenuPopup(CMenuPopupHelper::getFavouriteGraphs());
$favouriteGraphs = new CCollapsibleUiWidget(WIDGET_FAVOURITE_GRAPHS, getFavouriteGraphs());
$favouriteGraphs->open = (bool) CProfile::get('web.dashboard.widget.' . WIDGET_FAVOURITE_GRAPHS . '.state', true);
$favouriteGraphs->setHeader(_('Favourite graphs'), $icon);
$favouriteGraphs->setFooter(new CLink(_('Graphs') . ' »', 'charts.php', 'highlight'), true);
$col = CProfile::get('web.dashboard.widget.' . WIDGET_FAVOURITE_GRAPHS . '.col', 0);
$row = CProfile::get('web.dashboard.widget.' . WIDGET_FAVOURITE_GRAPHS . '.row', 0);
$dashboardGrid[$col][$row] = $favouriteGraphs;
// favourite maps
$icon = new CIcon(_('Menu'), 'iconmenu');
$icon->setAttribute('id', 'favouriteMaps');
$icon->setMenuPopup(CMenuPopupHelper::getFavouriteMaps());
$favouriteMaps = new CCollapsibleUiWidget(WIDGET_FAVOURITE_MAPS, getFavouriteMaps());
$favouriteMaps->open = (bool) CProfile::get('web.dashboard.widget.' . WIDGET_FAVOURITE_MAPS . '.state', true);
$favouriteMaps->setHeader(_('Favourite maps'), $icon);
$favouriteMaps->setFooter(new CLink(_('Maps') . ' »', 'maps.php', 'highlight'), true);
$col = CProfile::get('web.dashboard.widget.' . WIDGET_FAVOURITE_MAPS . '.col', 0);
 protected function doAction()
 {
     $object = $this->getInput('object');
     $operation = $this->getInput('operation');
     $objectids = $this->getInput('objectids');
     $data = [];
     $result = true;
     DBstart();
     switch ($object) {
         // favourite graphs
         case 'itemid':
         case 'graphid':
             zbx_value2array($objectids);
             foreach ($objectids as $id) {
                 if ($operation == 'create') {
                     $result &= CFavorite::add('web.favorite.graphids', $id, $object);
                 } elseif ($operation == 'delete') {
                     $result &= CFavorite::remove('web.favorite.graphids', $id, $object);
                 }
             }
             $graphs = getFavouriteGraphs();
             $graphs = $graphs->toString();
             $data['main_block'] = 'jQuery("#' . WIDGET_FAVOURITE_GRAPHS . '").html(' . CJs::encodeJson($graphs) . ');' . 'jQuery(".action-menu").remove();' . 'jQuery("#favouriteGraphs").data(' . '"menu-popup", ' . CJs::encodeJson(CMenuPopupHelper::getFavouriteGraphs()) . ');';
             break;
             // favourite maps
         // favourite maps
         case 'sysmapid':
             zbx_value2array($objectids);
             foreach ($objectids as $id) {
                 if ($operation == 'create') {
                     $result &= CFavorite::add('web.favorite.sysmapids', $id, $object);
                 } elseif ($operation == 'delete') {
                     $result &= CFavorite::remove('web.favorite.sysmapids', $id, $object);
                 }
             }
             $maps = getFavouriteMaps();
             $maps = $maps->toString();
             $data['main_block'] = 'jQuery("#' . WIDGET_FAVOURITE_MAPS . '").html(' . CJs::encodeJson($maps) . ');' . 'jQuery(".action-menu").remove();' . 'jQuery("#favouriteMaps").data(' . '"menu-popup", ' . CJs::encodeJson(CMenuPopupHelper::getFavouriteMaps()) . ');';
             break;
             // favourite screens, slideshows
         // favourite screens, slideshows
         case 'screenid':
         case 'slideshowid':
             zbx_value2array($objectids);
             foreach ($objectids as $id) {
                 if ($operation == 'create') {
                     $result &= CFavorite::add('web.favorite.screenids', $id, $object);
                 } elseif ($operation == 'delete') {
                     $result &= CFavorite::remove('web.favorite.screenids', $id, $object);
                 }
             }
             $screens = getFavouriteScreens();
             $screens = $screens->toString();
             $data['main_block'] = 'jQuery("#' . WIDGET_FAVOURITE_SCREENS . '").html(' . CJs::encodeJson($screens) . ');' . 'jQuery(".action-menu").remove();' . 'jQuery("#favouriteScreens").data(' . '"menu-popup", ' . CJs::encodeJson(CMenuPopupHelper::getFavouriteScreens()) . ');';
             break;
         default:
             $data['main_block'] = '';
     }
     DBend($result);
     $this->setResponse(new CControllerResponseData($data));
 }