protected function doAction() { $profile = ['graphid' => 'web.favorite.graphids', 'itemid' => 'web.favorite.graphids', 'screenid' => 'web.favorite.screenids', 'slideshowid' => 'web.favorite.screenids', 'sysmapid' => 'web.favorite.sysmapids']; $object = $this->getInput('object'); $objectid = $this->getInput('objectid'); $data = []; DBstart(); $result = CFavorite::remove($profile[$object], $objectid, $object); $result = DBend($result); if ($result) { $data['main_block'] = '$("addrm_fav").title = "' . _('Add to favourites') . '";' . "\n" . '$("addrm_fav").onclick = function() { add2favorites("' . $object . '", "' . $objectid . '"); }' . "\n" . 'switchElementClass("addrm_fav", "btn-remove-fav", "btn-add-fav");'; } else { $data['main_block'] = ''; } $this->setResponse(new CControllerResponseData($data)); }
} if (isset($_REQUEST['favobj'])) { if (getRequest('favobj') === 'timelinefixedperiod' && hasRequest('favid')) { CProfile::update('web.screens.timelinefixed', getRequest('favid'), PROFILE_TYPE_INT); } if (str_in_array($_REQUEST['favobj'], array('itemid', 'graphid'))) { $result = false; DBstart(); if ($_REQUEST['favaction'] == 'add') { $result = CFavorite::add('web.favorite.graphids', $_REQUEST['favid'], $_REQUEST['favobj']); if ($result) { echo '$("addrm_fav").title = "' . _('Remove from favourites') . '";' . "\n"; echo '$("addrm_fav").onclick = function() { rm4favorites("graphid", "' . $_REQUEST['favid'] . '"); }' . "\n"; } } elseif ($_REQUEST['favaction'] == 'remove') { $result = CFavorite::remove('web.favorite.graphids', $_REQUEST['favid'], $_REQUEST['favobj']); if ($result) { echo '$("addrm_fav").title = "' . _('Add to favourites') . '";' . "\n"; echo '$("addrm_fav").onclick = function() { add2favorites("graphid", "' . $_REQUEST['favid'] . '"); }' . "\n"; } } $result = DBend($result); if ($page['type'] == PAGE_TYPE_JS && $result) { echo 'switchElementClass("addrm_fav", "iconminus", "iconplus");'; } } } if (!empty($_REQUEST['period']) || !empty($_REQUEST['stime'])) { CScreenBase::calculateTime(array('profileIdx' => 'web.screens', 'profileIdx2' => $pageFilter->graphid, 'updateProfile' => true, 'period' => getRequest('period'), 'stime' => getRequest('stime'))); $curl = new CUrl(); $curl->removeArgument('period');
CProfile::update('web.dashconf.filter.enable', $filterEnable, PROFILE_TYPE_INT); if ($filterEnable == 1) { // groups CProfile::update('web.dashconf.groups.grpswitch', $_REQUEST['grpswitch'], PROFILE_TYPE_INT); if ($_REQUEST['grpswitch'] == 1) { // show groups $groupIds = getRequest('groupids', array()); $result = true; DBstart(); $result &= CFavorite::remove('web.dashconf.groups.groupids'); foreach ($groupIds as $groupId) { $result &= CFavorite::add('web.dashconf.groups.groupids', $groupId); } // hide groups $hideGroupIds = getRequest('hidegroupids', array()); $result &= CFavorite::remove('web.dashconf.groups.hide.groupids'); foreach ($hideGroupIds as $hideGroupId) { $result &= CFavorite::add('web.dashconf.groups.hide.groupids', $hideGroupId); } DBend($result); } // hosts $_REQUEST['maintenance'] = getRequest('maintenance', 0); CProfile::update('web.dashconf.hosts.maintenance', $_REQUEST['maintenance'], PROFILE_TYPE_INT); // triggers $_REQUEST['trgSeverity'] = getRequest('trgSeverity', array()); $_REQUEST['extAck'] = getRequest('extAck', 0); CProfile::update('web.dashconf.triggers.severity', implode(';', array_keys($_REQUEST['trgSeverity'])), PROFILE_TYPE_STR); CProfile::update('web.dashconf.events.extAck', $_REQUEST['extAck'], PROFILE_TYPE_INT); } jSredirect('dashboard.php');
echo ' jQuery("#' . WIDGET_FAVOURITE_MAPS . '").html(' . CJs::encodeJson($data) . '); jQuery(".menuPopup").remove(); jQuery("#favouriteMaps").data("menu-popup", ' . CJs::encodeJson(CMenuPopupHelper::getFavouriteMaps()) . ');'; break; // favourite screens, slideshows // favourite screens, slideshows case 'screenid': case 'slideshowid': if ($favouriteAction == 'add') { zbx_value2array($favouriteId); foreach ($favouriteId as $id) { $result &= CFavorite::add('web.favorite.screenids', $id, $favouriteObject); } } elseif ($favouriteAction == 'remove') { $result &= CFavorite::remove('web.favorite.screenids', $favouriteId, $favouriteObject); } $data = getFavouriteScreens(); $data = $data->toString(); echo ' jQuery("#' . WIDGET_FAVOURITE_SCREENS . '").html(' . CJs::encodeJson($data) . '); jQuery(".menuPopup").remove(); jQuery("#favouriteScreens").data("menu-popup", ' . CJs::encodeJson(CMenuPopupHelper::getFavouriteScreens()) . ');'; break; } DBend($result); } if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; }
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)); }