Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2020-07-05 14:23:30 +0300
committerMorris Jobke <hey@morrisjobke.de>2020-07-06 10:45:08 +0300
commit0bcc643d6e8fdc369e8c7117a619b1dcc8f8822d (patch)
tree954d5fa282898b4c6cf0240e5797994778b6a0bb /apps/sharebymail/lib
parent52af709ceaf77b1f8b6b8f7b81dbbc115784f792 (diff)
Cleanup share by mail a bit
* Moved to ned IBootstrap * Register everything via the capabilities api (So clients can use it as well) - This applies to the enforcing passwords * Updated the sharing js code to use it * removed app.php * removed unused settings now * typehints * strict typing Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl> Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com> Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/sharebymail/lib')
-rw-r--r--apps/sharebymail/lib/AppInfo/Application.php27
-rw-r--r--apps/sharebymail/lib/Capabilities.php31
-rw-r--r--apps/sharebymail/lib/Settings.php53
-rw-r--r--apps/sharebymail/lib/Settings/SettingsManager.php6
4 files changed, 39 insertions, 78 deletions
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';
}