fix software inputfilter

parent d1152c52
......@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "76a50cdfbc7976610314973fc6a6970c",
"content-hash": "392d1701bd480c4bd0e2e46da4adc693",
"hash": "57854ff2516737b353c5103c6c9748d4",
"content-hash": "f2bbb452cc9452c72a69af9712855e2d",
"packages": [
{
"name": "container-interop/container-interop",
......@@ -139,16 +139,16 @@
},
{
"name": "guzzlehttp/promises",
"version": "1.0.3",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea"
"reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea",
"reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea",
"url": "https://api.github.com/repos/guzzle/promises/zipball/bb9024c526b22f3fe6ae55a561fd70653d470aa8",
"reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8",
"shasum": ""
},
"require": {
......@@ -186,7 +186,7 @@
"keywords": [
"promise"
],
"time": "2015-10-15 22:28:00"
"time": "2016-03-08 01:15:46"
},
{
"name": "guzzlehttp/psr7",
......@@ -496,16 +496,16 @@
},
{
"name": "monolog/monolog",
"version": "1.18.0",
"version": "1.18.1",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "e19b764b5c855580e8ffa7e615f72c10fd2f99cc"
"reference": "a5f2734e8c16f3aa21b3da09715d10e15b4d2d45"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/e19b764b5c855580e8ffa7e615f72c10fd2f99cc",
"reference": "e19b764b5c855580e8ffa7e615f72c10fd2f99cc",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/a5f2734e8c16f3aa21b3da09715d10e15b4d2d45",
"reference": "a5f2734e8c16f3aa21b3da09715d10e15b4d2d45",
"shasum": ""
},
"require": {
......@@ -570,7 +570,7 @@
"logging",
"psr-3"
],
"time": "2016-03-01 18:00:40"
"time": "2016-03-13 16:08:35"
},
{
"name": "nikic/fast-route",
......@@ -617,16 +617,16 @@
},
{
"name": "paragonie/random_compat",
"version": "v1.2.1",
"version": "v1.2.2",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "f078eba3bcf140fd69b5fcc3ea5ac809abf729dc"
"reference": "b3313b618f4edd76523572531d5d7e22fe747430"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/f078eba3bcf140fd69b5fcc3ea5ac809abf729dc",
"reference": "f078eba3bcf140fd69b5fcc3ea5ac809abf729dc",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/b3313b618f4edd76523572531d5d7e22fe747430",
"reference": "b3313b618f4edd76523572531d5d7e22fe747430",
"shasum": ""
},
"require": {
......@@ -661,7 +661,7 @@
"pseudorandom",
"random"
],
"time": "2016-02-29 17:25:04"
"time": "2016-03-11 19:54:08"
},
{
"name": "pimple/pimple",
......@@ -893,16 +893,16 @@
},
{
"name": "slim/slim",
"version": "3.2.2",
"version": "3.3.0",
"source": {
"type": "git",
"url": "https://github.com/slimphp/Slim.git",
"reference": "1d99b8846c784d885201b2b709bfedb63656ed30"
"reference": "939f2e85d57508de9cff241d10091cd972f221c3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/1d99b8846c784d885201b2b709bfedb63656ed30",
"reference": "1d99b8846c784d885201b2b709bfedb63656ed30",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/939f2e85d57508de9cff241d10091cd972f221c3",
"reference": "939f2e85d57508de9cff241d10091cd972f221c3",
"shasum": ""
},
"require": {
......@@ -956,20 +956,20 @@
"micro",
"router"
],
"time": "2016-03-05 19:36:16"
"time": "2016-03-10 21:37:40"
},
{
"name": "slim/twig-view",
"version": "2.0",
"version": "2.1.1",
"source": {
"type": "git",
"url": "https://github.com/slimphp/Twig-View.git",
"reference": "fe98eab8daee498cc2821f1ad2ff7123bc327844"
"reference": "16fded26a44b8e8e0e041f1cff32afa21daeb284"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slimphp/Twig-View/zipball/fe98eab8daee498cc2821f1ad2ff7123bc327844",
"reference": "fe98eab8daee498cc2821f1ad2ff7123bc327844",
"url": "https://api.github.com/repos/slimphp/Twig-View/zipball/16fded26a44b8e8e0e041f1cff32afa21daeb284",
"reference": "16fded26a44b8e8e0e041f1cff32afa21daeb284",
"shasum": ""
},
"require": {
......@@ -997,7 +997,7 @@
"homepage": "http://joshlockhart.com"
}
],
"description": "Slim Framework view helper built on top of the Twig templating component",
"description": "Slim Framework 3 view helper built on top of the Twig templating component",
"homepage": "http://slimframework.com",
"keywords": [
"framework",
......@@ -1006,7 +1006,7 @@
"twig",
"view"
],
"time": "2015-08-17 08:45:48"
"time": "2016-03-13 20:58:41"
},
{
"name": "twig/twig",
......@@ -1181,6 +1181,50 @@
],
"time": "2016-02-03 23:46:30"
},
{
"name": "zendframework/zend-escaper",
"version": "2.5.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-escaper.git",
"reference": "a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73",
"reference": "a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73",
"shasum": ""
},
"require": {
"php": ">=5.3.23"
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev",
"dev-develop": "2.6-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\Escaper\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"homepage": "https://github.com/zendframework/zend-escaper",
"keywords": [
"escaper",
"zf2"
],
"time": "2015-06-03 14:05:37"
},
{
"name": "zendframework/zend-eventmanager",
"version": "3.0.1",
......@@ -1611,6 +1655,53 @@
],
"time": "2016-02-19 16:02:11"
},
{
"name": "zendframework/zend-uri",
"version": "2.5.2",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-uri.git",
"reference": "0bf717a239432b1a1675ae314f7c4acd742749ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-uri/zipball/0bf717a239432b1a1675ae314f7c4acd742749ed",
"reference": "0bf717a239432b1a1675ae314f7c4acd742749ed",
"shasum": ""
},
"require": {
"php": "^5.5 || ^7.0",
"zendframework/zend-escaper": "^2.5",
"zendframework/zend-validator": "^2.5"
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev",
"dev-develop": "2.6-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\Uri\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "a component that aids in manipulating and validating » Uniform Resource Identifiers (URIs)",
"homepage": "https://github.com/zendframework/zend-uri",
"keywords": [
"uri",
"zf2"
],
"time": "2016-02-17 22:38:51"
},
{
"name": "zendframework/zend-validator",
"version": "2.6.0",
......@@ -2193,16 +2284,16 @@
},
{
"name": "phpunit/phpunit",
"version": "4.8.23",
"version": "4.8.24",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "6e351261f9cd33daf205a131a1ba61c6d33bd483"
"reference": "a1066c562c52900a142a0e2bbf0582994671385e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6e351261f9cd33daf205a131a1ba61c6d33bd483",
"reference": "6e351261f9cd33daf205a131a1ba61c6d33bd483",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1066c562c52900a142a0e2bbf0582994671385e",
"reference": "a1066c562c52900a142a0e2bbf0582994671385e",
"shasum": ""
},
"require": {
......@@ -2261,7 +2352,7 @@
"testing",
"xunit"
],
"time": "2016-02-11 14:56:33"
"time": "2016-03-14 06:16:08"
},
{
"name": "phpunit/phpunit-mock-objects",
......@@ -3065,7 +3156,7 @@
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.1.0",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
......
......@@ -192,6 +192,12 @@ return function (Slim\App $app) {
);
};
$container[Middleware\InputFilterSoftware::class] = function ($c) {
return new Middleware\InputFilterSoftware(
$c->get(InputFilter\Software::class)
);
};
$container[Middleware\FetchSchoolFromIdentity::class] = function ($c) {
return new Middleware\FetchSchoolFromIdentity($c['authentication_service']);
};
......@@ -227,6 +233,10 @@ return function (Slim\App $app) {
);
};
$container[InputFilter\Software::class] = function ($c) {
return new InputFilter\Software();
};
});
$events('on', 'app.bootstrap', function ($app, $container) {
......@@ -255,7 +265,8 @@ return function (Slim\App $app) {
$this->delete('/assets', Action\Assets\DeleteAsset::class);
$this->get('/software', Action\Software\ListAll::class)->setName('school.software');
$this->post('/software', Action\Software\PersistSoftware::class);
$this->post('/software', Action\Software\PersistSoftware::class)
->add(Middleware\InputFilterSoftware::class);
$this->delete('/software', Action\Software\DeleteSoftware::class);
})->add(Middleware\FetchSchoolFromIdentity::class);
......
......@@ -141,7 +141,15 @@
that.model.add(response);
}
that.hide();
});
}).fail(function (xhr, err) {
var messages;
if (422 === xhr.status) {
messages = JSON.parse(xhr.responseText).messages || {};
utils.formMessages.render(that.form, messages);
} else {
alert('Προέκυψε κάποιο σφάλμα');
}
});;
},
removeSoftware: function () {
var that = this;
......
......@@ -38,11 +38,6 @@ class Software
->attach(new Validator\NotEmpty())
->attach(new Validator\StringLength(['min' => 3]));
$school_id = new Input('school_id');
$school_id->setRequired(true)
->getValidatorChain()
->attach(new Validator\Digits());
$lab_id = new Input('lab_id');
$lab_id->setRequired(false)
->getValidatorChain()
......@@ -58,13 +53,15 @@ class Software
$url = new Input('url');
$url->setRequired(false)
->getValidatorChain()
->attach(new Validator\Hostname());
->attach(new Validator\Uri([
'allowRelative' => false,
'allowAbsolute' => true,
]));
$this->inputFilter = new InputFilter();
$this->inputFilter
->add($id)
->add($softwarecategory_id)
->add($school_id)
->add($lab_id)
->add($title)
->add($vendor)
......
......@@ -118,7 +118,7 @@ class LabService implements LabServiceInterface
$responsible = sprintf("%s %s", $responsible->name, $responsible->surname);
}
$lab = $bean->export();
$lab = $bean->export();
$lab['attachment_file'] = basename($lab['attachment']);
return array_merge($lab, [
......
......@@ -66,8 +66,8 @@ class SoftwareService implements SoftwareServiceInterface
private function persistSoftware($software, array $data)
{
if (!$data['lab_id']) {
$data['lab_id'] = NULL;
if (!isset($data['lab_id']) || empty($data['lab_id'])) {
$data['lab_id'] = null;
}
$software->softwarecategory_id = $data['softwarecategory_id'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment