当前位置: 首页>>代码示例>>PHP>>正文


PHP API::Screen方法代码示例

本文整理汇总了PHP中API::Screen方法的典型用法代码示例。如果您正苦于以下问题:PHP API::Screen方法的具体用法?PHP API::Screen怎么用?PHP API::Screen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在API的用法示例。


在下文中一共展示了API::Screen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $screen = API::Screen()->get(array('screenids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'selectScreenItems' => API_OUTPUT_EXTEND));
     $screen = reset($screen);
     $screenBuilder = new CScreenBuilder(array('isFlickerfree' => $this->isFlickerfree, 'mode' => $this->mode == SCREEN_MODE_EDIT || $this->mode == SCREEN_MODE_SLIDESHOW ? SCREEN_MODE_SLIDESHOW : SCREEN_MODE_PREVIEW, 'timestamp' => $this->timestamp, 'screen' => $screen, 'period' => $this->timeline['period'], 'stime' => $this->timeline['stimeNow'], 'profileIdx' => $this->profileIdx, 'updateProfile' => false));
     return $this->getOutput($screenBuilder->show(), true);
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:12,代码来源:CScreenScreen.php

示例2: import

 /**
  * Import screens.
  *
  * @param array $screens
  *
  * @return mixed
  */
 public function import(array $screens)
 {
     $screens = zbx_toHash($screens, 'name');
     $this->checkCircularScreenReferences($screens);
     do {
         $independentScreens = $this->getIndependentScreens($screens);
         $screensToCreate = array();
         $screensToUpdate = array();
         foreach ($independentScreens as $name) {
             $screen = $screens[$name];
             unset($screens[$name]);
             $screen = $this->resolveScreenReferences($screen);
             if ($screenId = $this->referencer->resolveScreen($screen['name'])) {
                 $screen['screenid'] = $screenId;
                 $screensToUpdate[] = $screen;
             } else {
                 $screensToCreate[] = $screen;
             }
         }
         if ($this->options['screens']['createMissing'] && $screensToCreate) {
             $newScreenIds = API::Screen()->create($screensToCreate);
             foreach ($screensToCreate as $num => $newScreen) {
                 $screenidId = $newScreenIds['screenids'][$num];
                 $this->referencer->addScreenRef($newScreen['name'], $screenidId);
             }
         }
         if ($this->options['screens']['updateExisting'] && $screensToUpdate) {
             API::Screen()->update($screensToUpdate);
         }
     } while (!empty($independentScreens));
     // if there are screens left in $screens, then they have unresolved references
     foreach ($screens as $screen) {
         $unresolvedReferences = array();
         foreach ($screen['screenitems'] as $screenItem) {
             if ($screenItem['resourcetype'] == SCREEN_RESOURCE_SCREEN && !$this->referencer->resolveScreen($screenItem['resource']['name'])) {
                 $unresolvedReferences[] = $screenItem['resource']['name'];
             }
         }
         $unresolvedReferences = array_unique($unresolvedReferences);
         throw new Exception(_n('Cannot import screen "%1$s": subscreen "%2$s" does not exist.', 'Cannot import screen "%1$s": subscreens "%2$s" do not exist.', $screen['name'], implode(', ', $unresolvedReferences), count($unresolvedReferences)));
     }
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:49,代码来源:CScreenImporter.php

示例3: get

 /**
  * Get screen data.
  *
  * @param array  $options
  * @param bool   $options['editable']		only with read-write permission. Ignored for SuperAdmins
  * @param int    $options['count']			count Hosts, returned column name is rowscount
  * @param string $options['pattern']		search hosts by pattern in host names
  * @param int    $options['limit']			limit selection
  * @param string $options['order']			deprecated parameter (for now)
  *
  * @return array
  */
 public function get($options = [])
 {
     $result = [];
     $user_data = self::$userData;
     $sql_parts = ['select' => ['screens' => 's.screenid'], 'from' => ['screens' => 'screens s'], 'where' => ['template' => 's.templateid IS NULL'], 'order' => [], 'group' => [], 'limit' => null];
     $defOptions = ['screenids' => null, 'userids' => null, 'screenitemids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_EXTEND, 'selectScreenItems' => null, 'selectUsers' => null, 'selectUserGroups' => null, 'countOutput' => null, 'groupCount' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null];
     $options = zbx_array_merge($defOptions, $options);
     if ($options['countOutput'] !== null) {
         $count_output = true;
         $options['output'] = ['screenid'];
         $options['countOutput'] = null;
         $options['limit'] = null;
     } else {
         $count_output = false;
     }
     // Editable + permission check.
     if ($user_data['type'] != USER_TYPE_SUPER_ADMIN && $user_data['type'] != USER_TYPE_ZABBIX_ADMIN && !$options['nopermissions']) {
         $public_screens = '';
         if ($options['editable']) {
             $permission = PERM_READ_WRITE;
         } else {
             $permission = PERM_READ;
             $public_screens = ' OR s.private=' . PUBLIC_SHARING;
         }
         $user_groups = getUserGroupsByUserId($user_data['userid']);
         $sql_parts['where'][] = '(EXISTS (' . 'SELECT NULL' . ' FROM screen_user su' . ' WHERE s.screenid=su.screenid' . ' AND su.userid=' . $user_data['userid'] . ' AND su.permission>=' . $permission . ')' . ' OR EXISTS (' . 'SELECT NULL' . ' FROM screen_usrgrp sg' . ' WHERE s.screenid=sg.screenid' . ' AND ' . dbConditionInt('sg.usrgrpid', $user_groups) . ' AND sg.permission>=' . $permission . ')' . ' OR s.userid=' . $user_data['userid'] . $public_screens . ')';
     }
     // screenids
     if (!is_null($options['screenids'])) {
         zbx_value2array($options['screenids']);
         $sql_parts['where'][] = dbConditionInt('s.screenid', $options['screenids']);
     }
     // userids
     if ($options['userids'] !== null) {
         zbx_value2array($options['userids']);
         $sql_parts['where'][] = dbConditionInt('s.userid', $options['userids']);
     }
     // screenitemids
     if (!is_null($options['screenitemids'])) {
         zbx_value2array($options['screenitemids']);
         $sql_parts['from']['screens_items'] = 'screens_items si';
         $sql_parts['where']['ssi'] = 'si.screenid=s.screenid';
         $sql_parts['where'][] = dbConditionInt('si.screenitemid', $options['screenitemids']);
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('screens s', $options, $sql_parts);
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('screens s', $options, $sql_parts);
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sql_parts['limit'] = $options['limit'];
     }
     $screenids = [];
     $sql_parts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sql_parts);
     $sql_parts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sql_parts);
     $res = DBselect($this->createSelectQueryFromParts($sql_parts), $sql_parts['limit']);
     while ($screen = DBfetch($res)) {
         $screenids[$screen['screenid']] = true;
         $result[$screen['screenid']] = $screen;
     }
     // editable + PERMISSION CHECK
     if ($user_data['type'] != USER_TYPE_SUPER_ADMIN && !$options['nopermissions'] && $screenids) {
         $db_screen_items = DBselect('SELECT si.screenid,si.resourcetype,si.resourceid,si.style' . ' FROM screens_items si' . ' WHERE ' . dbConditionInt('si.screenid', array_keys($screenids)) . ' AND ' . dbConditionInt('si.resourcetype', [SCREEN_RESOURCE_HOSTS_INFO, SCREEN_RESOURCE_TRIGGERS_INFO, SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW, SCREEN_RESOURCE_HOSTGROUP_TRIGGERS, SCREEN_RESOURCE_HOST_TRIGGERS, SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_MAP, SCREEN_RESOURCE_SCREEN]) . ' AND si.resourceid<>0');
         $screens = [];
         while ($db_screen_item = DBfetch($db_screen_items)) {
             if (!array_key_exists($db_screen_item['screenid'], $screens)) {
                 $screens[$db_screen_item['screenid']] = ['groups' => [], 'hosts' => [], 'graphs' => [], 'items' => [], 'maps' => [], 'screens' => []];
             }
             switch ($db_screen_item['resourcetype']) {
                 case SCREEN_RESOURCE_HOSTS_INFO:
                 case SCREEN_RESOURCE_TRIGGERS_INFO:
                 case SCREEN_RESOURCE_TRIGGERS_OVERVIEW:
                 case SCREEN_RESOURCE_DATA_OVERVIEW:
                 case SCREEN_RESOURCE_HOSTGROUP_TRIGGERS:
                     $screens[$db_screen_item['screenid']]['groups'][$db_screen_item['resourceid']] = true;
                     break;
                 case SCREEN_RESOURCE_HOST_TRIGGERS:
                     $screens[$db_screen_item['screenid']]['hosts'][$db_screen_item['resourceid']] = true;
                     break;
                 case SCREEN_RESOURCE_GRAPH:
                     $screens[$db_screen_item['screenid']]['graphs'][$db_screen_item['resourceid']] = true;
                     break;
                 case SCREEN_RESOURCE_SIMPLE_GRAPH:
                 case SCREEN_RESOURCE_PLAIN_TEXT:
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CScreen.php

示例4: dirname

        }
    }
}
if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) {
    require_once dirname(__FILE__) . '/include/page_footer.php';
    exit;
}
/*
 * Display
 */
$data = array('fullscreen' => $_REQUEST['fullscreen'], 'period' => get_request('period'), 'stime' => get_request('stime'), 'elementid' => get_request('elementid', false), 'use_screen_name' => isset($_REQUEST['screenname']));
// if none is provided
if (empty($data['elementid']) && !$data['use_screen_name']) {
    // get element id saved in profile from the last visit
    $data['elementid'] = CProfile::get('web.screens.elementid', null);
}
$data['screens'] = API::Screen()->get(array('nodeids' => get_current_nodeid(), 'output' => array('screenid', 'name')));
// if screen name is provided it takes priority over elementid
if ($data['use_screen_name']) {
    $data['screens'] = zbx_toHash($data['screens'], 'name');
    $data['elementIdentifier'] = get_request('screenname');
} else {
    $data['screens'] = zbx_toHash($data['screens'], 'screenid');
    $data['elementIdentifier'] = $data['elementid'];
}
order_result($data['screens'], 'name');
// render view
$screenView = new CView('monitoring.screen', $data);
$screenView->render();
$screenView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:screens.php

示例5: update_slideshow

function update_slideshow($slideshowid, $name, $delay, $slides)
{
    // validate slides
    if (empty($slides)) {
        error(_('Slide show must contain slides.'));
        return false;
    }
    // validate screens
    $screenids = zbx_objectValues($slides, 'screenid');
    $screens = API::Screen()->get(array('screenids' => $screenids, 'output' => array('screenid')));
    $screens = ZBX_toHash($screens, 'screenid');
    foreach ($screenids as $screenid) {
        if (!isset($screens[$screenid])) {
            error(_('Incorrect screen provided for slide show.'));
            return false;
        }
    }
    // validate slide name
    $db_slideshow = DBfetch(DBselect('SELECT s.slideshowid' . ' FROM slideshows s' . ' WHERE s.name=' . zbx_dbstr($name) . ' AND s.slideshowid<>' . zbx_dbstr($slideshowid) . ' ' . andDbNode('s.slideshowid')));
    if (!empty($db_slideshow)) {
        error(_s('Slide show "%s" already exists.', $name));
        return false;
    }
    $db_slideshow = DBfetchArray(DBselect('SELECT * FROM slideshows WHERE slideshowid=' . zbx_dbstr($slideshowid)));
    $db_slideshow = $db_slideshow[0];
    $changed = false;
    $slideshow = array('name' => $name, 'delay' => $delay);
    foreach ($slideshow as $key => $val) {
        if ($db_slideshow[$key] != $val) {
            $changed = true;
            break;
        }
    }
    if ($changed) {
        if (!($result = DBexecute('UPDATE slideshows SET name=' . zbx_dbstr($name) . ',delay=' . zbx_dbstr($delay) . ' WHERE slideshowid=' . zbx_dbstr($slideshowid)))) {
            return false;
        }
    }
    // get slides
    $db_slides = DBfetchArrayAssoc(DBselect('SELECT s.* FROM slides s WHERE s.slideshowid=' . zbx_dbstr($slideshowid)), 'slideid');
    $slidesToDel = zbx_objectValues($db_slides, 'slideid');
    $slidesToDel = zbx_toHash($slidesToDel);
    $step = 0;
    foreach ($slides as $slide) {
        $slide['delay'] = $slide['delay'] ? $slide['delay'] : 0;
        if (isset($db_slides[$slide['slideid']])) {
            // update slide
            if ($db_slides[$slide['slideid']]['delay'] != $slide['delay'] || $db_slides[$slide['slideid']]['step'] != $step) {
                $result = DBexecute('UPDATE slides SET step=' . zbx_dbstr($step) . ', delay=' . zbx_dbstr($slide['delay']) . ' WHERE slideid=' . zbx_dbstr($slide['slideid']));
            } else {
                $result = true;
            }
            unset($slidesToDel[$slide['slideid']]);
        } else {
            $slideid = get_dbid('slides', 'slideid');
            $result = DBexecute('INSERT INTO slides (slideid,slideshowid,screenid,step,delay)' . ' VALUES (' . zbx_dbstr($slideid) . ',' . zbx_dbstr($slideshowid) . ',' . zbx_dbstr($slide['screenid']) . ',' . zbx_dbstr($step) . ',' . zbx_dbstr($slide['delay']) . ')');
        }
        $step++;
        if (!$result) {
            return false;
        }
    }
    // delete unnecessary slides
    if (!empty($slidesToDel)) {
        DBexecute('DELETE FROM slides WHERE slideid IN(' . implode(',', $slidesToDel) . ')');
    }
    return true;
}
开发者ID:itnihao,项目名称:Zabbix_,代码行数:68,代码来源:screens.inc.php

示例6: get_slideshow_by_slideshowid

if (hasRequest('elementid')) {
    $data['screen'] = get_slideshow_by_slideshowid(getRequest('elementid'), PERM_READ);
    if (!$data['screen']) {
        access_deny();
    }
} else {
    $data['screen'] = [];
}
/*
 * Actions
 */
if ((hasRequest('widgetRefresh') || hasRequest('widgetRefreshRate')) && $data['screen']) {
    $elementId = getRequest('elementid');
    $screen = getSlideshowScreens($elementId, getRequest('upd_counter'));
    // display screens
    $dbScreens = API::Screen()->get(['screenids' => $screen['screenid'], 'output' => API_OUTPUT_EXTEND, 'selectScreenItems' => API_OUTPUT_EXTEND]);
    if (!$dbScreens) {
        insert_js('alert("' . _('No permissions') . '");');
    } else {
        $dbScreen = reset($dbScreens);
        // get fresh widget data
        if (hasRequest('widgetRefresh')) {
            $screenBuilder = new CScreenBuilder(['screen' => $dbScreen, 'mode' => SCREEN_MODE_PREVIEW, 'profileIdx' => 'web.slides', 'profileIdx2' => $elementId, 'hostid' => getRequest('hostid'), 'period' => getRequest('period'), 'stime' => getRequest('stime')]);
            CScreenBuilder::insertScreenCleanJs();
            echo (new CDiv($screenBuilder->show()))->addClass(ZBX_STYLE_TABLE_FORMS_CONTAINER)->toString();
            CScreenBuilder::insertScreenStandardJs(['timeline' => $screenBuilder->timeline, 'profileIdx' => $screenBuilder->profileIdx]);
            insertPagePostJs();
        }
        // refresh rate
        if (hasRequest('widgetRefreshRate')) {
            $widgetRefreshRate = substr(getRequest('widgetRefreshRate'), 1);
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:slides.php

示例7: checkInput

 /**
  * Validates screen items.
  *
  * If the $dbScreenItems parameter is given, the screen items will be matched
  * against the ones given in $dbScreenItems. If a screen item is not present in
  * $dbScreenItems, a ZBX_API_ERROR_PERMISSIONS exception will be thrown.
  *
  * @throws APIException if a validation error occurred.
  *
  * @param array $screenItems
  * @param array $dbScreenItems
  */
 protected function checkInput(array $screenItems, array $dbScreenItems = array())
 {
     $hostGroupsIds = $hostIds = $graphIds = $itemIds = $mapIds = $screenIds = array();
     $screenItems = $this->extendFromObjects($screenItems, $dbScreenItems, array('resourcetype', 'resourceid'));
     foreach ($screenItems as $screenItem) {
         // check permissions
         if (isset($screenItem['screenitemid']) && !isset($dbScreenItems[$screenItem['screenitemid']])) {
             self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
         }
         if (!$this->isValidResourceType($screenItem['resourcetype'])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect resource type provided for screen item.'));
         }
         if (!isset($screenItem['resourceid'])) {
             $screenItem['resourceid'] = null;
         }
         // check resource id
         switch ($screenItem['resourcetype']) {
             case SCREEN_RESOURCE_HOSTS_INFO:
             case SCREEN_RESOURCE_TRIGGERS_INFO:
             case SCREEN_RESOURCE_TRIGGERS_OVERVIEW:
             case SCREEN_RESOURCE_HOSTGROUP_TRIGGERS:
             case SCREEN_RESOURCE_DATA_OVERVIEW:
                 if (in_array($screenItem['resourcetype'], array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) {
                     if (!$screenItem['resourceid']) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('No host group ID provided for screen element.'));
                     }
                 }
                 if ($screenItem['resourceid']) {
                     $hostGroupsIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 }
                 break;
             case SCREEN_RESOURCE_HOST_TRIGGERS:
                 if ($screenItem['resourceid']) {
                     $hostIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 }
                 break;
             case SCREEN_RESOURCE_GRAPH:
                 if (!$screenItem['resourceid']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('No graph ID provided for screen element.'));
                 }
                 $graphIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 break;
             case SCREEN_RESOURCE_SIMPLE_GRAPH:
             case SCREEN_RESOURCE_PLAIN_TEXT:
                 if (!$screenItem['resourceid']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('No item ID provided for screen element.'));
                 }
                 $itemIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 break;
             case SCREEN_RESOURCE_CLOCK:
                 if (isset($screenItem['style']) && $screenItem['style'] == TIME_TYPE_HOST) {
                     if (!$screenItem['resourceid']) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('No item ID provided for screen element.'));
                     }
                     $itemIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 }
                 break;
             case SCREEN_RESOURCE_MAP:
                 if (!$screenItem['resourceid']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('No map ID provided for screen element.'));
                 }
                 $mapIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 break;
             case SCREEN_RESOURCE_SCREEN:
                 if (!$screenItem['resourceid']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('No screen ID provided for screen element.'));
                 }
                 $screenIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 break;
         }
         // check url
         if ($screenItem['resourcetype'] == SCREEN_RESOURCE_URL) {
             if (!isset($screenItem['url']) || zbx_empty($screenItem['url'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No URL provided for screen element.'));
             }
         }
         // check "Show lines"
         if (isset($screenItem['elements'])) {
             switch ($screenItem['resourcetype']) {
                 case SCREEN_RESOURCE_ACTIONS:
                 case SCREEN_RESOURCE_EVENTS:
                 case SCREEN_RESOURCE_HOSTGROUP_TRIGGERS:
                 case SCREEN_RESOURCE_HOST_TRIGGERS:
                 case SCREEN_RESOURCE_PLAIN_TEXT:
                     if ($screenItem['elements'] < 1 || $screenItem['elements'] > 100) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect value "%1$s" for "%2$s" field: must be between %3$s and %4$s.', $screenItem['elements'], 'elements', 1, 100));
                     }
                     break;
//.........这里部分代码省略.........
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:101,代码来源:CScreenItem.php

示例8: getFavouriteScreens

 /**
  * 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);
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:36,代码来源:CMenuPopupHelper.php

示例9: reset

    $data = [];
    if ($resourceId > 0) {
        $data = API::HostGroup()->get(['groupids' => $resourceId, 'output' => ['groupid', 'name'], 'editable' => true]);
        if ($data) {
            $data = reset($data);
        }
    }
    $screenFormList->addRow(_('Group'), (new CMultiSelect(['name' => 'resourceid', 'objectName' => 'hostGroup', 'objectOptions' => ['editable' => true], 'data' => $data ? [['id' => $data['groupid'], 'name' => $data['name']]] : null, 'selectedLimit' => 1, 'popup' => ['parameters' => 'srctbl=host_groups&dstfrm=' . $form->getName() . '&dstfld1=resourceid' . '&srcfld1=groupid']]))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH));
    $screenFormList->addRow(_('Application'), (new CTextBox('application', $application, false, 255))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH));
} elseif ($resourceType == SCREEN_RESOURCE_SCREEN) {
    $caption = '';
    $id = 0;
    if ($resourceId > 0) {
        $db_screens = DBselect('SELECT s.screenid,s.name FROM screens s WHERE s.screenid=' . zbx_dbstr($resourceId));
        while ($row = DBfetch($db_screens)) {
            $screen = API::Screen()->get(['screenids' => $row['screenid'], 'output' => ['screenid']]);
            if (empty($screen)) {
                continue;
            }
            if (check_screen_recursion($_REQUEST['screenid'], $row['screenid'])) {
                continue;
            }
            $caption = $row['name'];
            $id = $resourceId;
        }
    }
    $form->addVar('resourceid', $id);
    $screenFormList->addRow(_('Screen'), [(new CTextBox('caption', $caption, true))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), (new CButton('select', _('Select')))->addClass(ZBX_STYLE_BTN_GREY)->onClick('javascript: return PopUp("popup.php?srctbl=screens2&srcfld1=screenid&srcfld2=name' . '&dstfrm=' . $form->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&screenid=' . $_REQUEST['screenid'] . '");')]);
} elseif ($resourceType == SCREEN_RESOURCE_HOSTS_INFO || $resourceType == SCREEN_RESOURCE_TRIGGERS_INFO) {
    $data = [];
    if ($resourceId > 0) {
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:monitoring.screen.constructor.edit.php

示例10: checkInput

 /**
  * Validates screen items.
  *
  * If the $dbScreenItems parameter is given, the screen items will be matched
  * against the ones given in $dbScreenItems. If a screen item is not present in
  * $dbScreenItems, a ZBX_API_ERROR_PERMISSIONS exception will be thrown.
  *
  * @throws APIException if a validation error occurred.
  *
  * @param array $screenItems
  * @param array $dbScreenItems
  */
 protected function checkInput(array $screenItems, array $dbScreenItems = array())
 {
     $hostGroupsIds = array();
     $hostIds = array();
     $graphIds = array();
     $itemIds = array();
     $mapIds = array();
     $screenIds = array();
     $itemPrototypeIds = array();
     $graphPrototypeIds = array();
     $screenItems = $this->extendFromObjects($screenItems, $dbScreenItems, array('resourcetype'));
     $validStyles = array(SCREEN_RESOURCE_CLOCK => array(TIME_TYPE_LOCAL, TIME_TYPE_SERVER, TIME_TYPE_HOST), SCREEN_RESOURCE_DATA_OVERVIEW => array(STYLE_TOP, STYLE_LEFT), SCREEN_RESOURCE_TRIGGERS_OVERVIEW => array(STYLE_TOP, STYLE_LEFT), SCREEN_RESOURCE_HOSTS_INFO => array(STYLE_VERTICAL, STYLE_HORIZONTAL), SCREEN_RESOURCE_TRIGGERS_INFO => array(STYLE_VERTICAL, STYLE_HORIZONTAL));
     foreach ($screenItems as $screenItem) {
         // check permissions
         if (isset($screenItem['screenitemid']) && !isset($dbScreenItems[$screenItem['screenitemid']])) {
             self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
         }
         if (!$this->isValidResourceType($screenItem['resourcetype'])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect resource type provided for screen item.'));
         }
         if (!isset($screenItem['resourceid'])) {
             $screenItem['resourceid'] = null;
         }
         // check resource id
         switch ($screenItem['resourcetype']) {
             case SCREEN_RESOURCE_HOSTS_INFO:
             case SCREEN_RESOURCE_TRIGGERS_INFO:
             case SCREEN_RESOURCE_TRIGGERS_OVERVIEW:
             case SCREEN_RESOURCE_HOSTGROUP_TRIGGERS:
             case SCREEN_RESOURCE_DATA_OVERVIEW:
                 $overviewResources = array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW);
                 if (in_array($screenItem['resourcetype'], $overviewResources)) {
                     if (!$screenItem['resourceid']) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('No host group ID provided for screen element.'));
                     }
                 }
                 if ($screenItem['resourceid']) {
                     $hostGroupsIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 }
                 break;
             case SCREEN_RESOURCE_HOST_TRIGGERS:
                 if ($screenItem['resourceid']) {
                     $hostIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 }
                 break;
             case SCREEN_RESOURCE_GRAPH:
                 if (!$screenItem['resourceid']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('No graph ID provided for screen element.'));
                 }
                 $graphIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 break;
             case SCREEN_RESOURCE_LLD_GRAPH:
                 if (!$screenItem['resourceid']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('No graph prototype ID provided for screen element.'));
                 }
                 $graphPrototypeIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 break;
             case SCREEN_RESOURCE_LLD_SIMPLE_GRAPH:
                 if (!$screenItem['resourceid']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('No item prototype ID provided for screen element.'));
                 }
                 $itemPrototypeIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 break;
             case SCREEN_RESOURCE_SIMPLE_GRAPH:
             case SCREEN_RESOURCE_PLAIN_TEXT:
                 if (!$screenItem['resourceid']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('No item ID provided for screen element.'));
                 }
                 $itemIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 break;
             case SCREEN_RESOURCE_CLOCK:
                 if (isset($screenItem['style'])) {
                     if ($screenItem['style'] == TIME_TYPE_HOST) {
                         if (!$screenItem['resourceid']) {
                             self::exception(ZBX_API_ERROR_PARAMETERS, _('No item ID provided for screen element.'));
                         }
                         $itemIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                     } elseif ($screenItem['resourceid']) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot set resource ID for screen element.'));
                     }
                 }
                 break;
             case SCREEN_RESOURCE_MAP:
                 if (!$screenItem['resourceid']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('No map ID provided for screen element.'));
                 }
                 $mapIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 break;
