class CControllerScriptList extends CController {
protected function init() {
$this->disableSIDValidation();
protected function checkInput() {
'sort' => 'in name,command',
'sortorder' => 'in '.ZBX_SORT_DOWN.','.ZBX_SORT_UP,
'filter_name' => 'string',
'filter_scope' => 'in '.implode(',', [-1, ZBX_SCRIPT_SCOPE_ACTION, ZBX_SCRIPT_SCOPE_HOST, ZBX_SCRIPT_SCOPE_EVENT])
$ret = $this->validateInput($fields);
$this->setResponse(new CControllerResponseFatal());
protected function checkPermissions() {
return $this->checkAccess(CRoleHelper::UI_ADMINISTRATION_SCRIPTS);
protected function doAction() {
$sortField = $this->getInput('sort', CProfile::get('web.scripts.php.sort', 'name'));
$sortOrder = $this->getInput('sortorder', CProfile::get('web.scripts.php.sortorder', ZBX_SORT_UP));
CProfile::update('web.scripts.php.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.scripts.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
if ($this->hasInput('filter_set')) {
CProfile::update('web.scripts.filter_name', $this->getInput('filter_name', ''), PROFILE_TYPE_STR);
CProfile::update('web.scripts.filter_scope', $this->getInput('filter_scope', -1), PROFILE_TYPE_INT);
elseif ($this->hasInput('filter_rst')) {
CProfile::delete('web.scripts.filter_name');
CProfile::delete('web.scripts.filter_scope');
'name' => CProfile::get('web.scripts.filter_name', ''),
'scope' => CProfile::get('web.scripts.filter_scope', -1)
'uncheck' => $this->hasInput('uncheck'),
'sortorder' => $sortOrder,
'profileIdx' => 'web.scripts.filter',
'active_tab' => CProfile::get('web.scripts.filter.active', 1)
$limit = CSettingsHelper::get(CSettingsHelper::SEARCH_LIMIT) + 1;
$data['scripts'] = API::Script()->get([
'output' => ['scriptid', 'name', 'command', 'host_access', 'usrgrpid', 'groupid', 'type', 'execute_on',
'name' => ($filter['name'] === '') ? null : $filter['name']