aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/App
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2024-09-13 17:44:38 +0200
committerGitHub <noreply@github.com>2024-09-13 17:44:38 +0200
commitbcb4e781a407798ef9d071dc3a15a1d0ac9e0e8d (patch)
treee210686e9c6d7fdd33b7e0cc905fbd38143db0a3 /lib/private/App
parent032f17c7956748fd25e33edf5d85d1d25b1ee94b (diff)
parent7a16d01ea79bf8effedd5e0e9ac7c2e4b4ea41f8 (diff)
downloadnextcloud-server-bcb4e781a407798ef9d071dc3a15a1d0ac9e0e8d.tar.gz
nextcloud-server-bcb4e781a407798ef9d071dc3a15a1d0ac9e0e8d.zip
Merge pull request #47927 from nextcloud/fix/migrate-away-from-oc_app
Migrate away from OC_App to IAppManager
Diffstat (limited to 'lib/private/App')
-rw-r--r--lib/private/App/AppManager.php40
1 files changed, 37 insertions, 3 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php
index fe2f7b74b22..4ffddef98c3 100644
--- a/lib/private/App/AppManager.php
+++ b/lib/private/App/AppManager.php
@@ -156,6 +156,37 @@ class AppManager implements IAppManager {
}
/**
+ * Get a list of all apps in the apps folder
+ *
+ * @return list<string> an array of app names (string IDs)
+ */
+ public function getAllAppsInAppsFolders(): array {
+ $apps = [];
+
+ foreach (\OC::$APPSROOTS as $apps_dir) {
+ if (!is_readable($apps_dir['path'])) {
+ $this->logger->warning('unable to read app folder : ' . $apps_dir['path'], ['app' => 'core']);
+ continue;
+ }
+ $dh = opendir($apps_dir['path']);
+
+ if (is_resource($dh)) {
+ while (($file = readdir($dh)) !== false) {
+ if (
+ $file[0] != '.' &&
+ is_dir($apps_dir['path'] . '/' . $file) &&
+ is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')
+ ) {
+ $apps[] = $file;
+ }
+ }
+ }
+ }
+
+ return array_values(array_unique($apps));
+ }
+
+ /**
* List all apps enabled for a user
*
* @param \OCP\IUser $user
@@ -647,11 +678,9 @@ class AppManager implements IAppManager {
/**
* Get the directory for the given app.
*
- * @param string $appId
- * @return string
* @throws AppPathNotFoundException if app folder can't be found
*/
- public function getAppPath($appId) {
+ public function getAppPath(string $appId): string {
$appPath = \OC_App::getAppPath($appId);
if ($appPath === false) {
throw new AppPathNotFoundException('Could not find path for ' . $appId);
@@ -877,4 +906,9 @@ class AppManager implements IAppManager {
return false;
}
+
+ public function cleanAppId(string $app): string {
+ // FIXME should list allowed characters instead
+ return str_replace(['<', '>', '"', "'", '\0', '/', '\\', '..'], '', $app);
+ }
}