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


PHP DBfetchArrayAssoc函数代码示例

本文整理汇总了PHP中DBfetchArrayAssoc函数的典型用法代码示例。如果您正苦于以下问题:PHP DBfetchArrayAssoc函数的具体用法?PHP DBfetchArrayAssoc怎么用?PHP DBfetchArrayAssoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: array

     // get application ids
     $applications = API::Application()->get(array('hostids' => $pageFilter->hostid > 0 ? $pageFilter->hostid : null, 'groupids' => $pageFilter->groupid > 0 ? $pageFilter->groupid : null, 'output' => array('applicationid'), 'editable' => true, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1));
     $applicationIds = zbx_objectValues($applications, 'applicationid');
     // get applications
     $data['applications'] = API::Application()->get(array('applicationids' => $applicationIds, 'output' => API_OUTPUT_EXTEND, 'selectItems' => array('itemid'), 'selectHost' => array('hostid', 'name')));
     order_result($data['applications'], $sortField, $sortOrder);
     // fetch template application source parents
     $applicationSourceParentIds = getApplicationSourceParentIds($applicationIds);
     $parentAppIds = array();
     foreach ($applicationSourceParentIds as $applicationParentIds) {
         foreach ($applicationParentIds as $parentId) {
             $parentAppIds[$parentId] = $parentId;
         }
     }
     if ($parentAppIds) {
         $parentTemplates = DBfetchArrayAssoc(DBselect('SELECT a.applicationid,h.hostid,h.name' . ' FROM applications a,hosts h' . ' WHERE a.hostid=h.hostid' . ' AND ' . dbConditionInt('a.applicationid', $parentAppIds)), 'applicationid');
         foreach ($data['applications'] as &$application) {
             if ($application['templateids'] && isset($applicationSourceParentIds[$application['applicationid']])) {
                 foreach ($applicationSourceParentIds[$application['applicationid']] as $parentAppId) {
                     $application['sourceTemplates'][] = $parentTemplates[$parentAppId];
                 }
             }
         }
     }
 } else {
     $data['applications'] = array();
 }
 // get paging
 $data['paging'] = getPagingLine($data['applications'], $sortOrder);
 // render view
 $applicationView = new CView('configuration.application.list', $data);
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:31,代码来源:applications.php

示例2: delete

 /**
  * Delete proxy.
  *
  * @param array	$proxyIds
  *
  * @return array
  */
 public function delete(array $proxyIds)
 {
     $this->validateDelete($proxyIds);
     $dbProxies = DBselect('SELECT h.hostid,h.host' . ' FROM hosts h' . ' WHERE ' . dbConditionInt('h.hostid', $proxyIds));
     $dbProxies = DBfetchArrayAssoc($dbProxies, 'hostid');
     $actionIds = array();
     // get conditions
     $dbActions = DBselect('SELECT DISTINCT c.actionid' . ' FROM conditions c' . ' WHERE c.conditiontype=' . CONDITION_TYPE_PROXY . ' AND ' . dbConditionString('c.value', $proxyIds));
     while ($dbAction = DBfetch($dbActions)) {
         $actionIds[$dbAction['actionid']] = $dbAction['actionid'];
     }
     if ($actionIds) {
         DB::update('actions', array('values' => array('status' => ACTION_STATUS_DISABLED), 'where' => array('actionid' => $actionIds)));
     }
     // delete action conditions
     DB::delete('conditions', array('conditiontype' => CONDITION_TYPE_PROXY, 'value' => $proxyIds));
     // delete interface
     DB::delete('interface', array('hostid' => $proxyIds));
     // delete host
     DB::delete('hosts', array('hostid' => $proxyIds));
     // TODO: remove info from API
     foreach ($dbProxies as $proxy) {
         info(_s('Deleted: Proxy "%1$s".', $proxy['host']));
         add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_PROXY, '[' . $proxy['host'] . '] [' . $proxy['hostid'] . ']');
     }
     return array('proxyids' => $proxyIds);
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:34,代码来源:CProxy.php

示例3: applyPostSqlFiltering


