mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-06-07 18:04:26 +02:00
[advancedcontentfilter] Migrate Slim to version 4 to avoid PHP 8.2 deprecation error
- Fix https://github.com/friendica/friendica/issues/13822
This commit is contained in:
parent
b05a95cc45
commit
a30e9b788c
376 changed files with 10144 additions and 15497 deletions
|
@ -190,7 +190,7 @@ function advancedcontentfilter_module() {}
|
|||
function advancedcontentfilter_init()
|
||||
{
|
||||
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'api') {
|
||||
$slim = new \Slim\App();
|
||||
$slim = \Slim\Factory\AppFactory::create();
|
||||
|
||||
require __DIR__ . '/src/middlewares.php';
|
||||
|
||||
|
@ -305,7 +305,7 @@ function advancedcontentfilter_build_fields($data)
|
|||
* API
|
||||
*/
|
||||
|
||||
function advancedcontentfilter_get_rules()
|
||||
function advancedcontentfilter_get_rules(ServerRequestInterface $request, ResponseInterface $response)
|
||||
{
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this method'));
|
||||
|
@ -313,7 +313,8 @@ function advancedcontentfilter_get_rules()
|
|||
|
||||
$rules = DBA::toArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => DI::userSession()->getLocalUserId()]));
|
||||
|
||||
return json_encode($rules);
|
||||
$response->getBody()->write(json_encode($rules));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
function advancedcontentfilter_get_rules_id(ServerRequestInterface $request, ResponseInterface $response, $args)
|
||||
|
@ -324,10 +325,11 @@ function advancedcontentfilter_get_rules_id(ServerRequestInterface $request, Res
|
|||
|
||||
$rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => $args['id'], 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
|
||||
return json_encode($rule);
|
||||
$response->getBody()->write(json_encode($rule));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
function advancedcontentfilter_post_rules(ServerRequestInterface $request)
|
||||
function advancedcontentfilter_post_rules(ServerRequestInterface $request, ResponseInterface $response)
|
||||
{
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this method'));
|
||||
|
@ -360,7 +362,8 @@ function advancedcontentfilter_post_rules(ServerRequestInterface $request)
|
|||
|
||||
DI::cache()->delete('rules_' . DI::userSession()->getLocalUserId());
|
||||
|
||||
return json_encode(['message' => DI::l10n()->t('Rule successfully added'), 'rule' => $rule]);
|
||||
$response->getBody()->write(json_encode(['message' => DI::l10n()->t('Rule successfully added'), 'rule' => $rule]));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, ResponseInterface $response, $args)
|
||||
|
@ -391,7 +394,8 @@ function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, Res
|
|||
|
||||
DI::cache()->delete('rules_' . DI::userSession()->getLocalUserId());
|
||||
|
||||
return json_encode(['message' => DI::l10n()->t('Rule successfully updated')]);
|
||||
$response->getBody()->write(json_encode(['message' => DI::l10n()->t('Rule successfully updated')]));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
function advancedcontentfilter_delete_rules_id(ServerRequestInterface $request, ResponseInterface $response, $args)
|
||||
|
@ -414,7 +418,8 @@ function advancedcontentfilter_delete_rules_id(ServerRequestInterface $request,
|
|||
|
||||
DI::cache()->delete('rules_' . DI::userSession()->getLocalUserId());
|
||||
|
||||
return json_encode(['message' => DI::l10n()->t('Rule successfully deleted')]);
|
||||
$response->getBody()->write(json_encode(['message' => DI::l10n()->t('Rule successfully deleted')]));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
function advancedcontentfilter_get_variables_guid(ServerRequestInterface $request, ResponseInterface $response, $args)
|
||||
|
@ -437,7 +442,8 @@ function advancedcontentfilter_get_variables_guid(ServerRequestInterface $reques
|
|||
|
||||
$return = advancedcontentfilter_get_filter_fields(advancedcontentfilter_prepare_item_row($item_row));
|
||||
|
||||
return json_encode(['variables' => str_replace('\\\'', '\'', var_export($return, true))]);
|
||||
$response->getBody()->write(json_encode(['variables' => str_replace('\\\'', '\'', var_export($return, true))]));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue