protected function doAction()
 {
     $filter = ['groupids' => null, 'maintenance' => null, 'severity' => null, 'trigger_name' => '', 'extAck' => 0];
     if (CProfile::get('web.dashconf.filter.enable', 0) == 1) {
         // groups
         if (CProfile::get('web.dashconf.groups.grpswitch', 0) == 0) {
             // null mean all groups
             $filter['groupids'] = null;
         } else {
             $filter['groupids'] = zbx_objectValues(CFavorite::get('web.dashconf.groups.groupids'), 'value');
             $hideHostGroupIds = zbx_objectValues(CFavorite::get('web.dashconf.groups.hide.groupids'), 'value');
             if ($hideHostGroupIds) {
                 // get all groups if no selected groups defined
                 if (!$filter['groupids']) {
                     $dbHostGroups = API::HostGroup()->get(['output' => ['groupid']]);
                     $filter['groupids'] = zbx_objectValues($dbHostGroups, 'groupid');
                 }
                 $filter['groupids'] = array_diff($filter['groupids'], $hideHostGroupIds);
                 // get available hosts
                 $dbAvailableHosts = API::Host()->get(['groupids' => $filter['groupids'], 'output' => ['hostid']]);
                 $availableHostIds = zbx_objectValues($dbAvailableHosts, 'hostid');
                 $dbDisabledHosts = API::Host()->get(['groupids' => $hideHostGroupIds, 'output' => ['hostid']]);
                 $disabledHostIds = zbx_objectValues($dbDisabledHosts, 'hostid');
                 $filter['hostids'] = array_diff($availableHostIds, $disabledHostIds);
             } else {
                 if (!$filter['groupids']) {
                     // null mean all groups
                     $filter['groupids'] = null;
                 }
             }
         }
         // hosts
         $maintenance = CProfile::get('web.dashconf.hosts.maintenance', 1);
         $filter['maintenance'] = $maintenance == 0 ? 0 : null;
         // triggers
         $severity = CProfile::get('web.dashconf.triggers.severity', null);
         $filter['severity'] = zbx_empty($severity) ? null : explode(';', $severity);
         $filter['severity'] = zbx_toHash($filter['severity']);
         $filter['trigger_name'] = CProfile::get('web.dashconf.triggers.name', '');
         $config = select_config();
         $filter['extAck'] = $config['event_ack_enable'] ? CProfile::get('web.dashconf.events.extAck', 0) : 0;
     }
     $this->setResponse(new CControllerResponseData(['filter' => $filter, 'user' => ['debug_mode' => $this->getDebugMode()]]));
 }
 protected function doAction()
 {
     $filter = ['groupids' => null, 'maintenance' => null];
     if (CProfile::get('web.dashconf.filter.enable', 0) == 1) {
         // groups
         if (CProfile::get('web.dashconf.groups.grpswitch', 0) == 0) {
             // null mean all groups
             $filter['groupids'] = null;
         } else {
             $filter['groupids'] = zbx_objectValues(CFavorite::get('web.dashconf.groups.groupids'), 'value');
             $hideHostGroupIds = zbx_objectValues(CFavorite::get('web.dashconf.groups.hide.groupids'), 'value');
             if ($hideHostGroupIds) {
                 // get all groups if no selected groups defined
                 if (!$filter['groupids']) {
                     $dbHostGroups = API::HostGroup()->get(['output' => ['groupid']]);
                     $filter['groupids'] = zbx_objectValues($dbHostGroups, 'groupid');
                 }
                 $filter['groupids'] = array_diff($filter['groupids'], $hideHostGroupIds);
                 // get available hosts
                 $dbAvailableHosts = API::Host()->get(['groupids' => $filter['groupids'], 'output' => ['hostid']]);
                 $availableHostIds = zbx_objectValues($dbAvailableHosts, 'hostid');
                 $dbDisabledHosts = API::Host()->get(['groupids' => $hideHostGroupIds, 'output' => ['hostid']]);
                 $disabledHostIds = zbx_objectValues($dbDisabledHosts, 'hostid');
                 $filter['hostids'] = array_diff($availableHostIds, $disabledHostIds);
             } else {
                 if (!$filter['groupids']) {
                     // null mean all groups
                     $filter['groupids'] = null;
                 }
             }
         }
         // hosts
         $maintenance = CProfile::get('web.dashconf.hosts.maintenance', 1);
         $filter['maintenance'] = $maintenance == 0 ? 0 : null;
     }
     $this->setResponse(new CControllerResponseData(['filter' => $filter, 'user' => ['debug_mode' => $this->getDebugMode()]]));
 }