//.........这里部分代码省略.........
         // Trigger dependency map.
         $downToUpTriggerIds = [];
         // Values (state) of each "up" trigger ID is stored in here.
         $upTriggerValues = [];
         // Will contain IDs of all triggers either disabled directly, or by having disabled item or disabled host.
         $disabledTriggerIds = [];
         // First loop uses result trigger IDs.
         $triggerIds = $resultTriggerIds;
         do {
             // Fetch all dependency records where "down" trigger IDs are in current iteration trigger IDs.
             $dbResult = DBselect('SELECT d.triggerid_down,d.triggerid_up,t.value' . ' FROM trigger_depends d,triggers t' . ' WHERE d.triggerid_up=t.triggerid' . ' AND ' . dbConditionInt('d.triggerid_down', $triggerIds));
             // Add trigger IDs as keys and empty arrays as values.
             $downToUpTriggerIds = $downToUpTriggerIds + array_fill_keys($triggerIds, []);
             $triggerIds = [];
             while ($dependency = DBfetch($dbResult)) {
                 // Trigger ID for "down" trigger, which has dependencies.
                 $downTriggerId = $dependency['triggerid_down'];
                 // Trigger ID for "up" trigger, on which the other ("up") trigger depends.
                 $upTriggerId = $dependency['triggerid_up'];
                 // Add "up" trigger ID to mapping. We also index by $upTrigger because later these arrays
                 // are combined with + and this way indexes and values do not break.
                 $downToUpTriggerIds[$downTriggerId][$upTriggerId] = $upTriggerId;
                 // Add ID of this "up" trigger to all known "up" triggers.
                 $allUpTriggerIds[] = $upTriggerId;
                 // Remember value of this "up" trigger.
                 $upTriggerValues[$upTriggerId] = $dependency['value'];
                 // Add ID of this "up" trigger to the list of trigger IDs which should be mapped.
                 $triggerIds[] = $upTriggerId;
             }
         } while ($triggerIds);
         // Fetch trigger IDs for triggers that are disabled, have disabled items or disabled item hosts.
         $dbResult = DBSelect('SELECT t.triggerid' . ' FROM triggers t,functions f,items i,hosts h' . ' WHERE t.triggerid=f.triggerid' . ' AND f.itemid=i.itemid' . ' AND i.hostid=h.hostid' . ' AND (' . 'i.status=' . ITEM_STATUS_DISABLED . ' OR h.status=' . HOST_STATUS_NOT_MONITORED . ' OR t.status=' . TRIGGER_STATUS_DISABLED . ')' . ' AND ' . dbConditionInt('t.triggerid', $allUpTriggerIds));
         while ($row = DBfetch($dbResult)) {
             $resultTriggerId = $row['triggerid'];
             $disabledTriggerIds[$resultTriggerId] = $resultTriggerId;
         }
         // Now process all mapped dependencies and unset any disabled "up" triggers so they do not participate in
         // decisions regarding nesting resolution in next step.
         foreach ($downToUpTriggerIds as $downTriggerId => $upTriggerIds) {
             $upTriggerIdsToUnset = [];
             foreach ($upTriggerIds as $upTriggerId) {
                 if (isset($disabledTriggerIds[$upTriggerId])) {
                     unset($downToUpTriggerIds[$downTriggerId][$upTriggerId]);
                 }
             }
         }
         // Resolve dependencies for all result set triggers.
         foreach ($resultTriggerIds as $resultTriggerId) {
             // We start with result trigger.
             $triggerIds = [$resultTriggerId];
             // This also is unrolled recursive function and is repeated until there are no more trigger IDs to
             // check, add and resolve.
             do {
                 $nextTriggerIds = [];
                 foreach ($triggerIds as $triggerId) {
                     // Loop through all "up" triggers.
                     foreach ($downToUpTriggerIds[$triggerId] as $upTriggerId) {
                         if ($downToUpTriggerIds[$upTriggerId]) {
                             // If there this "up" trigger has "up" triggers of it's own, merge them and proceed with recursion.
                             $downToUpTriggerIds[$resultTriggerId] += $downToUpTriggerIds[$upTriggerId];
                             // Add trigger ID to be processed in next loop iteration.
                             $nextTriggerIds[] = $upTriggerId;
                         }
                     }
                 }
                 $triggerIds = $nextTriggerIds;
             } while ($triggerIds);
         }
         // Clean result set.
         foreach ($resultTriggerIds as $resultTriggerId) {
             foreach ($downToUpTriggerIds[$resultTriggerId] as $upTriggerId) {
                 // If "up" trigger is in problem state, dependent trigger should not be returned and is removed
                 // from results.
                 if ($upTriggerValues[$upTriggerId] == TRIGGER_VALUE_TRUE) {
                     unset($triggers[$resultTriggerId]);
                 }
             }
             // Check if result trigger is disabled and if so, remove from results.
             if (isset($disabledTriggerIds[$resultTriggerId])) {
                 unset($triggers[$resultTriggerId]);
             }
         }
     }
     // withLastEventUnacknowledged
     if (!is_null($options['withLastEventUnacknowledged'])) {
         $triggerIds = zbx_objectValues($triggers, 'triggerid');
         $eventIds = [];
         $eventsDb = DBselect('SELECT MAX(e.eventid) AS eventid,e.objectid' . ' FROM events e' . ' WHERE e.object=' . EVENT_OBJECT_TRIGGER . ' AND e.source=' . EVENT_SOURCE_TRIGGERS . ' AND ' . dbConditionInt('e.objectid', $triggerIds) . ' AND ' . dbConditionInt('e.value', [TRIGGER_VALUE_TRUE]) . ' GROUP BY e.objectid');
         while ($event = DBfetch($eventsDb)) {
             $eventIds[] = $event['eventid'];
         }
         $correctTriggerIds = DBfetchArrayAssoc(DBselect('SELECT e.objectid' . ' FROM events e ' . ' WHERE ' . dbConditionInt('e.eventid', $eventIds) . ' AND e.acknowledged=0'), 'objectid');
         foreach ($triggers as $triggerId => $trigger) {
             if (!isset($correctTriggerIds[$triggerId])) {
                 unset($triggers[$triggerId]);
             }
         }
     }
     return $triggers;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CTrigger.php

示例4: resolveGraphsFunctionalItemMacros

 /**
  * Resolve functional macros, like {hostname:key.function(param)}.
  * If macro can not be resolved it is replaced with UNRESOLVED_MACRO_STRING string i.e. "*UNKNOWN*".
  *
  * Supports function "last", "min", "max" and "avg".
  * Supports seconds as parameters, except "last" function.
  * Second parameter like {hostname:key.last(0,86400) and offsets like {hostname:key.last(#1)} are not supported.
  * Supports postfixes s,m,h,d and w for parameter.
  *
  * @param array  $strList				list of string in which macros should be resolved
  * @param array  $itemsList				list of	lists of graph items
  * @param int    $items[n][m]['hostid']	n-th graph m-th item corresponding host Id
  * @param string $items[n][m]['host']	n-th graph m-th item corresponding host name
  *
  * @return array	list of strings with macros replaced with corresponding values
  */
 private function resolveGraphsFunctionalItemMacros($strList, $itemsList)
 {
     // retrieve all string macros and all host-key pairs
     $hostKeyPairs = $matchesList = array();
     $items = reset($itemsList);
     foreach ($strList as $str) {
         // extract all macros into $matches - keys: macros, hosts, keys, functions and parameters are used
         // searches for macros, for example, "{somehost:somekey["param[123]"].min(10m)}"
         preg_match_all('/(?P<macros>{' . '(?P<hosts>(' . ZBX_PREG_HOST_FORMAT . '|({(' . self::PATTERN_HOST_INTERNAL . ')' . self::PATTERN_MACRO_PARAM . '}))):' . '(?P<keys>' . ZBX_PREG_ITEM_KEY_FORMAT . ')\\.' . '(?P<functions>(last|max|min|avg))\\(' . '(?P<parameters>([0-9]+[' . ZBX_TIME_SUFFIXES . ']?)?)' . '\\)}{1})/Uux', $str, $matches, PREG_OFFSET_CAPTURE);
         if (!empty($matches['hosts'])) {
             foreach ($matches['hosts'] as $i => $host) {
                 $matches['hosts'][$i][0] = $this->resolveGraphPositionalMacros($host[0], $items);
                 if ($matches['hosts'][$i][0] !== UNRESOLVED_MACRO_STRING) {
                     if (!isset($hostKeyPairs[$matches['hosts'][$i][0]])) {
                         $hostKeyPairs[$matches['hosts'][$i][0]] = array();
                     }
                     $hostKeyPairs[$matches['hosts'][$i][0]][$matches['keys'][$i][0]] = 1;
                 }
             }
             $matchesList[] = $matches;
             $items = next($itemsList);
         }
     }
     // stop, if no macros found
     if (empty($matchesList)) {
         return $strList;
     }
     // build item retrieval query from host-key pairs
     $query = 'SELECT h.host,i.key_,i.itemid,i.value_type,i.units,i.valuemapid' . ' FROM items i, hosts h' . ' WHERE i.hostid=h.hostid AND (';
     foreach ($hostKeyPairs as $host => $keys) {
         $query .= '(h.host=' . zbx_dbstr($host) . ' AND i.key_ IN(';
         foreach ($keys as $key => $val) {
             $query .= zbx_dbstr($key) . ',';
         }
         $query = substr($query, 0, -1) . ')) OR ';
     }
     $query = substr($query, 0, -4) . ')';
     // get necessary items for all graph strings
     $items = DBfetchArrayAssoc(DBselect($query), 'itemid');
     $allowedItems = API::Item()->get(array('itemids' => array_keys($items), 'webitems' => true, 'output' => array('itemid', 'value_type', 'lastvalue', 'lastclock'), 'preservekeys' => true));
     // map item data only for allowed items
     foreach ($items as $item) {
         if (isset($allowedItems[$item['itemid']])) {
             $item['lastvalue'] = $allowedItems[$item['itemid']]['lastvalue'];
             $item['lastclock'] = $allowedItems[$item['itemid']]['lastclock'];
             $hostKeyPairs[$item['host']][$item['key_']] = $item;
         }
     }
     // replace macros with their corresponding values in graph strings
     $matches = reset($matchesList);
     foreach ($strList as &$str) {
         // iterate array backwards!
         $i = count($matches['macros']);
         while ($i--) {
             $host = $matches['hosts'][$i][0];
             $key = $matches['keys'][$i][0];
             $function = $matches['functions'][$i][0];
             $parameter = $matches['parameters'][$i][0];
             // host is real and item exists and has permissions
             if ($host !== UNRESOLVED_MACRO_STRING && is_array($hostKeyPairs[$host][$key])) {
                 $item = $hostKeyPairs[$host][$key];
                 // macro function is "last"
                 if ($function == 'last') {
                     $value = $item['lastclock'] > 0 ? formatHistoryValue($item['lastvalue'], $item) : UNRESOLVED_MACRO_STRING;
                 } else {
                     $value = getItemFunctionalValue($item, $function, $parameter);
                 }
             } else {
                 $value = UNRESOLVED_MACRO_STRING;
             }
             $str = substr_replace($str, $value, $matches['macros'][$i][1], strlen($matches['macros'][$i][0]));
         }
         $matches = next($matchesList);
     }
     unset($str);
     return $strList;
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:93,代码来源:CMacrosResolver.php

示例5: resolveGraphsFunctionalItemMacros

 /**
  * Resolve functional macros, like {hostname:key.function(param)}.
  * If macro can not be resolved it is replaced with UNRESOLVED_MACRO_STRING string i.e. "*UNKNOWN*".
  *
  * Supports function "last", "min", "max" and "avg".
  * Supports seconds as parameters, except "last" function.
  * Second parameter like {hostname:key.last(0,86400) and offsets like {hostname:key.last(#1)} are not supported.
  * Supports postfixes s,m,h,d and w for parameter.
  *
  * @param array  $sourceStringList			list of strings from graphs in which macros should be resolved
  * @param array  $itemsList					list of lists of graph items used in graphs
  * @param int    $itemsList[n][m]['hostid']	n-th graph m-th item corresponding host ID
  * @param string $itemsList[n][m]['host']	n-th graph m-th item corresponding host name
  *
  * @return array	list of strings, possibly with macros in them replaced with resolved values
  */
 private function resolveGraphsFunctionalItemMacros(array $sourceStringList, array $itemsList)
 {
     $hostKeyPairs = [];
     $matchesList = [];
     $items = reset($itemsList);
     foreach ($sourceStringList as $sourceString) {
         /*
          * Extract all macros into $matches - keys: macros, hosts, keys, functions and parameters are used
          * searches for macros, for example, "{somehost:somekey["param[123]"].min(10m)}"
          */
         preg_match_all('/(?P<macros>{' . '(?P<hosts>(' . ZBX_PREG_HOST_FORMAT . '|({(' . self::PATTERN_HOST_INTERNAL . ')' . self::PATTERN_MACRO_PARAM . '}))):' . '(?P<keys>' . ZBX_PREG_ITEM_KEY_FORMAT . ')\\.' . '(?P<functions>(last|max|min|avg))\\(' . '(?P<parameters>([0-9]+[' . ZBX_TIME_SUFFIXES . ']?)?)' . '\\)}{1})/Uux', $sourceString, $matches, PREG_OFFSET_CAPTURE);
         foreach ($matches['hosts'] as $i => &$host) {
             $host[0] = $this->resolveGraphPositionalMacros($host[0], $items);
             if ($host[0] !== UNRESOLVED_MACRO_STRING) {
                 // Take note that resolved host has a such key (and it is used in a macro).
                 if (!isset($hostKeyPairs[$host[0]])) {
                     $hostKeyPairs[$host[0]] = [];
                 }
                 $hostKeyPairs[$host[0]][$matches['keys'][$i][0]] = true;
             }
         }
         unset($host);
         // Remember match for later use.
         $matchesList[] = $matches;
         $items = next($itemsList);
     }
     /*
      * If no host/key pairs found in macro-like parts of source string then there is nothing to do but return
      * source strings as they are.
      */
     if (!$hostKeyPairs) {
         return $sourceStringList;
     }
     // Build item retrieval query from host-key pairs and get all necessary items for all source strings.
     $queryParts = [];
     foreach ($hostKeyPairs as $host => $keys) {
         $queryParts[] = '(h.host=' . zbx_dbstr($host) . ' AND ' . dbConditionString('i.key_', array_keys($keys)) . ')';
     }
     $items = DBfetchArrayAssoc(DBselect('SELECT h.host,i.key_,i.itemid,i.value_type,i.units,i.valuemapid' . ' FROM items i,hosts h' . ' WHERE i.hostid=h.hostid' . ' AND (' . join(' OR ', $queryParts) . ')'), 'itemid');
     // Get items for which user has permission.
     $allowedItems = API::Item()->get(['itemids' => array_keys($items), 'webitems' => true, 'output' => ['itemid', 'value_type', 'lastvalue', 'lastclock'], 'preservekeys' => true]);
     // Get map item data only for those allowed items and set "value_type" for allowed items.
     foreach ($items as $item) {
         if (isset($allowedItems[$item['itemid']])) {
             $item['lastvalue'] = $allowedItems[$item['itemid']]['lastvalue'];
             $item['lastclock'] = $allowedItems[$item['itemid']]['lastclock'];
             $hostKeyPairs[$item['host']][$item['key_']] = $item;
         }
     }
     /*
      * Replace macros with their corresponding values in graph strings and replace macros with their resolved
      * values in source strings.
      */
     $matches = reset($matchesList);
     foreach ($sourceStringList as &$sourceString) {
         /*
          * We iterate array backwards so that replacing unresolved macro string (see lower) with actual value
          * does not mess up originally captured offsets.
          */
         $i = count($matches['macros']);
         while ($i--) {
             $host = $matches['hosts'][$i][0];
             $key = $matches['keys'][$i][0];
             $function = $matches['functions'][$i][0];
             $parameter = $matches['parameters'][$i][0];
             // If host is real and item exists and has permissions.
             if ($host !== UNRESOLVED_MACRO_STRING && is_array($hostKeyPairs[$host][$key])) {
                 $item = $hostKeyPairs[$host][$key];
                 // Macro function is "last".
                 if ($function == 'last') {
                     $value = $item['lastclock'] > 0 ? formatHistoryValue($item['lastvalue'], $item) : UNRESOLVED_MACRO_STRING;
                 } else {
                     $value = getItemFunctionalValue($item, $function, $parameter);
                 }
             } else {
                 $value = UNRESOLVED_MACRO_STRING;
             }
             /*
              * Replace macro string with actual, resolved string value. This is safe because we start from far
              * end of $sourceString.
              */
             $sourceString = substr_replace($sourceString, $value, $matches['macros'][$i][1], strlen($matches['macros'][$i][0]));
         }
         // Advance to next matches for next $sourceString.
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CMacrosResolver.php

示例6: delete

 /**
  * Delete proxy.
  *
  * @param string|array $proxyIds
  *
  * @return array
  */
 public function delete($proxyIds)
 {
     $proxyIds = zbx_toArray($proxyIds);
     // deprecated input support
     if ($proxyIds && is_array($proxyIds[0])) {
         $this->deprecated('Passing objects is deprecated, use an array of IDs instead.');
         foreach ($proxyIds as $proxyId) {
             if (!check_db_fields(array('proxyid' => null), $proxyId)) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No proxy ID given.'));
             }
         }
         $proxyIds = zbx_objectValues($proxyIds, 'proxyid');
     }
     $this->validateDelete($proxyIds);
     $dbProxies = DBselect('SELECT h.hostid,h.host' . ' FROM hosts h' . ' WHERE ' . dbConditionInt('h.hostid', $proxyIds));
     $dbProxies = DBfetchArrayAssoc($dbProxies, 'hostid');
     $actionIds = array();
     // get conditions
     $dbActions = DBselect('SELECT DISTINCT c.actionid' . ' FROM conditions c' . ' WHERE c.conditiontype=' . CONDITION_TYPE_PROXY . ' AND ' . dbConditionString('c.value', $proxyIds));
     while ($dbAction = DBfetch($dbActions)) {
         $actionIds[$dbAction['actionid']] = $dbAction['actionid'];
     }
     if ($actionIds) {
         DB::update('actions', array('values' => array('status' => ACTION_STATUS_DISABLED), 'where' => array('actionid' => $actionIds)));
     }
     // delete action conditions
     DB::delete('conditions', array('conditiontype' => CONDITION_TYPE_PROXY, 'value' => $proxyIds));
     // delete interface
     DB::delete('interface', array('hostid' => $proxyIds));
     // delete host
     DB::delete('hosts', array('hostid' => $proxyIds));
     // TODO: remove info from API
     foreach ($dbProxies as $proxy) {
         info(_s('Deleted: Proxy "%1$s".', $proxy['host']));
         add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_PROXY, '[' . $proxy['host'] . '] [' . $proxy['hostid'] . ']');
     }
     return array('proxyids' => $proxyIds);
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:45,代码来源:CProxy.php

示例7: update_slideshow


//.........这里部分代码省略.........
            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);
    if ($shared_userids_to_delete) {
        DB::delete('slideshow_user', ['slideshowuserid' => $shared_userids_to_delete]);
    }
    // User group shares.
    DB::insert('slideshow_usrgrp', $shared_user_groups_to_add);
    DB::update('slideshow_usrgrp', $shared_user_groups_to_update);
    if ($shared_user_groupids_to_delete) {
        DB::delete('slideshow_usrgrp', ['slideshowusrgrpid' => $shared_user_groupids_to_delete]);
    }
    // get slides
    $db_slides = DBfetchArrayAssoc(DBselect('SELECT s.* FROM slides s WHERE s.slideshowid=' . zbx_dbstr($data['slideshowid'])), 'slideid');
    $slidesToDel = zbx_objectValues($db_slides, 'slideid');
    $slidesToDel = zbx_toHash($slidesToDel);
    $step = 0;
    foreach ($data['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($data['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:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:screens.inc.php

示例8: get_request

            $severity[$i] = $i;
        }
    }
} else {
    $severity = get_request('severity', array(0, 1, 2, 3, 4, 5));
}
$media = get_request('media', -1);
$sendto = get_request('sendto', '');
$mediatypeid = get_request('mediatypeid', 0);
$active = get_request('active', 0);
$period = get_request('period', ZBX_DEFAULT_INTERVAL);
$frmMedia = new CFormTable(_('New media'));
$frmMedia->addVar('media', $media);
$frmMedia->addVar('dstfrm', $_REQUEST['dstfrm']);
$cmbType = new CComboBox('mediatypeid', $mediatypeid);
$types = DBfetchArrayAssoc(DBselect('SELECT mt.mediatypeid,mt.description' . ' FROM media_type mt' . whereDbNode('mt.mediatypeid')), 'mediatypeid');
CArrayHelper::sort($types, array('description'));
foreach ($types as $mediaTypeId => $type) {
    $cmbType->addItem($mediaTypeId, get_node_name_by_elid($type['mediatypeid'], null, NAME_DELIMITER) . $type['description']);
}
$frmMedia->addRow(_('Type'), $cmbType);
$frmMedia->addRow(_('Send to'), new CTextBox('sendto', $sendto, 48));
$frmMedia->addRow(_('When active'), new CTextBox('period', $period, 48));
$frm_row = array();
foreach (getSeverityCaption() as $i => $caption) {
    $frm_row[] = array(new CCheckBox('severity[' . $i . ']', str_in_array($i, $severity), null, $i), $caption);
    $frm_row[] = BR();
}
$frmMedia->addRow(_('Use if severity'), $frm_row);
$cmbStat = new CComboBox('active', $active);
$cmbStat->addItem(0, _('Enabled'));
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:31,代码来源:popup_media.php

