protected function doAction() { $script = []; $this->getInputs($script, ['scriptid', 'name', 'type', 'execute_on', 'command', 'description', 'usrgrpid', 'groupid', 'host_access']); $script['confirmation'] = $this->getInput('confirmation', ''); if ($this->getInput('type', ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) == ZBX_SCRIPT_TYPE_IPMI && $this->hasInput('commandipmi')) { $script['command'] = $this->getInput('commandipmi'); } if ($this->getInput('hgstype', 1) == 0) { $script['groupid'] = 0; } DBstart(); $result = API::Script()->update($script); if ($result) { $scriptId = reset($result['scriptids']); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCRIPT, 'Name [' . $this->getInput('name', '') . '] id [' . $scriptId . ']'); } $result = DBend($result); if ($result) { $response = new CControllerResponseRedirect('zabbix.php?action=script.list&uncheck=1'); $response->setMessageOk(_('Script updated')); } else { $response = new CControllerResponseRedirect('zabbix.php?action=script.edit&scriptid=' . $this->getInput('scriptid')); $response->setFormData($this->getInputAll()); $response->setMessageError(_('Cannot update script')); } $this->setResponse($response); }
protected function doAction() { $proxy = []; $this->getInputs($proxy, ['host', 'status', 'description', 'tls_connect', 'tls_accept', 'tls_issuer', 'tls_subject', 'tls_psk_identity', 'tls_psk']); if ($this->getInput('status', HOST_STATUS_PROXY_ACTIVE) == HOST_STATUS_PROXY_PASSIVE) { $proxy['interface'] = []; $this->getInputs($proxy['interface'], ['dns', 'ip', 'useip', 'port']); } DBstart(); if ($this->hasInput('proxy_hostids')) { // skip discovered hosts $proxy['hosts'] = API::Host()->get(['output' => ['hostid'], 'hostids' => $this->getInput('proxy_hostids'), 'filter' => ['flags' => ZBX_FLAG_DISCOVERY_NORMAL]]); } $result = API::Proxy()->create([$proxy]); if ($result) { add_audit(AUDIT_ACTION_ADD, AUDIT_RESOURCE_PROXY, '[' . $this->getInput('host', '') . '] [' . reset($result['proxyids']) . ']'); } $result = DBend($result); if ($result) { $response = new CControllerResponseRedirect('zabbix.php?action=proxy.list&uncheck=1'); $response->setMessageOk(_('Proxy added')); } else { $response = new CControllerResponseRedirect('zabbix.php?action=proxy.edit'); $response->setFormData($this->getInputAll()); $response->setMessageError(_('Cannot add proxy')); } $this->setResponse($response); }
protected function doAction() { $eventids = $this->getInput('eventids'); $acknowledge_type = $this->getInput('acknowledge_type'); $result = true; if ($acknowledge_type == ZBX_ACKNOWLEDGE_PROBLEM || $acknowledge_type == ZBX_ACKNOWLEDGE_ALL) { $events = API::Event()->get(['output' => ['objectid'], 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'eventids' => $eventids]); $triggerids = zbx_objectValues($events, 'objectid'); $filter = ['acknowledged' => EVENT_NOT_ACKNOWLEDGED]; if ($acknowledge_type == ZBX_ACKNOWLEDGE_PROBLEM) { $filter['value'] = TRIGGER_VALUE_TRUE; } while ($result) { $events = API::Event()->get(['output' => [], 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'objectids' => $triggerids, 'filter' => $filter, 'preservekeys' => true, 'limit' => ZBX_DB_MAX_INSERTS]); if ($events) { foreach ($eventids as $i => $eventid) { if (array_key_exists($eventid, $events)) { unset($eventids[$i]); } } $result = API::Event()->acknowledge(['eventids' => array_keys($events), 'message' => $this->getInput('message', '')]); } else { break; } } } if ($result && $eventids) { $result = API::Event()->acknowledge(['eventids' => $eventids, 'message' => $this->getInput('message', '')]); } if ($result) { $response = new CControllerResponseRedirect($this->getInput('backurl', 'tr_status.php')); $response->setMessageOk(_n('Event acknowledged', 'Events acknowledged', count($eventids))); } else { $response = new CControllerResponseRedirect('zabbix.php?action=acknowledge.edit'); $response->setFormData($this->getInputAll()); $response->setMessageError(_n('Cannot acknowledge event', 'Cannot acknowledge events', count($eventids))); } $this->setResponse($response); }
protected function doAction() { $mediatype = []; $this->getInputs($mediatype, ['type', 'description', 'status']); switch ($mediatype['type']) { case MEDIA_TYPE_EMAIL: $this->getInputs($mediatype, ['smtp_server', 'smtp_port', 'smtp_helo', 'smtp_email', 'smtp_security', 'smtp_verify_peer', 'smtp_verify_host', 'smtp_authentication', 'passwd']); if ($this->hasInput('smtp_username')) { $mediatype['username'] = $this->getInput('smtp_username'); } break; case MEDIA_TYPE_EXEC: $this->getInputs($mediatype, ['exec_path']); $mediatype['exec_params'] = ''; if ($this->hasInput('exec_params')) { $exec_params = zbx_objectValues($this->getInput('exec_params'), 'exec_param'); foreach ($exec_params as $exec_param) { $mediatype['exec_params'] .= $exec_param . "\n"; } } break; case MEDIA_TYPE_SMS: $this->getInputs($mediatype, ['gsm_modem']); break; case MEDIA_TYPE_JABBER: $this->getInputs($mediatype, ['passwd']); if ($this->hasInput('jabber_username')) { $mediatype['username'] = $this->getInput('jabber_username'); } break; case MEDIA_TYPE_EZ_TEXTING: $this->getInputs($mediatype, ['passwd']); if ($this->hasInput('eztext_username')) { $mediatype['username'] = $this->getInput('eztext_username'); } if ($this->hasInput('eztext_limit')) { $mediatype['exec_path'] = $this->getInput('eztext_limit'); } break; } DBstart(); $result = API::Mediatype()->create($mediatype); if ($result) { add_audit(AUDIT_ACTION_ADD, AUDIT_RESOURCE_MEDIA_TYPE, 'Media type [' . $mediatype['description'] . ']'); } $result = DBend($result); if ($result) { $response = new CControllerResponseRedirect('zabbix.php?action=mediatype.list&uncheck=1'); $response->setMessageOk(_('Media type added')); } else { $response = new CControllerResponseRedirect('zabbix.php?action=mediatype.edit'); $response->setFormData($this->getInputAll()); $response->setMessageError(_('Cannot add media type')); } $this->setResponse($response); }