diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | lib/l10n/lt_LT.js | 2 | ||||
-rw-r--r-- | lib/l10n/lt_LT.json | 2 | ||||
-rw-r--r-- | lib/l10n/zh_TW.js | 3 | ||||
-rw-r--r-- | lib/l10n/zh_TW.json | 3 | ||||
-rw-r--r-- | lib/private/AppFramework/App.php | 4 | ||||
-rw-r--r-- | lib/private/AppFramework/DependencyInjection/DIContainer.php | 57 | ||||
-rw-r--r-- | lib/private/AppFramework/Utility/SimpleContainer.php | 1 | ||||
-rw-r--r-- | lib/private/Mail/Mailer.php | 6 | ||||
-rw-r--r-- | lib/private/Repair.php | 2 | ||||
-rw-r--r-- | lib/private/Repair/NC15/SetVcardDatabaseUID.php | 137 | ||||
-rw-r--r-- | lib/private/Server.php | 17 | ||||
-rw-r--r-- | lib/private/Settings/Admin/Sharing.php | 9 | ||||
-rw-r--r-- | lib/private/Share/Share.php | 20 | ||||
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 18 |
16 files changed, 202 insertions, 81 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 66aeafc56c5..317565a2f06 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -967,6 +967,7 @@ return array( 'OC\\Repair\\NC13\\RepairInvalidPaths' => $baseDir . '/lib/private/Repair/NC13/RepairInvalidPaths.php', 'OC\\Repair\\NC14\\AddPreviewBackgroundCleanupJob' => $baseDir . '/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php', 'OC\\Repair\\NC14\\RepairPendingCronJobs' => $baseDir . '/lib/private/Repair/NC14/RepairPendingCronJobs.php', + 'OC\\Repair\\NC15\\SetVcardDatabaseUID' => $baseDir . '/lib/private/Repair/NC15/SetVcardDatabaseUID.php', 'OC\\Repair\\OldGroupMembershipShares' => $baseDir . '/lib/private/Repair/OldGroupMembershipShares.php', 'OC\\Repair\\Owncloud\\DropAccountTermsTable' => $baseDir . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php', 'OC\\Repair\\Owncloud\\SaveAccountsTableData' => $baseDir . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index f50e6b5beb0..ab8e5b21265 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -997,6 +997,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Repair\\NC13\\RepairInvalidPaths' => __DIR__ . '/../../..' . '/lib/private/Repair/NC13/RepairInvalidPaths.php', 'OC\\Repair\\NC14\\AddPreviewBackgroundCleanupJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php', 'OC\\Repair\\NC14\\RepairPendingCronJobs' => __DIR__ . '/../../..' . '/lib/private/Repair/NC14/RepairPendingCronJobs.php', + 'OC\\Repair\\NC15\\SetVcardDatabaseUID' => __DIR__ . '/../../..' . '/lib/private/Repair/NC15/SetVcardDatabaseUID.php', 'OC\\Repair\\OldGroupMembershipShares' => __DIR__ . '/../../..' . '/lib/private/Repair/OldGroupMembershipShares.php', 'OC\\Repair\\Owncloud\\DropAccountTermsTable' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php', 'OC\\Repair\\Owncloud\\SaveAccountsTableData' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php', diff --git a/lib/l10n/lt_LT.js b/lib/l10n/lt_LT.js index 0b2ecd6b3eb..9079ab0266b 100644 --- a/lib/l10n/lt_LT.js +++ b/lib/l10n/lt_LT.js @@ -52,7 +52,7 @@ OC.L10N.register( "Delete" : "Ištrinti", "Overview" : "Apžvalga", "Basic settings" : "Pagrindiniai nustatymai", - "Sharing" : "Dalijimasis", + "Sharing" : "Bendrinimas", "Security" : "Saugumas", "Additional settings" : "Papildomi nustatymai", "Personal info" : "Asmeninė informacija", diff --git a/lib/l10n/lt_LT.json b/lib/l10n/lt_LT.json index ba92e39575e..ea36f3667ac 100644 --- a/lib/l10n/lt_LT.json +++ b/lib/l10n/lt_LT.json @@ -50,7 +50,7 @@ "Delete" : "Ištrinti", "Overview" : "Apžvalga", "Basic settings" : "Pagrindiniai nustatymai", - "Sharing" : "Dalijimasis", + "Sharing" : "Bendrinimas", "Security" : "Saugumas", "Additional settings" : "Papildomi nustatymai", "Personal info" : "Asmeninė informacija", diff --git a/lib/l10n/zh_TW.js b/lib/l10n/zh_TW.js index 1760dc66539..86f7f8450de 100644 --- a/lib/l10n/zh_TW.js +++ b/lib/l10n/zh_TW.js @@ -61,11 +61,14 @@ OC.L10N.register( "Change" : "更改", "Delete" : "刪除", "Share" : "分享", + "Overview" : "概觀", "Basic settings" : "基本設定", "Sharing" : "分享", "Security" : "安全性", + "Groupware" : "協作應用程式", "Additional settings" : "其他設定", "Personal info" : "個人資訊", + "Mobile & desktop" : "行動裝置及桌面", "Unlimited" : "無限", "Verifying" : "驗證中", "Verifying …" : "驗證中…", diff --git a/lib/l10n/zh_TW.json b/lib/l10n/zh_TW.json index 503dbb65d1c..78293a12adf 100644 --- a/lib/l10n/zh_TW.json +++ b/lib/l10n/zh_TW.json @@ -59,11 +59,14 @@ "Change" : "更改", "Delete" : "刪除", "Share" : "分享", + "Overview" : "概觀", "Basic settings" : "基本設定", "Sharing" : "分享", "Security" : "安全性", + "Groupware" : "協作應用程式", "Additional settings" : "其他設定", "Personal info" : "個人資訊", + "Mobile & desktop" : "行動裝置及桌面", "Unlimited" : "無限", "Verifying" : "驗證中", "Verifying …" : "驗證中…", diff --git a/lib/private/AppFramework/App.php b/lib/private/AppFramework/App.php index 25708245e26..abb779ca979 100644 --- a/lib/private/AppFramework/App.php +++ b/lib/private/AppFramework/App.php @@ -84,9 +84,9 @@ class App { */ public static function main(string $controllerName, string $methodName, DIContainer $container, array $urlParams = null) { if (!is_null($urlParams)) { - $container[IRequest::class]->setUrlParameters($urlParams); + $container->query(IRequest::class)->setUrlParameters($urlParams); } else if (isset($container['urlParams']) && !is_null($container['urlParams'])) { - $container[IRequest::class]->setUrlParameters($container['urlParams']); + $container->query(IRequest::class)->setUrlParameters($container['urlParams']); } $appName = $container['AppName']; diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 439404f26ce..3708d967c9d 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -46,15 +46,13 @@ use OC\AppFramework\Middleware\Security\RateLimitingMiddleware; use OC\AppFramework\Middleware\Security\SecurityMiddleware; use OC\AppFramework\Middleware\SessionMiddleware; use OC\AppFramework\Utility\SimpleContainer; -use OC\Collaboration\Collaborators\SearchResult; use OC\Core\Middleware\TwoFactorMiddleware; -use OC\RichObjectStrings\Validator; use OC\ServerContainer; use OCP\AppFramework\Http\IOutput; use OCP\AppFramework\IAppContainer; use OCP\AppFramework\QueryException; +use OCP\AppFramework\Utility\IControllerMethodReflector; use OCP\AppFramework\Utility\ITimeFactory; -use OCP\Collaboration\Collaborators\ISearchResult; use OCP\Files\Folder; use OCP\Files\IAppData; use OCP\GlobalScale\IConfig; @@ -64,8 +62,6 @@ use OCP\IRequest; use OCP\IServerContainer; use OCP\ISession; use OCP\IUserSession; -use OCP\RichObjectStrings\IValidator; -use OCP\Encryption\IManager; use OCA\WorkflowEngine\Manager; class DIContainer extends SimpleContainer implements IAppContainer { @@ -89,6 +85,8 @@ class DIContainer extends SimpleContainer implements IAppContainer { $this['AppName'] = $appName; $this['urlParams'] = $urlParams; + $this->registerAlias('Request', IRequest::class); + /** @var \OC\ServerContainer $server */ if ($server === null) { $server = \OC::$server; @@ -125,19 +123,6 @@ class DIContainer extends SimpleContainer implements IAppContainer { return new OC\AppFramework\Logger($this->server->query(ILogger::class), $c->query('AppName')); }); - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); - - $this->registerService(IRequest::class, function() { - return $this->getServer()->query(IRequest::class); - }); - $this->registerAlias('Request', IRequest::class); - - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); - - $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class); - $this->registerService(IServerContainer::class, function ($c) { return $this->getServer(); }); @@ -151,8 +136,6 @@ class DIContainer extends SimpleContainer implements IAppContainer { return $c; }); - $this->registerAlias(ISearchResult::class, SearchResult::class); - // commonly used attributes $this->registerService('UserId', function ($c) { return $c->query(IUserSession::class)->getSession()->get('user_id'); @@ -166,26 +149,10 @@ class DIContainer extends SimpleContainer implements IAppContainer { return $c->getServer()->getThemingDefaults(); }); - $this->registerService(IManager::class, function ($c) { - return $this->getServer()->getEncryptionManager(); - }); - $this->registerService(IConfig::class, function ($c) { return $c->query(OC\GlobalScale\Config::class); }); - $this->registerService(IValidator::class, function($c) { - return $c->query(Validator::class); - }); - - $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) { - return new \OC\Security\IdentityProof\Manager( - $this->getServer()->query(\OC\Files\AppData\Factory::class), - $this->getServer()->getCrypto(), - $this->getServer()->getConfig() - ); - }); - $this->registerService('Protocol', function($c){ /** @var \OC\Server $server */ $server = $c->query('ServerContainer'); @@ -197,7 +164,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { return new Dispatcher( $c['Protocol'], $c['MiddlewareDispatcher'], - $c['ControllerMethodReflector'], + $c->query(IControllerMethodReflector::class), $c['Request'] ); }); @@ -219,7 +186,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { return new SecurityMiddleware( $c['Request'], - $c['ControllerMethodReflector'], + $server->query(IControllerMethodReflector::class), $server->getNavigationManager(), $server->getURLGenerator(), $server->getLogger(), @@ -239,7 +206,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $server = $app->getServer(); return new OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware( - $c['ControllerMethodReflector'], + $c->query(IControllerMethodReflector::class), $server->getSession(), $server->getUserSession(), $server->query(ITimeFactory::class) @@ -251,7 +218,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $server = $app->getServer(); return new OC\AppFramework\Middleware\Security\BruteForceMiddleware( - $c['ControllerMethodReflector'], + $c->query(IControllerMethodReflector::class), $server->getBruteForceThrottler(), $server->getRequest() ); @@ -264,7 +231,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { return new RateLimitingMiddleware( $server->getRequest(), $server->getUserSession(), - $c['ControllerMethodReflector'], + $c->query(IControllerMethodReflector::class), $c->query(OC\Security\RateLimiting\Limiter::class) ); }); @@ -272,7 +239,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $this->registerService('CORSMiddleware', function($c) { return new CORSMiddleware( $c['Request'], - $c['ControllerMethodReflector'], + $c->query(IControllerMethodReflector::class), $c->query(IUserSession::class), $c->getServer()->getBruteForceThrottler() ); @@ -281,7 +248,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $this->registerService('SessionMiddleware', function($c) use ($app) { return new SessionMiddleware( $c['Request'], - $c['ControllerMethodReflector'], + $c->query(IControllerMethodReflector::class), $app->getServer()->getSession() ); }); @@ -291,7 +258,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $userSession = $app->getServer()->getUserSession(); $session = $app->getServer()->getSession(); $urlGenerator = $app->getServer()->getURLGenerator(); - $reflector = $c['ControllerMethodReflector']; + $reflector = $c->query(IControllerMethodReflector::class); $request = $app->getServer()->getRequest(); return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request); }); @@ -305,7 +272,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $this->registerService(OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware::class, function (SimpleContainer $c) { return new OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware( $c['Request'], - $c['ControllerMethodReflector'] + $c->query(IControllerMethodReflector::class) ); }); diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index 47a6f95f747..6c2844e681b 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -176,5 +176,4 @@ class SimpleContainer extends Container implements IContainer { } return $name; } - } diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index 6f148bc0c6e..df23b669365 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -274,7 +274,11 @@ class Mailer implements IMailer { $binaryPath = '/var/qmail/bin/sendmail'; break; default: - $binaryPath = '/usr/sbin/sendmail'; + $sendmail = \OC_Helper::findBinaryPath('sendmail'); + if ($sendmail === null) { + $sendmail = '/usr/sbin/sendmail'; + } + $binaryPath = $sendmail; break; } diff --git a/lib/private/Repair.php b/lib/private/Repair.php index ad9662ca1d7..01724fd6a38 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -39,6 +39,7 @@ use OC\Repair\NC11\FixMountStorages; use OC\Repair\NC13\AddLogRotateJob; use OC\Repair\NC14\AddPreviewBackgroundCleanupJob; use OC\Repair\NC14\RepairPendingCronJobs; +use OC\Repair\NC15\SetVcardDatabaseUID; use OC\Repair\OldGroupMembershipShares; use OC\Repair\Owncloud\DropAccountTermsTable; use OC\Repair\Owncloud\SaveAccountsTableData; @@ -139,6 +140,7 @@ class Repair implements IOutput{ new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()), new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()), new RepairPendingCronJobs(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()), + new SetVcardDatabaseUID(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()), ]; } diff --git a/lib/private/Repair/NC15/SetVcardDatabaseUID.php b/lib/private/Repair/NC15/SetVcardDatabaseUID.php new file mode 100644 index 00000000000..ccf6c47cbc8 --- /dev/null +++ b/lib/private/Repair/NC15/SetVcardDatabaseUID.php @@ -0,0 +1,137 @@ +<?php +/** + * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com> + * + * @author John Molakvoæ <skjnldsv@protonmail.com> + * + * @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 OC\Repair\NC15; + +use OCP\IConfig; +use OCP\IDBConnection; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; +use Sabre\VObject\Reader; + +class SetVcardDatabaseUID implements IRepairStep { + const MAX_ROWS = 1000; + + /** @var IDBConnection */ + private $connection; + + /** @var IConfig */ + private $config; + + private $updateQuery; + + public function __construct(IDBConnection $connection, IConfig $config) { + $this->connection = $connection; + $this->config = $config; + } + + public function getName() { + return 'Extract the vcard uid and store it in the db'; + } + + /** + * @return \Generator + * @suppress SqlInjectionChecker + */ + private function getInvalidEntries() { + $builder = $this->connection->getQueryBuilder(); + + $builder->select('id', 'carddata') + ->from('cards') + ->where($builder->expr()->isNull('uid')) + ->setMaxResults(self::MAX_ROWS); + + do { + $result = $builder->execute(); + $rows = $result->fetchAll(); + foreach ($rows as $row) { + yield $row; + } + $result->closeCursor(); + } while (count($rows) > 0); + } + + /** + * Extract UID from vcard + * + * @param string $cardData the vcard raw data + * @return string the uid or empty if none + */ + private function getUID(string $cardData): string { + $vCard = Reader::read($cardData); + if ($vCard->UID) { + $uid = $vCard->UID->getValue(); + return $uid; + } + + return ''; + } + + /** + * @param int $id + * @param string $uid + */ + private function update(int $id, string $uid) { + if (!$this->updateQuery) { + $builder = $this->connection->getQueryBuilder(); + + $this->updateQuery = $builder->update('cards') + ->set('uid', $builder->createParameter('uid')) + ->where($builder->expr()->eq('id', $builder->createParameter('id'))); + } + + $this->updateQuery->setParameter('id', $id); + $this->updateQuery->setParameter('uid', $uid); + + $this->updateQuery->execute(); + } + + private function repair(): int { + $this->connection->beginTransaction(); + $entries = $this->getInvalidEntries(); + $count = 0; + foreach ($entries as $entry) { + $count++; + $uid = $this->getUID($entry['carddata']); + $this->update($entry['id'], $uid); + } + $this->connection->commit(); + + return $count; + } + + private function shouldRun() { + $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + + // was added to 15.0.0.2 + return version_compare($versionFromBeforeUpdate, '15.0.0.2', '<='); + } + + public function run(IOutput $output) { + if ($this->shouldRun()) { + $count = $this->repair(); + + $output->info('Fixed ' . $count . ' vcards'); + } + } +} diff --git a/lib/private/Server.php b/lib/private/Server.php index 204345708b9..938c54b8a1c 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -217,7 +217,7 @@ class Server extends ServerContainer implements IServerContainer { ); }); - $this->registerService('EncryptionManager', function (Server $c) { + $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { $view = new View(); $util = new Encryption\Util( $view, @@ -234,6 +234,7 @@ class Server extends ServerContainer implements IServerContainer { new ArrayCache() ); }); + $this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class); $this->registerService('EncryptionFileHelper', function (Server $c) { $util = new Encryption\Util( @@ -361,7 +362,7 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); - $this->registerService(\OCP\IUserSession::class, function (Server $c) { + $this->registerService(\OC\User\Session::class, function (Server $c) { $manager = $c->getUserManager(); $session = new \OC\Session\Memory(''); $timeFactory = new TimeFactory(); @@ -430,7 +431,8 @@ class Server extends ServerContainer implements IServerContainer { }); return $userSession; }); - $this->registerAlias('UserSession', \OCP\IUserSession::class); + $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); + $this->registerAlias('UserSession', \OC\User\Session::class); $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); @@ -1083,6 +1085,7 @@ class Server extends ServerContainer implements IServerContainer { return $instance; }); $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); + $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); @@ -1188,6 +1191,14 @@ class Server extends ServerContainer implements IServerContainer { $this->registerAlias(IDashboardManager::class, DashboardManager::class); $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); + $this->registerService(\OC\Security\IdentityProof\Manager::class, function (Server $c) { + return new \OC\Security\IdentityProof\Manager( + $c->query(\OC\Files\AppData\Factory::class), + $c->getCrypto(), + $c->getConfig() + ); + }); + $this->connectDispatcher(); } diff --git a/lib/private/Settings/Admin/Sharing.php b/lib/private/Settings/Admin/Sharing.php index dfc0b11478b..ee6a64c85bf 100644 --- a/lib/private/Settings/Admin/Sharing.php +++ b/lib/private/Settings/Admin/Sharing.php @@ -32,6 +32,7 @@ use OCP\Constants; use OCP\IConfig; use OCP\IL10N; use OCP\Settings\ISettings; +use OCP\Share\IManager; use OCP\Util; class Sharing implements ISettings { @@ -41,12 +42,16 @@ class Sharing implements ISettings { /** @var IL10N */ private $l; + /** @var IManager */ + private $shareManager; + /** * @param IConfig $config */ - public function __construct(IConfig $config, IL10N $l) { + public function __construct(IConfig $config, IL10N $l, IManager $shareManager) { $this->config = $config; $this->l = $l; + $this->shareManager = $shareManager; } /** @@ -65,7 +70,7 @@ class Sharing implements ISettings { 'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'), 'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'), 'enforceLinkPassword' => Util::isPublicLinkPasswordRequired(), - 'onlyShareWithGroupMembers' => Share::shareWithGroupMembersOnly(), + 'onlyShareWithGroupMembers' => $this->shareManager->shareWithGroupMembersOnly(), 'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'), 'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'), 'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'), diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php index 36912dcafe3..76a6a1baeca 100644 --- a/lib/private/Share/Share.php +++ b/lib/private/Share/Share.php @@ -341,7 +341,7 @@ class Share extends Constants { } $uidOwner = \OC_User::getUser(); - $shareWithinGroupOnly = self::shareWithGroupMembersOnly(); + $shareWithinGroupOnly = \OC::$server->getConfig()->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes'; if (is_null($itemSourceName)) { $itemSourceName = $itemSource; @@ -2055,15 +2055,6 @@ class Share extends Constants { } /** - * check if user can only share with group members - * @return bool - */ - public static function shareWithGroupMembersOnly() { - $value = \OC::$server->getConfig()->getAppValue('core', 'shareapi_only_share_with_group_members', 'no'); - return $value === 'yes'; - } - - /** * @return bool */ public static function isDefaultExpireDateEnabled() { @@ -2104,15 +2095,6 @@ class Share extends Constants { } /** - * @param IConfig $config - * @return bool - */ - public static function enforcePassword(IConfig $config) { - $enforcePassword = $config->getAppValue('core', 'shareapi_enforce_links_password', 'no'); - return $enforcePassword === 'yes'; - } - - /** * @param string $password * @throws \Exception */ diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 50111054546..a2388012fe7 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -156,6 +156,8 @@ class DefaultShareProvider implements IShareProvider { $qb->setValue('password', $qb->createNamedParameter($share->getPassword())); } + $qb->setValue('password_by_talk', $qb->createNamedParameter($share->getSendPasswordByTalk(), IQueryBuilder::PARAM_BOOL)); + //If an expiration date is set store it if ($share->getExpirationDate() !== null) { $qb->setValue('expiration', $qb->createNamedParameter($share->getExpirationDate(), 'datetime')); @@ -293,6 +295,7 @@ class DefaultShareProvider implements IShareProvider { $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->set('password', $qb->createNamedParameter($share->getPassword())) + ->set('password_by_talk', $qb->createNamedParameter($share->getSendPasswordByTalk(), IQueryBuilder::PARAM_BOOL)) ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) @@ -620,12 +623,14 @@ class DefaultShareProvider implements IShareProvider { if ($reshares === false) { $qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))); } else { - $qb->andWhere( - $qb->expr()->orX( - $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), - $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) - ) - ); + if ($node === null) { + $qb->andWhere( + $qb->expr()->orX( + $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), + $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) + ) + ); + } } if ($node !== null) { @@ -938,6 +943,7 @@ class DefaultShareProvider implements IShareProvider { $share->setSharedWith($data['share_with']); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { $share->setPassword($data['password']); + $share->setSendPasswordByTalk((bool)$data['password_by_talk']); $share->setToken($data['token']); } |