From 0fe00a2654b4eec3b7b28c447a64d6fce23f4228 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Wed, 2 Aug 2023 22:28:07 +0200 Subject: [PATCH] Add docker environment and fix sharing folder --- .dockerignore | 7 +++++++ Dockerfile | 21 +++++++++++++++++++++ lib/Hooks.php | 12 ++++++------ 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cdc7851 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.idea +*.iml +/vendor/ +/build/ +node_modules/ +/.php-cs-fixer.cache +js/*hot-update.* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a0293f1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM nextcloud:27 + +ENV NEXTCLOUD_UPDATE 1 +ENV NEXTCLOUD_ADMIN_USER epubreader +ENV NEXTCLOUD_ADMIN_PASSWORD epubreader +ENV NEXTCLOUD_INIT_HTACCESS 1 +ENV SQLITE_DATABASE epubreader + +RUN curl -sSLo /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar && \ + chmod +x /usr/local/bin/composer && \ + rm -f /usr/local/etc/php/conf.d/opcache-recommended.ini && \ + /entrypoint.sh true + +USER www-data + +COPY --chown=www-data:www-data . apps/epubreader +RUN cd apps/epubreader && composer install && cd - && \ + php occ app:enable epubreader && \ + php occ config:system:set debug --value=true + +USER root diff --git a/lib/Hooks.php b/lib/Hooks.php index 8ed29b0..9060ca0 100644 --- a/lib/Hooks.php +++ b/lib/Hooks.php @@ -45,19 +45,19 @@ class Hooks { // Nextcloud encodes this as JSON, Owncloud does not (yet) (#75) // TODO: remove this when Owncloud starts encoding oc_appconfig as JSON just like it already encodes most other properties - $user = Server::get(IUserSession::class)->getUser(); - if ($user - && is_array($settings['array']) + if (is_array($settings['array']) && array_key_exists('oc_appconfig', $settings['array']) ) { $isJson = self::isJson($settings['array']['oc_appconfig']); + $user = Server::get(IUserSession::class)->getUser(); + $userId = $user ? $user->getUID() : null; /** @var array $array */ $array = ($isJson) ? json_decode((string) $settings['array']['oc_appconfig'], true) : $settings['array']['oc_appconfig']; $array['filesReader'] = [ - 'enableEpub' => Server::get(IConfig::class)->getUserValue($user->getUID(), Application::APP_ID, 'epub_enable', true), - 'enablePdf' => Server::get(IConfig::class)->getUserValue($user->getUID(), Application::APP_ID, 'pdf_enable', true), - 'enableCbx' => Server::get(IConfig::class)->getUserValue($user->getUID(), Application::APP_ID, 'cbx_enable', true), + 'enableEpub' => Server::get(IConfig::class)->getUserValue($userId, Application::APP_ID, 'epub_enable', true), + 'enablePdf' => Server::get(IConfig::class)->getUserValue($userId, Application::APP_ID, 'pdf_enable', true), + 'enableCbx' => Server::get(IConfig::class)->getUserValue($userId, Application::APP_ID, 'cbx_enable', true), ]; $settings['array']['oc_appconfig'] = ($isJson) ? json_encode($array) : $array; }