//.........这里部分代码省略.........
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:101,代码来源:CScreenItem.php

示例11: CButton

        $table->addRow($name);
    }
    if ($multiselect) {
        $button = new CButton('select', _('Select'), "javascript: addSelectedValues('screens', " . zbx_jsvalue($reference) . ');');
        $table->setFooter(new CCol($button, 'right'));
        insert_js('var popupReference = ' . zbx_jsvalue($screens, true) . ';');
    }
    zbx_add_post_js('chkbxRange.pageGoName = "screens";');
    $form->addItem($table);
    $form->show();
} elseif ($srctbl == 'screens2') {
    require_once dirname(__FILE__) . '/include/screens.inc.php';
    $table = new CTableInfo(_('No screens defined.'));
    $table->setHeader(_('Name'));
    $options = array('nodeids' => $nodeid, 'output' => API_OUTPUT_EXTEND);
    $screens = API::Screen()->get($options);
    order_result($screens, 'name');
    foreach ($screens as $row) {
        $row['node_name'] = get_node_name_by_elid($row['screenid'], true);
        if (check_screen_recursion($_REQUEST['screenid'], $row['screenid'])) {
            continue;
        }
        $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
        $name = new CLink($row['name'], '#');
        $row['name'] = $row['node_name'] . $row['name'];
        $action = get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : '');
        $name->setAttribute('onclick', $action . ' close_window(); return false;');
        $table->addRow($name);
    }
    $table->show();
} elseif ($srctbl == 'overview') {
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:popup.php

示例12: selectScreens

 /**
  * Select screen ids for previously added screen names.
  */
 protected function selectScreens()
 {
     if (!empty($this->screens)) {
         $this->screensRefs = [];
         $db_screens = API::Screen()->get(['filter' => ['name' => $this->screens], 'output' => ['screenid', 'name']]);
         foreach ($db_screens as $db_screen) {
             $this->screensRefs[$db_screen['name']] = $db_screen['screenid'];
         }
         $this->screens = [];
     }
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:14,代码来源:CImportReferencer.php

示例13: addValues

            $values = [$dstfld1 => $screen[$srcfld1], $dstfld2 => $screen[$srcfld2]];
            $js_action = 'javascript: addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . '); close_window(); return false;';
        }
        $name->onClick($js_action . ' jQuery(this).removeAttr("onclick");');
        $table->addRow([$multiselect ? new CCheckBox('screens[' . zbx_jsValue($screen[$srcfld1]) . ']', $screen['screenid']) : null, $name]);
    }
    if ($multiselect) {
        $table->setFooter(new CCol((new CButton('select', _('Select')))->onClick("javascript: addSelectedValues('screens', " . zbx_jsvalue($reference) . ');')));
        insert_js('var popupReference = ' . zbx_jsvalue($screens, true) . ';');
    }
    $form->addItem($table);
    $widget->addItem($form)->show();
} elseif ($srctbl == 'screens2') {
    require_once dirname(__FILE__) . '/include/screens.inc.php';
    $table = (new CTableInfo())->setHeader(_('Name'));
    $screens = API::Screen()->get(['output' => ['screenid', 'name'], 'editable' => $writeonly === null ? null : true]);
    order_result($screens, 'name');
    foreach ($screens as $screen) {
        if (check_screen_recursion($_REQUEST['screenid'], $screen['screenid'])) {
            continue;
        }
        $name = new CLink($screen['name'], 'javascript:void(0);');
        $action = get_window_opener($dstfrm, $dstfld1, $screen[$srcfld1]) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $screen[$srcfld2]) : '');
        $name->onClick($action . ' close_window(); return false;');
        $table->addRow($name);
    }
    $widget->addItem($table)->show();
} elseif ($srctbl === 'drules') {
    $table = (new CTableInfo())->setHeader(_('Name'));
    $dRules = API::DRule()->get(['output' => ['druleid', 'name']]);
    order_result($dRules, 'name');
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:popup.php

示例14: validateDelete

 /**
  * Validates the input parameters for the delete() method.
  *
  * @param array $userids
  *
  * @throws APIException if the input is invalid.
  */
 protected function validateDelete(array $userids)
 {
     if (!$userids) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty input parameter.'));
     }
     $this->checkPermissions($userids);
     $this->checkDeleteCurrentUser($userids);
     $this->checkDeleteInternal($userids);
     // Check if deleted users have a map.
     $user_maps = API::Map()->get(['output' => ['name', 'userid'], 'userids' => $userids]);
     if ($user_maps) {
         // Get first problem user and map.
         $user_map = reset($user_maps);
         $db_users = $this->get(['output' => ['alias'], 'userids' => [$user_map['userid']], 'limit' => 1]);
         // Get first problem user.
         $db_user = reset($db_users);
         self::exception(ZBX_API_ERROR_PARAMETERS, _s('User "%1$s" is map "%2$s" owner.', $db_user['alias'], $user_map['name']));
     }
     // Check if deleted users have a screen.
     $user_screens = API::Screen()->get(['output' => ['name', 'userid'], 'userids' => $userids]);
     if ($user_screens) {
         // Get first problem user and screen.
         $user_screen = reset($user_screens);
         $db_users = $this->get(['output' => ['alias'], 'userids' => [$user_screen['userid']], 'limit' => 1]);
         // Get first problem user.
         $db_user = reset($db_users);
         self::exception(ZBX_API_ERROR_PARAMETERS, _s('User "%1$s" is screen "%2$s" owner.', $db_user['alias'], $user_screen['name']));
     }
     // Check if deleted users have a slide show.
     $user_slideshow = DBfetch(DBselect('SELECT s.name,s.userid' . ' FROM slideshows s' . ' WHERE ' . dbConditionInt('s.userid', $userids)));
     if ($user_slideshow) {
         $db_users = $this->get(['output' => ['alias'], 'userids' => [$user_slideshow['userid']], 'limit' => 1]);
         // Get first problem user.
         $db_user = reset($db_users);
         self::exception(ZBX_API_ERROR_PARAMETERS, _s('User "%1$s" is slide show "%2$s" owner.', $db_user['alias'], $user_slideshow['name']));
     }
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:44,代码来源:CUser.php

示例15: update_slideshow

function update_slideshow($data)
{
    $user_data = CWebUser::$data;
    // Validate slides.
    if (empty($data['slides'])) {
        error(_('Slide show must contain slides.'));
        return false;
    }
    // validate screens.
    $screenids = zbx_objectValues($data['slides'], 'screenid');
    $screens = API::Screen()->get(['output' => ['screenid'], 'screenids' => $screenids, 'preservekeys' => true]);
    foreach ($screenids as $screenid) {
        if (!array_key_exists($screenid, $screens)) {
            error(_('Incorrect screen provided for slide show.'));
            return false;
        }
    }
    // Validate slide name.
    $db_slideshow = DBfetch(DBselect('SELECT s.slideshowid' . ' FROM slideshows s' . ' WHERE s.name=' . zbx_dbstr($data['name']) . ' AND s.slideshowid<>' . zbx_dbstr($data['slideshowid'])));
    if ($db_slideshow) {
        error(_s('Slide show "%1$s" already exists.', $data['name']));
        return false;
    }
    // Validate slide show owner.
    if (array_key_exists('userid', $data)) {
        if ($data['userid'] === null || $data['userid'] === '') {
            error(_('Slide show owner cannot be empty.'));
            return false;
        } elseif ($data['userid'] != $user_data['userid'] && $user_data['type'] != USER_TYPE_SUPER_ADMIN && $user_data['type'] != USER_TYPE_ZABBIX_ADMIN) {
            error(_('Only administrators can set slide show owner.'));
            return false;
        }
    }
    $to_update = $data;
    unset($to_update['slideshowid'], $to_update['slides'], $to_update['users'], $to_update['userGroups']);
    DB::update('slideshows', ['values' => $to_update, 'where' => ['slideshowid' => $data['slideshowid']]]);
    // Read-only sharing validation.
    foreach ($data['users'] as $user) {
        if ($data['private'] == PUBLIC_SHARING && $user['permission'] == PERM_READ) {
            error(_s('Slide show "%1$s" is public and read-only sharing is disallowed.', $data['name']));
            return false;
        }
    }
    foreach ($data['userGroups'] as $user_group) {
        if ($data['private'] == PUBLIC_SHARING && $user_group['permission'] == PERM_READ) {
            error(_s('Slide show "%1$s" is public and read-only sharing is disallowed.', $data['name']));
            return false;
        }
    }
    $shared_userids_to_delete = [];
    $shared_users_to_update = [];
    $shared_users_to_add = [];
    $shared_user_groupids_to_delete = [];
    $shared_user_groups_to_update = [];
    $shared_user_groups_to_add = [];
    // Slide show user shares.
    $db_slideshow['users'] = DBfetchArray(DBselect('SELECT s.userid,s.permission,s.slideshowuserid' . ' FROM slideshow_user s' . ' WHERE s.slideshowid=' . zbx_dbstr(getRequest('slideshowid'))));
    $userids = [];
    foreach ($db_slideshow['users'] as $user) {
        $userids[] = $user['userid'];
    }
    $allowed_users = API::User()->get(['output' => ['userid'], 'userids' => $userids, 'preservekeys' => true]);
    foreach ($db_slideshow['users'] as $key => $user) {
        if (!array_key_exists($user['userid'], $allowed_users)) {
            unset($db_slideshow['users'][$key]);
        }
    }
    $user_shares_diff = zbx_array_diff($data['users'], $db_slideshow['users'], 'userid');
    foreach ($user_shares_diff['both'] as $update_user_share) {
        $shared_users_to_update[] = ['values' => $update_user_share, 'where' => ['userid' => $update_user_share['userid'], 'slideshowid' => $data['slideshowid']]];
    }
    foreach ($user_shares_diff['first'] as $new_shared_user) {
        $new_shared_user['slideshowid'] = $data['slideshowid'];
        $shared_users_to_add[] = $new_shared_user;
    }
    $shared_userids_to_delete = zbx_objectValues($user_shares_diff['second'], 'slideshowuserid');
    // Slide show user group shares.
    $db_slideshow['userGroups'] = DBfetchArray(DBselect('SELECT s.usrgrpid,s.permission,s.slideshowusrgrpid' . ' FROM slideshow_usrgrp s' . ' WHERE s.slideshowid=' . zbx_dbstr(getRequest('slideshowid'))));
    $usrgrpids = [];
    foreach ($db_slideshow['userGroups'] as $user_group) {
        $usrgrpids[] = $user_group['usrgrpid'];
    }
    $allowed_user_groups = API::UserGroup()->get(['output' => ['usrgrpid'], 'usrgrpids' => $usrgrpids, 'preservekeys' => true]);
    foreach ($db_slideshow['userGroups'] as $key => $user_group) {
        if (!array_key_exists($user_group['usrgrpid'], $allowed_user_groups)) {
            unset($db_slideshow['userGroups'][$key]);
        }
    }
    $user_group_shares_diff = zbx_array_diff($data['userGroups'], $db_slideshow['userGroups'], 'usrgrpid');
    foreach ($user_group_shares_diff['both'] as $update_user_share) {
        $shared_user_groups_to_update[] = ['values' => $update_user_share, 'where' => ['usrgrpid' => $update_user_share['usrgrpid'], 'slideshowid' => $data['slideshowid']]];
    }
    foreach ($user_group_shares_diff['first'] as $new_shared_user_group) {
        $new_shared_user_group['slideshowid'] = $data['slideshowid'];
        $shared_user_groups_to_add[] = $new_shared_user_group;
    }
    $shared_user_groupids_to_delete = zbx_objectValues($user_group_shares_diff['second'], 'slideshowusrgrpid');
    // User shares.
    DB::insert('slideshow_user', $shared_users_to_add);
    DB::update('slideshow_user', $shared_users_to_update);
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:screens.inc.php


注:本文中的API::Screen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。