コード例 #1
0
ファイル: class.cgraph.php プロジェクト: phedders/zabbix
    /**
     * Delete graph items
     *
     * @static
     * @param array $items
     * @return boolean
     */
    public static function deleteItems($item_list, $force = false)
    {
        $error = 'Unknown ZABBIX internal error';
        $result = true;
        $graphid = $item_list['graphid'];
        $items = $item_list['items'];
        if (!$force) {
            // check if graph is templated graph, then items cannot be deleted
            $graph = CGraph::getById(array('graphid' => $graphid));
            if ($graph['templateid'] != 0) {
                self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Cannot edit templated graph : ' . $graph['name']);
                return false;
            }
        }
        $chd_graphs = get_graphs_by_templateid($graphid);
        while ($chd_graph = DBfetch($chd_graphs)) {
            $item_list['graphid'] = $chd_graph['graphid'];
            $result = self::deleteItems($item_list, true);
            if (!$result) {
                return false;
            }
        }
        $sql = 'SELECT curr.itemid
				FROM graphs_items gi, items curr, items src
				WHERE gi.graphid=' . $graphid . ' AND gi.itemid=curr.itemid
					AND curr.key_=src.key_
					AND ' . DBcondition('src.itemid', $items);
        $db_items = DBselect($sql);
        $gitems = array();
        while ($curr_item = DBfetch($db_items)) {
            $gitems[$curr_item['itemid']] = $curr_item['itemid'];
        }
        $sql = 'DELETE
				FROM graphs_items
				WHERE graphid=' . $graphid . ' AND ' . DBcondition('itemid', $gitems);
        $result = DBselect($sql);
        return $result;
    }
コード例 #2
0
ファイル: class.czbxrpc.php プロジェクト: phedders/zabbix
 private static function graph($action, $params)
 {
     CGraph::$error = array();
     switch ($action) {
         case 'add':
             $result = CGraph::add($params);
             break;
         case 'get':
             $result = CGraph::get($params);
             break;
         case 'getById':
             $result = CGraph::getById($params);
             break;
         case 'getId':
             $result = CGraph::getId($params);
             break;
         case 'update':
             $result = CGraph::update($params);
             break;
         case 'addItems':
             $result = CGraph::addItems($params);
             break;
         case 'deleteItems':
             $result = CGraph::deleteItems($params);
             break;
         case 'delete':
             $result = CGraph::delete($params);
             break;
         default:
             self::$result = array('error' => ZBX_API_ERROR_NO_METHOD, 'data' => 'Method: "' . $action . '" doesn\'t exist.');
             return;
             //exit function
     }
     if ($result !== false) {
         self::$result = array('result' => $result);
     } else {
         self::$result = CGraph::$error;
     }
 }