Commit e6ab5c20 authored by Aspasia Katsi's avatar Aspasia Katsi

Merge branch 'master' of gitlab.minedu.gov.gr:itminedu/gredu_labs

parents 73f9de65 d4eb5da9
<?php <?php
/** /**
* gredu_labs. * gredu_labs.
* *
* @link https://github.com/eellak/gredu_labs for the canonical source repository * @link https://github.com/eellak/gredu_labs for the canonical source repository
* *
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/) * @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
...@@ -20,6 +20,7 @@ return [ ...@@ -20,6 +20,7 @@ return [
'module/sch_sync/bootstrap.php', 'module/sch_sync/bootstrap.php',
'module/schools/bootstrap.php', 'module/schools/bootstrap.php',
'module/application_form/bootstrap.php', 'module/application_form/bootstrap.php',
'module/receive_equip/bootstrap.php',
'module/tpe_survey/bootstrap.php', 'module/tpe_survey/bootstrap.php',
'module/in_numbers/bootstrap.php', 'module/in_numbers/bootstrap.php',
'module/in_numbers_mm/bootstrap.php', 'module/in_numbers_mm/bootstrap.php',
......
...@@ -6,21 +6,20 @@ ...@@ -6,21 +6,20 @@
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/) * @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html * @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/ */
return [ return [
'acl' => [ 'acl' => [
'default_role' => 'guest', 'default_role' => 'guest',
'roles' => [ 'roles' => [
'guest' => [], 'guest' => [],
'user' => [], 'user' => [],
'school' => ['user'], 'school' => ['user'],
'admin' => ['user'], 'admin' => ['user'],
], ],
'resoures' => [], 'resoures' => [],
'guards' => [ 'guards' => [
'resources' => [], 'resources' => [],
'callables' => [], 'callables' => [],
'routes' => [ 'routes' => [
['/', ['guest', 'user'], ['get']], ['/', ['guest', 'user'], ['get']],
['/about', ['guest', 'user'], ['get']], ['/about', ['guest', 'user'], ['get']],
['/school', ['school'], ['get']], ['/school', ['school'], ['get']],
...@@ -32,6 +31,10 @@ return [ ...@@ -32,6 +31,10 @@ return [
['/application-form', ['school'], ['get', 'post']], ['/application-form', ['school'], ['get', 'post']],
['/application-form/submit-success', ['school'], ['get']], ['/application-form/submit-success', ['school'], ['get']],
['/application-form/report', ['school'], ['get']], ['/application-form/report', ['school'], ['get']],
['/receive-equip', ['school'], ['get', 'post'], GrEduLabs\ReceiveEquip\Acl\Assertion\CanSubmit::class],
['/receive-equip/submit-success', ['school'], ['get']],
['/receive-equip/report', ['school'], ['get']],
['/receive-equip/receive-doc/{fn}', ['school'], ['get']],
['/tpe_survey', ['school'], ['get', 'post']], ['/tpe_survey', ['school'], ['get', 'post']],
['/tpe_survey/total-teachers', ['school'], ['post']], ['/tpe_survey/total-teachers', ['school'], ['post']],
['/forum', ['guest', 'user'], ['get']], ['/forum', ['guest', 'user'], ['get']],
......
<?php <?php
/** /**
* gredu_labs. * gredu_labs.
* *
* @link https://github.com/eellak/gredu_labs for the canonical source repository * @link https://github.com/eellak/gredu_labs for the canonical source repository
* *
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/) * @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
...@@ -51,6 +51,10 @@ return [ ...@@ -51,6 +51,10 @@ return [
'label' => 'Αίτηση', 'label' => 'Αίτηση',
'route' => 'application_form', 'route' => 'application_form',
], ],
'receive-equip' => [
'label' => 'Παραλαβή εξοπλισμού',
'route' => 'receive_equip',
],
'open-data' => [ 'open-data' => [
'label' => 'Ανοικτά δεδομένα', 'label' => 'Ανοικτά δεδομένα',
'route' => 'open_data', 'route' => 'open_data',
......
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return [
'open_data' => [
'pagesize' => 20, // default page size
'maxpagesize' => 200, // maximum page size
],
];
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return [
'receive_equip' => [
'file_upload_path' => __DIR__ . '/../../data/uploads', // path to save file
'file_upload_max_size' => 3145728, // Maximum number of bytes allowed(default 3MB)
'file_upload_types_permitted' => ['jpg', 'jpeg', 'pdf', 'png'], // Array of allowed extensions
],
];
...@@ -22,12 +22,16 @@ CREATE TABLE `applicationform` ( ...@@ -22,12 +22,16 @@ CREATE TABLE `applicationform` (
`comments` text COLLATE utf8mb4_unicode_ci, `comments` text COLLATE utf8mb4_unicode_ci,
`submitted` int(11) unsigned NOT NULL, `submitted` int(11) unsigned NOT NULL,
`submitted_by` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `submitted_by` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`received_ts` timestamp NULL,
`received_by` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`received_document` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `index_foreignkey_applicationform_school` (`school_id`), KEY `index_foreignkey_applicationform_school` (`school_id`),
CONSTRAINT `c_fk_applicationform_school_id` FOREIGN KEY (`school_id`) REFERENCES `school` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE CONSTRAINT `c_fk_applicationform_school_id` FOREIGN KEY (`school_id`) REFERENCES `school` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
CREATE INDEX `index_applicationform_submitted` ON `applicationform`(`submitted`);
CREATE INDEX `index_applicationform_received_ts` ON `applicationform`(`received_ts`);
-- --
-- Dumping data for table `applicationform` -- Dumping data for table `applicationform`
-- --
...@@ -49,6 +53,7 @@ CREATE TABLE `applicationformitem` ( ...@@ -49,6 +53,7 @@ CREATE TABLE `applicationformitem` (
`itemcategory_id` int(11) unsigned NOT NULL, `itemcategory_id` int(11) unsigned NOT NULL,
`qty` int(11) unsigned NOT NULL, `qty` int(11) unsigned NOT NULL,
`qtyacquired` int(11) unsigned NOT NULL DEFAULT 0, `qtyacquired` int(11) unsigned NOT NULL DEFAULT 0,
`qtyreceived` int(11) unsigned DEFAULT 0,
`reasons` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `reasons` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`applicationform_id` int(11) unsigned NOT NULL, `applicationform_id` int(11) unsigned NOT NULL,
`lab_id` int(11) unsigned NOT NULL, `lab_id` int(11) unsigned NOT NULL,
...@@ -172,7 +177,7 @@ CREATE TABLE `itemcategory` ( ...@@ -172,7 +177,7 @@ CREATE TABLE `itemcategory` (
LOCK TABLES `itemcategory` WRITE; LOCK TABLES `itemcategory` WRITE;
/*!40000 ALTER TABLE `itemcategory` DISABLE KEYS */; /*!40000 ALTER TABLE `itemcategory` DISABLE KEYS */;
INSERT INTO `itemcategory` (`id`,`name`,`groupflag`,`sort`) VALUES INSERT INTO `itemcategory` (`id`,`name`,`groupflag`,`sort`) VALUES
(8,'ACCESS POINT',0,8), (8,'ACCESS POINT',0,8),
(26,'ΦΟΡΗΤΟΣ Η/Υ (LAPTOP)',0,26), (26,'ΦΟΡΗΤΟΣ Η/Υ (LAPTOP)',0,26),
(6,'MODEM / ROUTER ',0,6), (6,'MODEM / ROUTER ',0,6),
...@@ -196,7 +201,7 @@ INSERT INTO `itemcategory` (`id`,`name`,`groupflag`,`sort`) VALUES ...@@ -196,7 +201,7 @@ INSERT INTO `itemcategory` (`id`,`name`,`groupflag`,`sort`) VALUES
(43,'ΤΡΙΣΔΙΑΣΤΑΤΟΣ ΣΑΡΩΤΗΣ',0,43), (43,'ΤΡΙΣΔΙΑΣΤΑΤΟΣ ΣΑΡΩΤΗΣ',0,43),
(44,'ΣΕΤ ΡΟΜΠΟΤΙΚΗΣ - ΑΙΣΘΗΤΗΡΩΝ',0,44), (44,'ΣΕΤ ΡΟΜΠΟΤΙΚΗΣ - ΑΙΣΘΗΤΗΡΩΝ',0,44),
(45,'ΔΟΜΗΜΕΝΗ ΚΑΛΩΔΙΩΣΗ',0,45); (45,'ΔΟΜΗΜΕΝΗ ΚΑΛΩΔΙΩΣΗ',0,45);
INSERT INTO `itemcategory` (`id`,`name`,`groupflag`,`sort`) VALUES INSERT INTO `itemcategory` (`id`,`name`,`groupflag`,`sort`) VALUES
(101,'ΣΤΑΘΕΡΟΣ ΗΛΕΚΤΡΟΝΙΚΟΣ ΥΠΟΛΟΓΙΣΤΗΣ (DESKTOP)', 1,1), (101,'ΣΤΑΘΕΡΟΣ ΗΛΕΚΤΡΟΝΙΚΟΣ ΥΠΟΛΟΓΙΣΤΗΣ (DESKTOP)', 1,1),
(102,'ΦΟΡΗΤΟΣ ΗΛΕΚΤΡΟΝΙΚΟΣ ΥΠΟΛΟΓΙΣΤΗΣ (LAPTOP)', 1,2), (102,'ΦΟΡΗΤΟΣ ΗΛΕΚΤΡΟΝΙΚΟΣ ΥΠΟΛΟΓΙΣΤΗΣ (LAPTOP)', 1,2),
(103,'ΕΠΙΤΡΑΠΕΖΙΟΣ ΒΙΝΤΕΟΠΡΟΒΟΛΕΑΣ (SHORT THROW PROJECTOR)', 1,3), (103,'ΕΠΙΤΡΑΠΕΖΙΟΣ ΒΙΝΤΕΟΠΡΟΒΟΛΕΑΣ (SHORT THROW PROJECTOR)', 1,3),
...@@ -280,7 +285,7 @@ CREATE TABLE `lab_lesson` ( ...@@ -280,7 +285,7 @@ CREATE TABLE `lab_lesson` (
UNIQUE KEY `UQ_82ac3a020f1d21984f224331fbd99880f89b2e71` (`lab_id`,`lesson_id`), UNIQUE KEY `UQ_82ac3a020f1d21984f224331fbd99880f89b2e71` (`lab_id`,`lesson_id`),
KEY `index_foreignkey_lab_lesson_lesson` (`lesson_id`), KEY `index_foreignkey_lab_lesson_lesson` (`lesson_id`),
KEY `index_foreignkey_lab_lesson_lab` (`lab_id`), KEY `index_foreignkey_lab_lesson_lab` (`lab_id`),
CONSTRAINT `c_fk_lab_lesson_lesson_id` FOREIGN KEY (`lesson_id`) REFERENCES `lesson` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `c_fk_lab_lesson_lesson_id` FOREIGN KEY (`lesson_id`) REFERENCES `lesson` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `c_fk_lab_lesson_lab_id` FOREIGN KEY (`lab_id`) REFERENCES `lab` (`id`) ON DELETE CASCADE ON UPDATE CASCADE CONSTRAINT `c_fk_lab_lesson_lab_id` FOREIGN KEY (`lab_id`) REFERENCES `lab` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
......
ALTER TABLE `applicationformitem`
DROP COLUMN `qtyreceived` ;
ALTER TABLE `applicationform`
DROP COLUMN `received_ts` ;
ALTER TABLE `applicationform`
DROP COLUMN `received_by` ;
ALTER TABLE applicationform DROP INDEX `index_applicationform_submitted`;
ALTER TABLE `applicationformitem`
ADD COLUMN `qtyreceived` int(11) unsigned NOT NULL DEFAULT 0
AFTER `qtyacquired` ;
ALTER TABLE `applicationform`
ADD COLUMN `received_ts` timestamp NULL
AFTER `submitted_by` ;
ALTER TABLE `applicationform`
ADD COLUMN `received_by` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL
AFTER `received_ts` ;
CREATE INDEX `index_applicationform_submitted` ON `applicationform`(`submitted`);
CREATE INDEX `index_applicationform_received_ts` ON `applicationform`(`received_ts`);
ALTER TABLE `applicationform`
DROP COLUMN `received_document` ;
ALTER TABLE `applicationform`
ADD COLUMN `received_document` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''
AFTER `received_by` ;
...@@ -22,11 +22,16 @@ CREATE TABLE `applicationform` ( ...@@ -22,11 +22,16 @@ CREATE TABLE `applicationform` (
`comments` text COLLATE utf8mb4_unicode_ci, `comments` text COLLATE utf8mb4_unicode_ci,
`submitted` int(11) unsigned NOT NULL, `submitted` int(11) unsigned NOT NULL,
`submitted_by` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `submitted_by` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`received_ts` timestamp NULL,
`received_by` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`received_document` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `index_foreignkey_applicationform_school` (`school_id`), KEY `index_foreignkey_applicationform_school` (`school_id`),
CONSTRAINT `c_fk_applicationform_school_id` FOREIGN KEY (`school_id`) REFERENCES `school` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE CONSTRAINT `c_fk_applicationform_school_id` FOREIGN KEY (`school_id`) REFERENCES `school` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
CREATE INDEX `index_applicationform_submitted` ON `applicationform`(`submitted`);
CREATE INDEX `index_applicationform_received_ts` ON `applicationform`(`received_ts`);
-- --
-- Dumping data for table `applicationform` -- Dumping data for table `applicationform`
...@@ -49,6 +54,7 @@ CREATE TABLE `applicationformitem` ( ...@@ -49,6 +54,7 @@ CREATE TABLE `applicationformitem` (
`itemcategory_id` int(11) unsigned NOT NULL, `itemcategory_id` int(11) unsigned NOT NULL,
`qty` int(11) unsigned NOT NULL, `qty` int(11) unsigned NOT NULL,
`qtyacquired` int(11) unsigned DEFAULT 0, `qtyacquired` int(11) unsigned DEFAULT 0,
`qtyreceived` int(11) unsigned DEFAULT 0,
`reasons` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `reasons` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`applicationform_id` int(11) unsigned NOT NULL, `applicationform_id` int(11) unsigned NOT NULL,
`lab_id` int(11) unsigned NOT NULL, `lab_id` int(11) unsigned NOT NULL,
...@@ -61,7 +67,6 @@ CREATE TABLE `applicationformitem` ( ...@@ -61,7 +67,6 @@ CREATE TABLE `applicationformitem` (
CONSTRAINT `c_fk_applicationformitem_lab_id` FOREIGN KEY (`lab_id`) REFERENCES `lab` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE CONSTRAINT `c_fk_applicationformitem_lab_id` FOREIGN KEY (`lab_id`) REFERENCES `lab` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- Dumping data for table `applicationformitem` -- Dumping data for table `applicationformitem`
-- --
...@@ -78,4 +83,4 @@ UNLOCK TABLES; ...@@ -78,4 +83,4 @@ UNLOCK TABLES;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
\ No newline at end of file
<?php <?php
/** /**
* gredu_labs. * gredu_labs.
* *
* @link https://github.com/eellak/gredu_labs for the canonical source repository * @link https://github.com/eellak/gredu_labs for the canonical source repository
* *
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/) * @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
...@@ -42,7 +42,7 @@ class Login ...@@ -42,7 +42,7 @@ class Login
/** /**
* *
* @param Twig $view * @param Twig $view
* @param AuthenticationService $authService * @param AuthenticationService $authService
* @param Messages $flash * @param Messages $flash
......
This diff is collapsed.
This diff is collapsed.
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\OpenData\Action;
/**
* @inheritdoc
*/
class AllSchools extends PagedApiAction
{
}
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\OpenData\Action;
use Slim\Container;
use Slim\Http\Request;
use Slim\Http\Response;
use GrEduLabs\OpenData\Service\DataProviderInterface;
use GrEduLabs\OpenData\Service\RedBeanQueryPagedDataProvider;
/**
* Base class implementaing the api action.
* A dataprovider object is used to retrieve data.
*
* @see GrEduLabs\OpenData\Service\DataProviderInterface
*/
class ApiAction
{
/**
* @var GrEduLabs\OpenData\Service\DataProviderInterface
*/
protected $dataProvider;
/**
* @var Slim\Container
*/
protected $container;
/**
* @var boolean Respond with a 404 instead of 200 if data from dataprovider is an empty array.
*/
protected $empty_data_404;
public function __construct(Container $container, DataProviderInterface $dataProvider, $empty_data_404 = false)
{
$this->container = $container;
$this->dataProvider = $dataProvider;
$this->empty_data_404 = $empty_data_404;
}
public function setEmptyData404()
{
$this->empty_data_404 = true;
}
public function setEmptyData200()
{
$this->empty_data_404 = false;
}
public function __invoke(Request $req, Response $res, array $args = [])
{
/**
* Get data from dataprovider.
* If data is null, respond with a 500 status.
* If data is empty, respond with a 404 when $empty_data_404 is true.
* In any other case respond with a 200 status.
*
* @see GrEduLabs\OpenData\Service\DataProviderInterface
*/
$data = $this->dataProvider->getData();
$status = 200;
if ($data === null) {
$status = 500;
$data = ['message' => 'An error occured while retrieving data'];
} elseif (!is_array($data)) {
$status = 500;
$data = ['message' => 'Unexpected data: ' . var_export($data, true)];
} elseif (count($data) === 0) {
$status = (($this->empty_data_404 === true) ? 404 : 200);
}
return $this->respond($res, 'JSON', $this->prepareResponseData($status, $data), $status);
}
/**
*
* @param int $status HTTP status code
* @param type $data the real data to wrap in response
* @return array An array with predetermined keys:
* - status HTTP status code
* - success boolean
* - data The actual data
* - labels Data labels
* - count Data count in resultset
* - countall Data count without paging
* - page Data current page
* - pages Data number of pages available
*/
protected function prepareResponseData($status, $data = null)
{
$is_success = ($status == 200);
$has_data = $is_success && isset($data);
$has_paging = $this->dataProvider instanceof RedBeanQueryPagedDataProvider && $has_data;
$response_data = [
'status' => $status,
'success' => $is_success,
'count' => ($has_data ? $this->dataProvider->getCount() : null),
'countall' => ($has_paging ? $this->dataProvider->getCountAll() : null),
'page' => ($has_paging ? $this->dataProvider->getPage() : null),
'pages' => ($has_paging ? $this->dataProvider->getPages() : null),
'labels' => ($has_data ? $this->dataProvider->getLabels() : null),
'data' => $data,
];
return $response_data;
}
/**
* Send the final response. Only Json format is currently supported.
*
* @param string $outputFormat i.e. JSON
* @param array $response_data typically an array to send ot data to the client
* @param int $status HTTP status code
* @return mixed response object
*/
protected function respond(Response $res, $outputFormat, array $response_data, $status)
{
switch ($outputFormat) {
case 'JSON':
default:
return $res->withJson($response_data, $status, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
}
}
}
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\OpenData\Action;
use Slim\Container;
use Slim\Http\Request;
use Slim\Http\Response;
use GrEduLabs\OpenData\Service\DataProviderInterface;
use GrEduLabs\OpenData\InputFilter\EduadminNameInputFilter;
use GrEduLabs\OpenData\InputFilter\RegioneduadminNameInputFilter;
/**
* @inheritdoc
*/
class EduadminFilteredPagedApiAction extends PagedApiAction
{
/**
* @var InputFilter for eduadmin name
*/
private $_eduadminInputFilter;
/**
* @var InputFilter for region eduadmin name
*/
private $_regioneduadminInputFilter;
public function __construct(Container $container, DataProviderInterface $dataProvider, $empty_data_404 = false)
{
parent::__construct($container, $dataProvider, $empty_data_404);
$this->_eduadminInputFilter = new EduadminNameInputFilter();
$this->_regioneduadminInputFilter = new RegioneduadminNameInputFilter();
}
public function __invoke(Request $req, Response $res, array $args = [])
{
$this->_eduadminInputFilter->setData([
'name' => (isset($args['eduadmin']) ? $args['eduadmin'] : null)
]);
$this->_regioneduadminInputFilter->setData([
'name' => (isset($args['regioneduadmin']) ? $args['regioneduadmin'] : null)
]);
if ($this->_eduadminInputFilter->isValid() &&
$this->_regioneduadminInputFilter->isValid()) {
$this->dataProvider->queryFilter('eduadmin.name', $this->_eduadminInputFilter->getValue('name'), 'LIKE');
$this->dataProvider->queryFilter('regioneduadmin.name', $this->_regioneduadminInputFilter->getValue('name'), 'LIKE');
return parent::__invoke($req, $res, $args);
} else {
$messages = array_merge($this->_eduadminInputFilter->getMessages(), $this->_regioneduadminInputFilter->getMessages());
$responseData = $this->prepareResponseData(400, [
'errors' => array_reduce(array_keys($messages), function ($m, $k) use ($messages) {
$m[$k] = array_values($messages[$k]);
return $m;
}, [])
]);
return $this->respond($res, 'JSON', $responseData, 400);
}
}
}
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\OpenData\Action;
//use Slim\Container;
//use Slim\Http\Request;
//use Slim\Http\Response;
//use GrEduLabs\OpenData\Service\DataProviderInterface;
/**
* @inheritdoc
*/
class Index extends ApiAction
{
}
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\OpenData\Action;
use Slim\Container;
use Slim\Http\Request;
use Slim\Http\Response;
use GrEduLabs\OpenData\Service\DataProviderInterface;
use GrEduLabs\OpenData\InputFilter\GroupFlagInputFilter;
/**
* @inheritdoc
*/
class ItemCategoryNames extends ApiAction
{
/**
* @var InputFilter
*/
private $inputFilter;
public function __construct(Container $container, DataProviderInterface $dataProvider, $empty_data_404 = false)
{
parent::__construct($container, $dataProvider, $empty_data_404);
$this->inputFilter = new GroupFlagInputFilter();
}
public function __invoke(Request $req, Response $res, array $args = [])
{
$this->inputFilter->setData([
'group' => $req->getParam('group', null),
]);
if ($this->inputFilter->isValid()) {
$this->dataProvider->filterGroupflag($this->inputFilter->getValue('group'));
return parent::__invoke($req, $res, $args);
} else {
$messages = $this->inputFilter->getMessages();
$responseData = $this->prepareResponseData(400, [
'errors' => array_reduce(array_keys($messages), function ($m, $k) use ($messages) {
$m[$k] = array_values($messages[$k]);
return $m;
}, [])
]);
return $this->respond($res, 'JSON', $responseData, 400);
}
}
}
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\OpenData\Action;
use Slim\Container;
use Slim\Http\Request;
use Slim\Http\Response;
use GrEduLabs\OpenData\Service\DataProviderInterface;
use GrEduLabs\OpenData\Action\EduadminFilteredPagedApiAction;