Squashed commit

Fixed some localization strings
Reviewed/optimized product deletion handling
Add option to hide products from the stock overview page (closes #906)
Prefill default_due_days also on the inventory page (closes #591)
Added DataTables accent chinese-string plugin (closes #872)
Show costs and calories per recipe ingredient (closes #1072)
Fixed user permission saving (fixes #1099)
User permissions should not have an effect for demo mode (closes #972)
Handle QU conversion when consuming a substituation (child) product (fixes #1118)
Consume/open any child product when the parent product is not in stock (closes #899)
Added a retry camera barcode scanning button to product picker workflow (closes #736)
This commit is contained in:
Bernd Bestel
2020-12-07 19:48:33 +01:00
parent 2bdb6ab2d4
commit cf34df5e3f
53 changed files with 387 additions and 210 deletions

View File

@@ -152,22 +152,32 @@ class UsersApiController extends BaseApiController
try
{
User::checkPermission($request, User::PERMISSION_ADMIN);
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
$requestBody = $request->getParsedBody();
$db = $this->getDatabase();
$db->user_permissions()
->where('user_id', $args['userId'])
->delete();
$perms = [];
foreach ($requestBody['permissions'] as $perm_id)
if (GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease')
{
// For demo mode always all users have and keep the ADMIN permission
$perms[] = [
'user_id' => $args['userId'],
'permission_id' => $perm_id
'permission_id' => 1
];
}
else
{
foreach ($requestBody['permissions'] as $perm_id)
{
$perms[] = [
'user_id' => $args['userId'],
'permission_id' => $perm_id
];
}
}
$db->insert('user_permissions', $perms, 'batch');
return $this->EmptyApiResponse($response);