示例#1
0
$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);
$row = CProfile::get('web.dashboard.widget.' . WIDGET_FAVOURITE_MAPS . '.row', 2);
$dashboardGrid[$col][$row] = $favouriteMaps;
// favourite screens
$icon = new CIcon(_('Menu'), 'iconmenu');
$icon->setAttribute('id', 'favouriteScreens');
$icon->setMenuPopup(CMenuPopupHelper::getFavouriteScreens());
$favouriteScreens = new CCollapsibleUiWidget(WIDGET_FAVOURITE_SCREENS, getFavouriteScreens());
$favouriteScreens->open = (bool) CProfile::get('web.dashboard.widget.' . WIDGET_FAVOURITE_SCREENS . '.state', true);
$favouriteScreens->setHeader(_('Favourite screens'), $icon);
$favouriteScreens->setFooter(array(new CLink(_('Screens') . ' »', 'screens.php', 'highlight'), SPACE, SPACE, SPACE, new CLink(_('Slide shows') . ' »', 'slides.php', 'highlight')), true);
 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));
 }