Exemplo n.º 3
0
function make_screen_submenu()
{
    $favScreens = array();
    $fav_screens = CFavorite::get('web.favorite.screenids');
    if (!$fav_screens) {
        return $favScreens;
    }
    $screenids = array();
    foreach ($fav_screens as $favorite) {
        if ('screenid' == $favorite['source']) {
            $screenids[$favorite['value']] = $favorite['value'];
        }
    }
    $options = array('screenids' => $screenids, 'output' => array('screenid', 'name'));
    $screens = API::Screen()->get($options);
    $screens = zbx_toHash($screens, 'screenid');
    foreach ($fav_screens as $favorite) {
        $source = $favorite['source'];
        $sourceid = $favorite['value'];
        if ('slideshowid' == $source) {
            if (!slideshow_accessible($sourceid, PERM_READ)) {
                continue;
            }
            if (!($slide = get_slideshow_by_slideshowid($sourceid))) {
                continue;
            }
            $slide_added = true;
            $favScreens[] = array('name' => $slide['name'], 'favobj' => 'slideshowid', 'favid' => $slide['slideshowid'], 'favaction' => 'remove');
        } else {
            if (!isset($screens[$sourceid])) {
                continue;
            }
            $screen = $screens[$sourceid];
            $screen_added = true;
            $favScreens[] = array('name' => $screen['name'], 'favobj' => 'screenid', 'favid' => $screen['screenid'], 'favaction' => 'remove');
        }
    }
    if (isset($screen_added)) {
        $favScreens[] = array('name' => _('Remove') . ' ' . _('All') . ' ' . _('Screens'), 'favobj' => 'screenid', 'favid' => 0, 'favaction' => 'remove');
    }
    if (isset($slide_added)) {
        $favScreens[] = array('name' => _('Remove') . ' ' . _('All') . ' ' . _('Slides'), 'favobj' => 'slideshowid', 'favid' => 0, 'favaction' => 'remove');
    }
    return $favScreens;
}
Exemplo n.º 4
0
 /**
  * Prepare data for favourite screens menu popup.
  *
  * @return array
  */
 public static function getFavouriteScreens()
 {
     $screens = $slideshows = array();
     $favourites = CFavorite::get('web.favorite.screenids');
     if ($favourites) {
         $screenIds = $slideshowIds = array();
         foreach ($favourites as $favourite) {
             if ($favourite['source'] === 'screenid') {
                 $screenIds[$favourite['value']] = $favourite['value'];
             }
         }
         $dbScreens = API::Screen()->get(array('output' => array('screenid', 'name'), 'screenids' => $screenIds, 'preservekeys' => true));
         foreach ($favourites as $favourite) {
             $sourceId = $favourite['value'];
             if ($favourite['source'] === 'slideshowid') {
                 if (slideshow_accessible($sourceId, PERM_READ)) {
                     $dbSlideshow = get_slideshow_by_slideshowid($sourceId);
                     if ($dbSlideshow) {
                         $slideshows[] = array('id' => $dbSlideshow['slideshowid'], 'label' => $dbSlideshow['name']);
                     }
                 }
             } else {
                 if (isset($dbScreens[$sourceId])) {
                     $dbScreen = $dbScreens[$sourceId];
                     $screens[] = array('id' => $dbScreen['screenid'], 'label' => $dbScreen['name']);
                 }
             }
         }
     }
     return array('type' => 'favouriteScreens', 'screens' => $screens, 'slideshows' => $slideshows);
 }
Exemplo n.º 5
0
 */
