diff options
Diffstat (limited to 'apps/sharebymail')
-rw-r--r-- | apps/sharebymail/appinfo/app.php | 27 | ||||
-rw-r--r-- | apps/sharebymail/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | apps/sharebymail/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | apps/sharebymail/lib/AppInfo/Application.php | 27 | ||||
-rw-r--r-- | apps/sharebymail/lib/Capabilities.php | 31 | ||||
-rw-r--r-- | apps/sharebymail/lib/Settings.php | 53 | ||||
-rw-r--r-- | apps/sharebymail/lib/Settings/SettingsManager.php | 6 |
7 files changed, 39 insertions, 107 deletions
diff --git a/apps/sharebymail/appinfo/app.php b/apps/sharebymail/appinfo/app.php deleted file mode 100644 index b57957e7dac..00000000000 --- a/apps/sharebymail/appinfo/app.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016 Bjoern Schiessle <bjoern@schiessle.org> - * - * @author Bjoern Schiessle <bjoern@schiessle.org> - * @author Robin Appelman <robin@icewind.nl> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use OCA\ShareByMail\AppInfo\Application; - -$app = \OC::$server->query(Application::class); diff --git a/apps/sharebymail/composer/composer/autoload_classmap.php b/apps/sharebymail/composer/composer/autoload_classmap.php index 0df9428d7b0..4fa3560d87f 100644 --- a/apps/sharebymail/composer/composer/autoload_classmap.php +++ b/apps/sharebymail/composer/composer/autoload_classmap.php @@ -9,7 +9,6 @@ return array( 'OCA\\ShareByMail\\Activity' => $baseDir . '/../lib/Activity.php', 'OCA\\ShareByMail\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', 'OCA\\ShareByMail\\Capabilities' => $baseDir . '/../lib/Capabilities.php', - 'OCA\\ShareByMail\\Settings' => $baseDir . '/../lib/Settings.php', 'OCA\\ShareByMail\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php', 'OCA\\ShareByMail\\Settings\\SettingsManager' => $baseDir . '/../lib/Settings/SettingsManager.php', 'OCA\\ShareByMail\\ShareByMailProvider' => $baseDir . '/../lib/ShareByMailProvider.php', diff --git a/apps/sharebymail/composer/composer/autoload_static.php b/apps/sharebymail/composer/composer/autoload_static.php index 273da60be64..22897e05f56 100644 --- a/apps/sharebymail/composer/composer/autoload_static.php +++ b/apps/sharebymail/composer/composer/autoload_static.php @@ -24,7 +24,6 @@ class ComposerStaticInitShareByMail 'OCA\\ShareByMail\\Activity' => __DIR__ . '/..' . '/../lib/Activity.php', 'OCA\\ShareByMail\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', 'OCA\\ShareByMail\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php', - 'OCA\\ShareByMail\\Settings' => __DIR__ . '/..' . '/../lib/Settings.php', 'OCA\\ShareByMail\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php', 'OCA\\ShareByMail\\Settings\\SettingsManager' => __DIR__ . '/..' . '/../lib/Settings/SettingsManager.php', 'OCA\\ShareByMail\\ShareByMailProvider' => __DIR__ . '/..' . '/../lib/ShareByMailProvider.php', diff --git a/apps/sharebymail/lib/AppInfo/Application.php b/apps/sharebymail/lib/AppInfo/Application.php index 7acb43cfbed..572e754d934 100644 --- a/apps/sharebymail/lib/AppInfo/Application.php +++ b/apps/sharebymail/lib/AppInfo/Application.php @@ -1,4 +1,6 @@ <?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org> * @@ -27,23 +29,22 @@ namespace OCA\ShareByMail\AppInfo; use OCA\ShareByMail\Capabilities; -use OCA\ShareByMail\Settings; use OCP\AppFramework\App; -use OCP\Util; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; -class Application extends App { - public function __construct(array $urlParams = []) { - parent::__construct('sharebymail', $urlParams); +class Application extends App implements IBootstrap { + public const APP_ID = 'sharebymail'; - $settingsManager = \OC::$server->query(Settings\SettingsManager::class); - $settings = new Settings($settingsManager); + public function __construct() { + parent::__construct(self::APP_ID); + } - /** register capabilities */ - $container = $this->getContainer(); - $container->registerCapability(Capabilities::class); + public function register(IRegistrationContext $context): void { + $context->registerCapability(Capabilities::class); + } - /** register hooks */ - Util::connectHook('\OCP\Config', 'js', $settings, 'announceShareProvider'); - Util::connectHook('\OCP\Config', 'js', $settings, 'announceShareByMailSettings'); + public function boot(IBootContext $context): void { } } diff --git a/apps/sharebymail/lib/Capabilities.php b/apps/sharebymail/lib/Capabilities.php index e703b9b1e5f..bc2d2baf817 100644 --- a/apps/sharebymail/lib/Capabilities.php +++ b/apps/sharebymail/lib/Capabilities.php @@ -1,4 +1,6 @@ <?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org> * @@ -23,26 +25,35 @@ namespace OCA\ShareByMail; +use OCA\ShareByMail\Settings\SettingsManager; use OCP\Capabilities\ICapability; class Capabilities implements ICapability { - /** - * Function an app uses to return the capabilities - * - * @return array Array containing the apps capabilities - * @since 8.2.0 - */ - public function getCapabilities() { + /** @var SettingsManager */ + private $manager; + + public function __construct(SettingsManager $manager) { + $this->manager = $manager; + } + + public function getCapabilities(): array { return [ 'files_sharing' => [ 'sharebymail' => [ 'enabled' => true, - 'upload_files_drop' => ['enabled' => true], - 'password' => ['enabled' => true], - 'expire_date' => ['enabled' => true] + 'upload_files_drop' => [ + 'enabled' => true, + ], + 'password' => [ + 'enabled' => true, + 'enforced' => $this->manager->enforcePasswordProtection(), + ], + 'expire_date' => [ + 'enabled' => true, + ], ] ] ]; diff --git a/apps/sharebymail/lib/Settings.php b/apps/sharebymail/lib/Settings.php deleted file mode 100644 index 721050c83c4..00000000000 --- a/apps/sharebymail/lib/Settings.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016 Bjoern Schiessle <bjoern@schiessle.org> - * - * @author Bjoern Schiessle <bjoern@schiessle.org> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -namespace OCA\ShareByMail; - -use OCA\ShareByMail\Settings\SettingsManager; - -class Settings { - - /** @var SettingsManager */ - private $settingsManager; - - public function __construct(SettingsManager $settingsManager) { - $this->settingsManager = $settingsManager; - } - - /** - * announce that the share-by-mail share provider is enabled - * - * @param array $settings - */ - public function announceShareProvider(array $settings) { - $array = json_decode($settings['array']['oc_appconfig'], true); - $array['shareByMailEnabled'] = true; - $settings['array']['oc_appconfig'] = json_encode($array); - } - - public function announceShareByMailSettings(array $settings) { - $array = json_decode($settings['array']['oc_appconfig'], true); - $array['shareByMail']['enforcePasswordProtection'] = $this->settingsManager->enforcePasswordProtection(); - $settings['array']['oc_appconfig'] = json_encode($array); - } -} diff --git a/apps/sharebymail/lib/Settings/SettingsManager.php b/apps/sharebymail/lib/Settings/SettingsManager.php index cded3e1713d..00826b9b6f5 100644 --- a/apps/sharebymail/lib/Settings/SettingsManager.php +++ b/apps/sharebymail/lib/Settings/SettingsManager.php @@ -1,4 +1,6 @@ <?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org> * @@ -43,7 +45,7 @@ class SettingsManager { * * @return bool */ - public function sendPasswordByMail() { + public function sendPasswordByMail(): bool { $sendPasswordByMail = $this->config->getAppValue('sharebymail', 'sendpasswordmail', $this->sendPasswordByMailDefault); return $sendPasswordByMail === 'yes'; } @@ -53,7 +55,7 @@ class SettingsManager { * * @return bool */ - public function enforcePasswordProtection() { + public function enforcePasswordProtection(): bool { $enforcePassword = $this->config->getAppValue('sharebymail', 'enforcePasswordProtection', $this->enforcePasswordProtectionDefault); return $enforcePassword === 'yes'; } |