Squashed commit

Use managed fonts
Include userentities dynamically in grocy.openapi.json for /userfields/{entity}/{objectId} endpoints (closes #1218)
Fixed userfieldsform load / save (for products and recipes) handling (fixes #1302)
Fixed PUT/DELETE /objects/{entity}/{objectId} when the given object id was invalid (fixes #1396)
Allow arrays in HTMLPurifier (fixes #1407)
This commit is contained in:
Bernd Bestel
2021-06-28 17:00:16 +02:00
parent acb81187d9
commit 35fb87ab1e
35 changed files with 51 additions and 1408 deletions

View File

@@ -220,11 +220,12 @@ class BaseController
}
$requestBody = $request->getParsedBody();
return $requestBody;
foreach ($requestBody as $key => &$value)
{
// HTMLPurifier removes boolean values (true/false), so explicitly keep them
// HTMLPurifier removes boolean values (true/false) and arrays, so explicitly keep them
// Maybe also possible through HTMLPurifier config (http://htmlpurifier.org/live/configdoc/plain.html)
if (!is_bool($value))
if (!is_bool($value) && !is_array($value))
{
$value = self::$htmlPurifierInstance->purify($value);
}

View File

@@ -58,6 +58,11 @@ class GenericEntityApiController extends BaseApiController
}
$row = $this->getDatabase()->{$args['entity']}($args['objectId']);
if ($row == null)
{
return $this->GenericErrorResponse($response, 'Object not found', 400);
}
$row->delete();
$success = $row->isClean();
@@ -90,6 +95,11 @@ class GenericEntityApiController extends BaseApiController
}
$row = $this->getDatabase()->{$args['entity']}($args['objectId']);
if ($row == null)
{
return $this->GenericErrorResponse($response, 'Object not found', 400);
}
$row->update($requestBody);
$success = $row->isClean();

View File

@@ -36,6 +36,12 @@ class OpenApiController extends BaseApiController
$spec->info->description = str_replace('PlaceHolderManageApiKeysUrl', $this->AppContainer->get('UrlManager')->ConstructUrl('/manageapikeys'), $spec->info->description);
$spec->servers[0]->url = $this->AppContainer->get('UrlManager')->ConstructUrl('/api');
$spec->components->internalSchemas->ExposedEntity_IncludingUserEntities = clone $spec->components->internalSchemas->ExposedEntity;
foreach ($this->getUserfieldsService()->GetEntities() as $userEntity)
{
array_push($spec->components->internalSchemas->ExposedEntity_IncludingUserEntities->enum, $userEntity);
}
$spec->components->internalSchemas->ExposedEntity_NotIncludingNotEditable = clone $spec->components->internalSchemas->StringEnumTemplate;
foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value)
{
@@ -45,6 +51,15 @@ class OpenApiController extends BaseApiController
}
}
$spec->components->internalSchemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable = clone $spec->components->internalSchemas->StringEnumTemplate;
foreach ($spec->components->internalSchemas->ExposedEntity_IncludingUserEntities->enum as $value)
{
if (!in_array($value, $spec->components->internalSchemas->ExposedEntityNoEdit->enum))
{
array_push($spec->components->internalSchemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable->enum, $value);
}
}
$spec->components->internalSchemas->ExposedEntity_NotIncludingNotDeletable = clone $spec->components->internalSchemas->StringEnumTemplate;
foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value)
{