| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /**
- * @OA\Tag(
- * name="plugins"
- * )
- */
- $app->get('/plugins', function ($request, $response, $args) {
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->checkRoute($request)) {
- $GLOBALS['api']['response']['data'] = $Organizr->getPlugins();
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/plugins/disabled', function ($request, $response, $args) {
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->checkRoute($request)) {
- $GLOBALS['api']['response']['data'] = $Organizr->getPlugins('disabled');
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/plugins/enabled', function ($request, $response, $args) {
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->checkRoute($request)) {
- $GLOBALS['api']['response']['data'] = $Organizr->getPlugins('enabled');
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->post('/plugins/manage/{plugin}', function ($request, $response, $args) {
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->installPlugin($args['plugin']);
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->delete('/plugins/manage/{plugin}', function ($request, $response, $args) {
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->qualifyRequest(1, true)) {
- $Organizr->removePlugin($args['plugin']);
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/plugins/marketplace', function ($request, $response, $args) {
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->checkRoute($request)) {
- if ($Organizr->qualifyRequest(1, true)) {
- $GLOBALS['api']['response']['data'] = $Organizr->getPluginsMarketplace();
- }
-
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
|