示例9: applyPostSqlFiltering

 protected function applyPostSqlFiltering(array $triggers, array $options)
 {
     $triggers = zbx_toHash($triggers, 'triggerid');
     // skipDependent
     if (!is_null($options['skipDependent'])) {
         $triggerIds = zbx_objectValues($triggers, 'triggerid');
         $map = array();
         do {
             $dbResult = DBselect('SELECT d.triggerid_down,d.triggerid_up,t.value' . ' FROM trigger_depends d,triggers t' . ' WHERE ' . dbConditionInt('d.triggerid_down', $triggerIds) . ' AND d.triggerid_up=t.triggerid');
             $triggerIds = array();
             while ($row = DBfetch($dbResult)) {
                 if (TRIGGER_VALUE_TRUE == $row['value']) {
                     if (isset($map[$row['triggerid_down']])) {
                         foreach ($map[$row['triggerid_down']] as $triggerid => $state) {
                             unset($triggers[$triggerid]);
                         }
                     } else {
                         unset($triggers[$row['triggerid_down']]);
                     }
                 } else {
                     if (isset($map[$row['triggerid_down']])) {
                         if (!isset($map[$row['triggerid_up']])) {
                             $map[$row['triggerid_up']] = array();
                         }
                         $map[$row['triggerid_up']] += $map[$row['triggerid_down']];
                     } else {
                         if (!isset($map[$row['triggerid_up']])) {
                             $map[$row['triggerid_up']] = array();
                         }
                         $map[$row['triggerid_up']][$row['triggerid_down']] = 1;
                     }
                     $triggerIds[] = $row['triggerid_up'];
                 }
             }
         } while (!empty($triggerIds));
     }
     // withLastEventUnacknowledged
     if (!is_null($options['withLastEventUnacknowledged'])) {
         $triggerIds = zbx_objectValues($triggers, 'triggerid');
         $eventIds = array();
         $eventsDb = DBselect('SELECT MAX(e.eventid) AS eventid,e.objectid' . ' FROM events e' . ' WHERE e.object=' . EVENT_OBJECT_TRIGGER . ' AND e.source=' . EVENT_SOURCE_TRIGGERS . ' AND ' . dbConditionInt('e.objectid', $triggerIds) . ' AND ' . dbConditionInt('e.value', array(TRIGGER_VALUE_TRUE)) . ' GROUP BY e.objectid');
         while ($event = DBfetch($eventsDb)) {
             $eventIds[] = $event['eventid'];
         }
         $correctTriggerIds = DBfetchArrayAssoc(DBselect('SELECT e.objectid' . ' FROM events e ' . ' WHERE ' . dbConditionInt('e.eventid', $eventIds) . ' AND e.acknowledged=0'), 'objectid');
         foreach ($triggers as $triggerId => $trigger) {
             if (!isset($correctTriggerIds[$triggerId])) {
                 unset($triggers[$triggerId]);
             }
         }
     }
     return $triggers;
 }
