diff options
Diffstat (limited to 'ui/app/controllers/CControllerImageCreate.php')
-rw-r--r-- | ui/app/controllers/CControllerImageCreate.php | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/ui/app/controllers/CControllerImageCreate.php b/ui/app/controllers/CControllerImageCreate.php index 41a2533003c..2362a5d3340 100644 --- a/ui/app/controllers/CControllerImageCreate.php +++ b/ui/app/controllers/CControllerImageCreate.php @@ -23,8 +23,8 @@ class CControllerImageCreate extends CController { protected function checkInput() { $fields = [ - 'name' => 'required | not_empty | db images.name', - 'imagetype' => 'required | fatal | db images.imagetype' + 'name' => 'required|not_empty|db images.name', + 'imagetype' => 'required|fatal|db images.imagetype' ]; $ret = $this->validateInput($fields); @@ -56,12 +56,6 @@ class CControllerImageCreate extends CController { return false; } - $this->image = [ - 'imageid' => 0, - 'imagetype' => $this->getInput('imagetype'), - 'name' => $this->getInput('name', '') - ]; - return true; } @@ -109,23 +103,30 @@ class CControllerImageCreate extends CController { return $this->setResponse($response); } - $result = API::Image()->create([ + $options = [ 'imagetype' => $this->getInput('imagetype'), - 'name' => $this->getInput('name'), - 'image' => $image - ]); + 'name' => $this->getInput('name') + ]; + + if ($image != null) { + $options['image'] = $image; + } + + $result = API::Image()->create($options); if ($result) { - $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) - ->setArgument('action', 'image.list') - ->setArgument('imagetype', $this->getInput('imagetype')) + $response = new CControllerResponseRedirect( + (new CUrl('zabbix.php')) + ->setArgument('action', 'image.list') + ->setArgument('imagetype', $this->getInput('imagetype')) ); CMessageHelper::setSuccessTitle(_('Image added')); } else { - $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) - ->setArgument('action', 'image.edit') - ->setArgument('imagetype', $this->getInput('imagetype')) + $response = new CControllerResponseRedirect( + (new CUrl('zabbix.php')) + ->setArgument('action', 'image.edit') + ->setArgument('imagetype', $this->getInput('imagetype')) ); $response->setFormData($this->getInputAll()); CMessageHelper::setErrorTitle(_('Cannot add image')); |