2018-09-24 13:53:18 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Grocy\Controllers;
|
|
|
|
|
|
|
|
class SystemApiController extends BaseApiController
|
|
|
|
{
|
2020-04-13 10:35:20 +02:00
|
|
|
public function GetConfig(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$constants = get_defined_constants();
|
|
|
|
|
|
|
|
// Some GROCY_* constants are not really config settings and therefore should not be exposed
|
|
|
|
unset($constants['GROCY_AUTHENTICATED']);
|
|
|
|
unset($constants['GROCY_DATAPATH']);
|
|
|
|
unset($constants['GROCY_IS_EMBEDDED_INSTALL']);
|
|
|
|
unset($constants['GROCY_USER_ID']);
|
|
|
|
|
2020-08-31 20:40:31 +02:00
|
|
|
$returnArray = [];
|
|
|
|
|
2020-04-13 10:35:20 +02:00
|
|
|
foreach ($constants as $constant => $value)
|
|
|
|
{
|
|
|
|
if (substr($constant, 0, 6) === 'GROCY_')
|
|
|
|
{
|
|
|
|
$returnArray[substr($constant, 6)] = $value;
|
|
|
|
}
|
2020-08-31 20:40:31 +02:00
|
|
|
|
2020-04-13 10:35:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->ApiResponse($response, $returnArray);
|
|
|
|
}
|
|
|
|
catch (\Exception $ex)
|
|
|
|
{
|
|
|
|
return $this->GenericErrorResponse($response, $ex->getMessage());
|
|
|
|
}
|
2020-08-31 20:40:31 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function GetDbChangedTime(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
|
|
|
{
|
|
|
|
return $this->ApiResponse($response, [
|
|
|
|
'changed_time' => $this->getDatabaseService()->GetDbChangedTime()
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function GetSystemInfo(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
|
|
|
{
|
|
|
|
return $this->ApiResponse($response, $this->getApplicationService()->GetSystemInfo());
|
2020-04-13 10:35:20 +02:00
|
|
|
}
|
|
|
|
|
2020-02-11 17:42:03 +01:00
|
|
|
public function LogMissingLocalization(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
2018-09-30 13:02:07 +02:00
|
|
|
{
|
|
|
|
if (GROCY_MODE === 'dev')
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$requestBody = $request->getParsedBody();
|
|
|
|
|
2020-03-01 23:47:47 +07:00
|
|
|
$this->getLocalizationService()->CheckAndAddMissingTranslationToPot($requestBody['text']);
|
2019-01-19 14:51:51 +01:00
|
|
|
return $this->EmptyApiResponse($response);
|
2018-09-30 13:02:07 +02:00
|
|
|
}
|
|
|
|
catch (\Exception $ex)
|
|
|
|
{
|
2019-01-19 14:51:51 +01:00
|
|
|
return $this->GenericErrorResponse($response, $ex->getMessage());
|
2018-09-30 13:02:07 +02:00
|
|
|
}
|
2020-08-31 20:40:31 +02:00
|
|
|
|
2020-03-01 23:47:47 +07:00
|
|
|
}
|
2020-08-31 20:40:31 +02:00
|
|
|
|
2018-09-30 13:02:07 +02:00
|
|
|
}
|
2019-02-09 13:41:40 +01:00
|
|
|
|
2020-08-31 20:40:31 +02:00
|
|
|
public function __construct(\DI\Container $container)
|
2019-02-09 13:41:40 +01:00
|
|
|
{
|
2020-08-31 20:40:31 +02:00
|
|
|
parent::__construct($container);
|
2019-02-09 13:41:40 +01:00
|
|
|
}
|
2020-08-31 20:40:31 +02:00
|
|
|
|
2018-09-24 13:53:18 +02:00
|
|
|
}
|