开发者ID:itnihao,项目名称:Zabbix_,代码行数:53,代码来源:CTrigger.php

示例10: array

    // get items
    $data['hostPrototypes'] = API::HostPrototype()->get(array('discoveryids' => $data['parent_discoveryid'], 'output' => API_OUTPUT_EXTEND, 'selectTemplates' => array('templateid', 'name'), 'editable' => true, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1));
    order_result($data['hostPrototypes'], $sortField, $sortOrder);
    $data['paging'] = getPagingLine($data['hostPrototypes'], $sortOrder);
    // fetch templates linked to the prototypes
    $templateIds = array();
    foreach ($data['hostPrototypes'] as $hostPrototype) {
        $templateIds = array_merge($templateIds, zbx_objectValues($hostPrototype['templates'], 'templateid'));
    }
    $templateIds = array_unique($templateIds);
    $linkedTemplates = API::Template()->get(array('output' => array('templateid', 'name'), 'templateids' => $templateIds, 'selectParentTemplates' => array('hostid', 'name')));
    $data['linkedTemplates'] = zbx_toHash($linkedTemplates, 'templateid');
    // fetch source templates and LLD rules
    $hostPrototypeSourceIds = getHostPrototypeSourceParentIds(zbx_objectValues($data['hostPrototypes'], 'hostid'));
    if ($hostPrototypeSourceIds) {
        $hostPrototypeSourceTemplates = DBfetchArrayAssoc(DBSelect('SELECT h.hostid,h2.name,h2.hostid AS parent_hostid' . ' FROM hosts h,host_discovery hd,items i,hosts h2' . ' WHERE h.hostid=hd.hostid' . ' AND hd.parent_itemid=i.itemid' . ' AND i.hostid=h2.hostid' . ' AND ' . dbConditionInt('h.hostid', $hostPrototypeSourceIds)), 'hostid');
        foreach ($data['hostPrototypes'] as &$hostPrototype) {
            if ($hostPrototype['templateid']) {
                $sourceTemplate = $hostPrototypeSourceTemplates[$hostPrototypeSourceIds[$hostPrototype['hostid']]];
                $hostPrototype['sourceTemplate'] = array('hostid' => $sourceTemplate['parent_hostid'], 'name' => $sourceTemplate['name']);
                $sourceDiscoveryRuleId = get_realrule_by_itemid_and_hostid($discoveryRule['itemid'], $sourceTemplate['hostid']);
                $hostPrototype['sourceDiscoveryRuleId'] = $sourceDiscoveryRuleId;
            }
        }
        unset($hostPrototype);
    }
    // render view
    $itemView = new CView('configuration.host.prototype.list', $data);
    $itemView->render();
    $itemView->show();
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:31,代码来源:host_prototypes.php