$dashconf = array();
$dashconf['groupids'] = null;
$dashconf['maintenance'] = null;
$dashconf['severity'] = null;
$dashconf['extAck'] = 0;
$dashconf['filterEnable'] = CProfile::get('web.dashconf.filter.enable', 0);
if ($dashconf['filterEnable'] == 1) {
    // groups
    $dashconf['grpswitch'] = CProfile::get('web.dashconf.groups.grpswitch', 0);
    if ($dashconf['grpswitch'] == 0) {
        $dashconf['groupids'] = null;
        // null mean all groups
    } else {
        $dashconf['groupids'] = zbx_objectValues(CFavorite::get('web.dashconf.groups.groupids'), 'value');
        $hideGroupIds = zbx_objectValues(CFavorite::get('web.dashconf.groups.hide.groupids'), 'value');
        if ($hideGroupIds) {
            // get all groups if no selected groups defined
            if (empty($dashconf['groupids'])) {
                $groups = API::HostGroup()->get(array('nodeids' => get_current_nodeid(), 'output' => array('groupid')));
                $dashconf['groupids'] = zbx_objectValues($groups, 'groupid');
            }
            $dashconf['groupids'] = array_diff($dashconf['groupids'], $hideGroupIds);
            // get available hosts
            $availableHosts = API::Host()->get(array('groupids' => $dashconf['groupids'], 'output' => array('hostid')));
            $availableHostIds = zbx_objectValues($availableHosts, 'hostid');
            $disabledHosts = API::Host()->get(array('groupids' => $hideGroupIds, 'output' => array('hostid')));
            $disabledHostIds = zbx_objectValues($disabledHosts, 'hostid');
            $dashconf['hostids'] = array_diff($availableHostIds, $disabledHostIds);
        } else {
            if (empty($dashconf['groupids'])) {
Exemplo n.º 6
0
/**
 * Get favourite screens and slide shows data.
 *
 * @return array['screens']
 * @return array['slideshows']
 */
function getFavouriteScreensData()
{
    $screens = $slideshows = [];
    $favourites = CFavorite::get('web.favorite.screenids');
    if ($favourites) {
        $screenIds = $slideshowIds = [];
        foreach ($favourites as $favourite) {
            if ($favourite['source'] === 'screenid') {
                $screenIds[$favourite['value']] = $favourite['value'];
            }
        }
        $dbScreens = API::Screen()->get(['output' => ['screenid', 'name'], 'screenids' => $screenIds, 'preservekeys' => true]);
        foreach ($favourites as $favourite) {
            $sourceId = $favourite['value'];
            if ($favourite['source'] === 'slideshowid') {
                if (slideshow_accessible($sourceId, PERM_READ)) {
                    $dbSlideshow = get_slideshow_by_slideshowid($sourceId, PERM_READ);
                    if ($dbSlideshow) {
                        $slideshows[] = ['id' => $dbSlideshow['slideshowid'], 'label' => $dbSlideshow['name']];
                    }
                }
            } else {
                if (isset($dbScreens[$sourceId])) {
                    $dbScreen = $dbScreens[$sourceId];
                    $screens[] = ['id' => $dbScreen['screenid'], 'label' => $dbScreen['name']];
                }
            }
        }
    }
    return ['screens' => $screens, 'slideshows' => $slideshows];
}
Exemplo n.º 7
0
    $data['groupIds'] = getRequest('groupids', array());
    $data['groupIds'] = zbx_toHash($data['groupIds']);
    $data['hideGroupIds'] = getRequest('hidegroupids', array());
    $data['hideGroupIds'] = zbx_toHash($data['hideGroupIds']);
} else {
    $data['isFilterEnable'] = CProfile::get('web.dashconf.filter.enable', 0);
    $data['maintenance'] = CProfile::get('web.dashconf.hosts.maintenance', 1);
    $data['extAck'] = CProfile::get('web.dashconf.events.extAck', 0);
    $data['severity'] = CProfile::get('web.dashconf.triggers.severity', '0;1;2;3;4;5');
    $data['severity'] = zbx_empty($data['severity']) ? array() : explode(';', $data['severity']);
    // groups
    $data['grpswitch'] = CProfile::get('web.dashconf.groups.grpswitch', 0);
    $data['groupIds'] = CFavorite::get('web.dashconf.groups.groupids');
    $data['groupIds'] = zbx_objectValues($data['groupIds'], 'value');
    $data['groupIds'] = zbx_toHash($data['groupIds']);
    $data['hideGroupIds'] = CFavorite::get('web.dashconf.groups.hide.groupids');
    $data['hideGroupIds'] = zbx_objectValues($data['hideGroupIds'], 'value');
    $data['hideGroupIds'] = zbx_toHash($data['hideGroupIds']);
}
$data['severity'] = zbx_toHash($data['severity']);
$data['severities'] = array(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER);
if ($data['grpswitch']) {
    // show groups
    $data['groups'] = API::HostGroup()->get(array('groupids' => $data['groupIds'], 'output' => array('groupid', 'name')));
    CArrayHelper::sort($data['groups'], array(array('field' => 'name', 'order' => ZBX_SORT_UP)));
    foreach ($data['groups'] as &$group) {
        $group['id'] = $group['groupid'];
        unset($group['groupid']);
    }
    unset($group);
    // hide groups