Source
xxxxxxxxxx
$api_input_rules = ['type' => API_OBJECTS, 'flags' => API_NOT_EMPTY | API_NORMALIZE, 'uniq' => [['imageid'], ['name']], 'fields' => [
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* Class containing methods for operations with images.
*/
class CImage extends CApiService {
public const ACCESS_RULES = [
'get' => ['min_user_type' => USER_TYPE_ZABBIX_USER],
'create' => ['min_user_type' => USER_TYPE_SUPER_ADMIN],
'update' => ['min_user_type' => USER_TYPE_SUPER_ADMIN],
'delete' => ['min_user_type' => USER_TYPE_SUPER_ADMIN]
];
protected $tableName = 'images';
protected $tableAlias = 'i';
protected $sortColumns = ['imageid', 'name'];
/**
* Get images data
*
* @param array $options
* @param array $options['imageids']
* @param array $options['sysmapids']
* @param array $options['filter']
* @param array $options['search']
* @param bool $options['searchByAny']
* @param bool $options['startSearch']
* @param bool $options['excludeSearch']
* @param bool $options['searchWildcardsEnabled']
* @param array $options['output']
* @param int $options['select_image']
* @param bool $options['editable']
* @param bool $options['countOutput']
* @param bool $options['preservekeys']
* @param string $options['sortfield']
* @param string $options['sortorder']
* @param int $options['limit']
*
* @return array|boolean image data as array or false if error
*/
public function get($options = []) {
$result = [];
$sqlParts = [
'select' => ['images' => 'i.imageid'],
'from' => ['images' => 'images i'],
'where' => [],
'order' => [],
'limit' => null
];
$defOptions = [
'imageids' => null,
'sysmapids' => null,
// filter
'filter' => null,
'search' => null,
'searchByAny' => null,
'startSearch' => false,
'excludeSearch' => false,
'searchWildcardsEnabled' => null,
// output
'output' => API_OUTPUT_EXTEND,
'select_image' => null,
'editable' => false,
'countOutput' => false,
'preservekeys' => false,
'sortfield' => '',
'sortorder' => '',
'limit' => null
];
$options = zbx_array_merge($defOptions, $options);
// editable + PERMISSION CHECK
if ($options['editable'] && self::$userData['type'] < USER_TYPE_ZABBIX_ADMIN) {
return [];