示例11: updateStepsReal

 /**
  * Update web scenario steps.
  *
  * @param $httpTest
  * @param $websteps
  *
  * @throws Exception
  */
 protected function updateStepsReal($httpTest, $websteps)
 {
     // get all used keys
     $webstepids = zbx_objectValues($websteps, 'httpstepid');
     $dbKeys = DBfetchArrayAssoc(DBselect('SELECT i.key_' . ' FROM items i,httpstepitem hi' . ' WHERE ' . dbConditionInt('hi.httpstepid', $webstepids) . ' AND hi.itemid=i.itemid'), 'key_');
     foreach ($websteps as $webstep) {
         DB::update('httpstep', array('values' => $webstep, 'where' => array('httpstepid' => $webstep['httpstepid'])));
         // update item keys
         $itemids = array();
         $stepitemsUpdate = $updateFields = array();
         $dbStepItems = DBselect('SELECT i.itemid,i.key_,hi.type' . ' FROM items i,httpstepitem hi' . ' WHERE hi.httpstepid=' . zbx_dbstr($webstep['httpstepid']) . ' AND hi.itemid=i.itemid');
         while ($stepitem = DBfetch($dbStepItems)) {
             $itemids[] = $stepitem['itemid'];
             if (isset($httpTest['name']) || isset($webstep['name'])) {
                 if (!isset($httpTest['name']) || !isset($webstep['name'])) {
                     $key = new CItemKey($stepitem['key_']);
                     $params = $key->getParameters();
                     if (!isset($httpTest['name'])) {
                         $httpTest['name'] = $params[0];
                     }
                     if (!isset($webstep['name'])) {
                         $webstep['name'] = $params[1];
                     }
                 }
                 $updateFields['key_'] = $this->getStepKey($stepitem['type'], $httpTest['name'], $webstep['name']);
             }
             if (isset($dbKeys[$updateFields['key_']])) {
                 unset($updateFields['key_']);
             }
             if (isset($httpTest['status'])) {
                 $updateFields['status'] = HTTPTEST_STATUS_ACTIVE == $httpTest['status'] ? ITEM_STATUS_ACTIVE : ITEM_STATUS_DISABLED;
             }
             if (isset($httpTest['delay'])) {
                 $updateFields['delay'] = $httpTest['delay'];
             }
             if (!empty($updateFields)) {
                 $stepitemsUpdate[] = array('values' => $updateFields, 'where' => array('itemid' => $stepitem['itemid']));
             }
         }
         DB::update('items', $stepitemsUpdate);
         if (isset($httpTest['applicationid'])) {
             $this->updateItemsApplications($itemids, $httpTest['applicationid']);
         }
     }
 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:53,代码来源:CHttpTestManager.php

示例12: getRequest

            $severity[$i] = $i;
        }
    }
} else {
    $severity = getRequest('severity', array(0, 1, 2, 3, 4, 5));
}
$media = getRequest('media', -1);
$sendto = getRequest('sendto', '');
$mediatypeid = getRequest('mediatypeid', 0);
$active = getRequest('active', 0);
$period = getRequest('period', ZBX_DEFAULT_INTERVAL);
$frmMedia = new CFormTable(_('New media'));
$frmMedia->addVar('media', $media);
$frmMedia->addVar('dstfrm', $_REQUEST['dstfrm']);
$cmbType = new CComboBox('mediatypeid', $mediatypeid);
$types = DBfetchArrayAssoc(DBselect('SELECT mt.mediatypeid,mt.description FROM media_type mt'), 'mediatypeid');
CArrayHelper::sort($types, array('description'));
foreach ($types as $mediaTypeId => $type) {
    $cmbType->addItem($mediaTypeId, $type['description']);
}
$frmMedia->addRow(_('Type'), $cmbType);
$frmMedia->addRow(_('Send to'), new CTextBox('sendto', $sendto, 48));
$frmMedia->addRow(_('When active'), new CTextBox('period', $period, 48));
$frm_row = array();
foreach (getSeverityCaption() as $i => $caption) {
    $frm_row[] = array(new CCheckBox('severity[' . $i . ']', str_in_array($i, $severity), null, $i), $caption);
    $frm_row[] = BR();
}
$frmMedia->addRow(_('Use if severity'), $frm_row);
$cmbStat = new CComboBox('active', $active);
$cmbStat->addItem(0, _('Enabled'));
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:31,代码来源:popup_media.php

示例13: get_report2_filter

/**
 * Creates the availability report page filter and modifies trigger retrieval options.
 *
 * Possible $config values are AVAILABILITY_REPORT_BY_HOST or AVAILABILITY_REPORT_BY_TEMPLATE.
 *
 * @param int $config			report mode
 * @param array $PAGE_GROUPS	the data for the host/template group filter select
 * @param array $PAGE_HOSTS		the data for the host/template filter select
 * @param array $options		trigger retrieval options, to be modified
 *
 * @return array returns form table and modified options: array('form' => CFormTable, 'options' => array)
 */
