Fix app enabling for groups and allow requesting all apps

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2018-05-22 08:58:07 +02:00
parent 3b39e9c971
commit bb50ee08e9
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
2 changed files with 15 additions and 9 deletions

View File

@ -187,7 +187,7 @@ class AppSettingsController extends Controller {
* @param string $requestedCategory
* @return array
*/
private function getAppsForCategory($requestedCategory) {
private function getAppsForCategory($requestedCategory = '') {
$versionParser = new VersionParser();
$formattedApps = [];
$apps = $this->appFetcher->get();
@ -197,14 +197,16 @@ class AppSettingsController extends Controller {
}
// Skip all apps not in the requested category
$isInCategory = false;
foreach($app['categories'] as $category) {
if($category === $requestedCategory) {
$isInCategory = true;
if ($requestedCategory !== '') {
$isInCategory = false;
foreach($app['categories'] as $category) {
if($category === $requestedCategory) {
$isInCategory = true;
}
}
if(!$isInCategory) {
continue;
}
}
if(!$isInCategory) {
continue;
}
$nextCloudVersion = $versionParser->getVersion($app['releases'][0]['rawPlatformVersionSpec']);
@ -496,9 +498,10 @@ class AppSettingsController extends Controller {
* @PasswordConfirmationRequired
*
* @param string $appId
* @param array $groups
* @return JSONResponse
*/
public function enableApp(string $appId, array $groups): JSONResponse {
public function enableApp(string $appId, array $groups = []): JSONResponse {
return $this->enableApps([$appId], $groups);
}

View File

@ -51,7 +51,10 @@ $application->registerRoutes($this, [
['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'],
['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}', 'verb' => 'GET', 'defaults' => ['category' => '']],
['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}/{id}', 'verb' => 'GET', 'defaults' => ['category' => '', 'id' => '']],
['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'GET'],
['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'POST'],
['name' => 'AppSettings#enableApps', 'url' => '/settings/apps/enable', 'verb' => 'POST'],
['name' => 'AppSettings#disableApp', 'url' => '/settings/apps/disable/{appId}', 'verb' => 'GET'],
['name' => 'AppSettings#disableApps', 'url' => '/settings/apps/disable', 'verb' => 'POST'],