function get_report2_filter($config, array $PAGE_GROUPS, array $PAGE_HOSTS, $options)
{
    $filterForm = new CFormTable();
    $filterForm->setAttribute('name', 'zbx_filter');
    $filterForm->setAttribute('id', 'zbx_filter');
    $filterForm->addVar('config', $config);
    $filterForm->addVar('filter_timesince', date('YmdHis', $_REQUEST['filter_timesince']));
    $filterForm->addVar('filter_timetill', date('YmdHis', $_REQUEST['filter_timetill']));
    $cmbGroups = new CComboBox('filter_groupid', $PAGE_GROUPS['selected'], 'javascript: submit();');
    $cmbHosts = new CComboBox('filter_hostid', $PAGE_HOSTS['selected'], 'javascript: submit();');
    foreach ($PAGE_GROUPS['groups'] as $groupid => $name) {
        $cmbGroups->addItem($groupid, get_node_name_by_elid($groupid, null, ': ') . $name);
    }
    foreach ($PAGE_HOSTS['hosts'] as $hostid => $name) {
        $cmbHosts->addItem($hostid, get_node_name_by_elid($hostid, null, ': ') . $name);
    }
    if ($config == AVAILABILITY_REPORT_BY_TEMPLATE) {
        $filterForm->addRow(_('Template group'), $cmbGroups);
        $filterForm->addRow(_('Template'), $cmbHosts);
        $cmbTrigs = new CComboBox('tpl_triggerid', get_request('tpl_triggerid', 0), 'submit()');
        $cmbHGrps = new CComboBox('hostgroupid', get_request('hostgroupid', 0), 'submit()');
        $cmbTrigs->addItem(0, _('all'));
        $cmbHGrps->addItem(0, _('all'));
        // fetch the groups, that the used hosts belong to
        $hostGroups = API::HostGroup()->get(array('output' => array('name', 'groupid'), 'hostids' => $options['hostids'], 'monitored_hosts' => true, 'preservekeys' => true));
        foreach ($hostGroups as $hostGroup) {
            $cmbHGrps->addItem($hostGroup['groupid'], get_node_name_by_elid($hostGroup['groupid'], null, ': ') . $hostGroup['name']);
        }
        if (isset($_REQUEST['hostgroupid']) && !isset($hostGroups[$_REQUEST['hostgroupid']])) {
            unset($options['groupids']);
        }
        if ($PAGE_HOSTS['selected']) {
            $sql_cond = ' AND h.hostid=' . $PAGE_HOSTS['selected'];
        } else {
            $sql_cond = ' AND ' . dbConditionInt('h.hostid', $PAGE_HOSTS['hostids']);
        }
        $sql = 'SELECT DISTINCT t.triggerid,t.description ' . ' FROM triggers t,hosts h,items i,functions f ' . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND t.triggerid=f.triggerid ' . ' AND h.status=' . HOST_STATUS_TEMPLATE . ' AND ' . DBin_node('t.triggerid') . ' AND i.status=' . ITEM_STATUS_ACTIVE . $sql_cond . ' ORDER BY t.description';
        $triggers = DBfetchArrayAssoc(DBselect($sql), 'triggerid');
        foreach ($triggers as $trigger) {
            $cmbTrigs->addItem($trigger['triggerid'], get_node_name_by_elid($trigger['triggerid'], null, ': ') . $trigger['description']);
        }
        if (isset($_REQUEST['tpl_triggerid']) && !isset($triggers[$_REQUEST['tpl_triggerid']])) {
            unset($options['filter']['templateid']);
        }
        $filterForm->addRow(_('Template trigger'), $cmbTrigs);
        $filterForm->addRow(_('Filter by host group'), $cmbHGrps);
    } elseif ($config == AVAILABILITY_REPORT_BY_HOST) {
        $filterForm->addRow(_('Host group'), $cmbGroups);
        $filterForm->addRow(_('Host'), $cmbHosts);
    }
    //*
    $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
    $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_since'].clndr.clndrshow(pos.top,pos.left);");
    $filtertimetab = new CTable(null, 'calendar');
    $filtertimetab->setAttribute('width', '10%');
    $filtertimetab->setCellPadding(0);
    $filtertimetab->setCellSpacing(0);
    $filtertimetab->addRow(array(_('From'), new CNumericBox('filter_since_day', $_REQUEST['filter_timesince'] > 0 ? date('d', $_REQUEST['filter_timesince']) : '', 2), '/', new CNumericBox('filter_since_month', $_REQUEST['filter_timesince'] > 0 ? date('m', $_REQUEST['filter_timesince']) : '', 2), '/', new CNumericBox('filter_since_year', $_REQUEST['filter_timesince'] > 0 ? date('Y', $_REQUEST['filter_timesince']) : '', 4), SPACE, new CNumericBox('filter_since_hour', $_REQUEST['filter_timesince'] > 0 ? date('H', $_REQUEST['filter_timesince']) : '', 2), ':', new CNumericBox('filter_since_minute', $_REQUEST['filter_timesince'] > 0 ? date('i', $_REQUEST['filter_timesince']) : '', 2), $clndr_icon));
    zbx_add_post_js('create_calendar(null,' . '["filter_since_day","filter_since_month","filter_since_year","filter_since_hour","filter_since_minute"],' . '"avail_report_since",' . '"filter_timesince");');
    $clndr_icon->AddAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_till'].clndr.clndrshow(pos.top,pos.left);");
    $filtertimetab->AddRow(array(_('Till'), new CNumericBox('filter_till_day', $_REQUEST['filter_timetill'] > 0 ? date('d', $_REQUEST['filter_timetill']) : '', 2), '/', new CNumericBox('filter_till_month', $_REQUEST['filter_timetill'] > 0 ? date('m', $_REQUEST['filter_timetill']) : '', 2), '/', new CNumericBox('filter_till_year', $_REQUEST['filter_timetill'] > 0 ? date('Y', $_REQUEST['filter_timetill']) : '', 4), SPACE, new CNumericBox('filter_till_hour', $_REQUEST['filter_timetill'] > 0 ? date('H', $_REQUEST['filter_timetill']) : '', 2), ':', new CNumericBox('filter_till_minute', $_REQUEST['filter_timetill'] > 0 ? date('i', $_REQUEST['filter_timetill']) : '', 2), $clndr_icon));
    zbx_add_post_js('create_calendar(null,' . '["filter_till_day","filter_till_month","filter_till_year","filter_till_hour","filter_till_minute"],' . '"avail_report_till",' . '"filter_timetill");');
    zbx_add_post_js('addListener($("filter_icon"),"click",CLNDR[\'avail_report_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_since\'].clndr));' . 'addListener($("filter_icon"),"click",CLNDR[\'avail_report_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_till\'].clndr));');
    $filterForm->addRow(_('Period'), $filtertimetab);
    //*/
    $filterForm->addItemToBottomRow(new CSubmit('filter_set', _('Filter')));
    $reset = new CButton("filter_rst", _('Reset'), 'javascript: var url = new Curl(location.href); url.setArgument("filter_rst",1); location.href = url.getUrl();');
    $filterForm->addItemToBottomRow($reset);
    return array('form' => $filterForm, 'options' => $options);
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:82,代码来源:reports.inc.php

示例14: massUpdate


//.........这里部分代码省略.........
     /*
      * Update template linkage
      */
     if (isset($updateTemplates)) {
         $hostTemplates = API::Template()->get(array('hostids' => $hostids, 'output' => array('templateid'), 'preservekeys' => true));
         $hostTemplateids = array_keys($hostTemplates);
         $newTemplateids = zbx_objectValues($updateTemplates, 'templateid');
         $templatesToDel = array_diff($hostTemplateids, $newTemplateids);
         $templatesToDel = array_diff($templatesToDel, $templateidsClear);
         if ($templatesToDel) {
             $result = $this->massRemove(array('hostids' => $hostids, 'templateids' => $templatesToDel));
             if (!$result) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot unlink template'));
             }
         }
         $result = $this->massAdd(array('hosts' => $hosts, 'templates' => $updateTemplates));
         if (!$result) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot link template'));
         }
     }
     // macros
     if (isset($updateMacros)) {
         DB::delete('hostmacro', array('hostid' => $hostids));
         $this->massAdd(array('hosts' => $hosts, 'macros' => $updateMacros));
     }
     /*
      * Inventory
      */
     if (isset($updateInventory)) {
         if ($updateInventory['inventory_mode'] == HOST_INVENTORY_DISABLED) {
             $sql = 'DELETE FROM host_inventory WHERE ' . dbConditionInt('hostid', $hostids);
             if (!DBexecute($sql)) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot delete inventory.'));
             }
         } else {
             $hostsWithInventories = array();
             $existingInventoriesDb = DBfetchArrayAssoc(DBselect('SELECT hostid' . ' FROM host_inventory' . ' WHERE ' . dbConditionInt('hostid', $hostids)), 'hostid');
             // check for hosts with disabled inventory mode
             if ($updateInventory['inventory_mode'] === null && count($existingInventoriesDb) !== count($hostids)) {
                 foreach ($hostids as $hostId) {
                     if (!isset($existingInventoriesDb[$hostId])) {
                         $host = get_host_by_hostid($hostId);
                         self::exception(ZBX_API_ERROR_PARAMETERS, _s('Inventory disabled for host "%s".', $host['host']));
                     }
                 }
             }
             foreach ($existingInventoriesDb as $existingInventory) {
                 $hostsWithInventories[] = $existingInventory['hostid'];
             }
             // when hosts are being updated to use automatic mode for host inventories,
             // we must check if some items are set to populate inventory fields of every host.
             // if they do, mass update for those fields should be ignored
             if ($updateInventory['inventory_mode'] == HOST_INVENTORY_AUTOMATIC) {
                 // getting all items on all affected hosts
                 $itemsToInventories = API::item()->get(array('output' => array('inventory_link', 'hostid'), 'filter' => array('hostid' => $hostids), 'nopermissions' => true));
                 // gathering links to array: 'hostid'=>array('inventory_name_1'=>true, 'inventory_name_2'=>true)
                 $inventoryLinksOnHosts = array();
                 $inventoryFields = getHostInventories();
                 foreach ($itemsToInventories as $hinv) {
                     if ($hinv['inventory_link'] != 0) {
                         // 0 means 'no link'
                         if (isset($inventoryLinksOnHosts[$hinv['hostid']])) {
                             $inventoryLinksOnHosts[$hinv['hostid']][$inventoryFields[$hinv['inventory_link']]['db_field']] = true;
                         } else {
                             $inventoryLinksOnHosts[$hinv['hostid']] = array($inventoryFields[$hinv['inventory_link']]['db_field'] => true);
                         }
                     }
                 }
                 // now we have all info we need to determine, which inventory fields should be saved
                 $inventoriesToSave = array();
                 foreach ($hostids as $hostid) {
                     $inventoriesToSave[$hostid] = $updateInventory;
                     $inventoriesToSave[$hostid]['hostid'] = $hostid;
                     foreach ($updateInventory as $inventoryName => $hinv) {
                         if (isset($inventoryLinksOnHosts[$hostid][$inventoryName])) {
                             unset($inventoriesToSave[$hostid][$inventoryName]);
                         }
                     }
                 }
             } else {
                 // if mode is not automatic, all fields can be saved
                 $inventoriesToSave = array();
                 foreach ($hostids as $hostid) {
                     $inventoriesToSave[$hostid] = $updateInventory;
                     $inventoriesToSave[$hostid]['hostid'] = $hostid;
                 }
             }
             $hostsWithoutInventory = array_diff($hostids, $hostsWithInventories);
             // hosts that have no inventory yet, need it to be inserted
             foreach ($hostsWithoutInventory as $hostid) {
                 DB::insert('host_inventory', array($inventoriesToSave[$hostid]), false);
             }
             // those hosts that already have an inventory, need it to be updated
             foreach ($hostsWithInventories as $hostid) {
                 DB::update('host_inventory', array('values' => $inventoriesToSave[$hostid], 'where' => array('hostid' => $hostid)));
             }
         }
     }
     return array('hostids' => $inputHostIds);
 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:101,代码来源:CHost.php

示例15: 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


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