diff options
author | Morris Jobke <hey@morrisjobke.de> | 2021-05-21 15:35:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-21 15:35:39 +0200 |
commit | f1dbabd9109c08e62d6f82124c63201c96ad2203 (patch) | |
tree | ea6b862c1fa97ec5ad03895c120268bd25d1d35e /lib/private/legacy | |
parent | b1ad3faf14140e3c85a7eec1dade88cd551cc747 (diff) | |
parent | 8d7fae8fae054eaa08635fea3ba092196c6f8b84 (diff) | |
download | nextcloud-server-f1dbabd9109c08e62d6f82124c63201c96ad2203.tar.gz nextcloud-server-f1dbabd9109c08e62d6f82124c63201c96ad2203.zip |
Merge pull request #26727 from nextcloud/group-exclude-link-share
Add option to exclude groups from creating link shares
Diffstat (limited to 'lib/private/legacy')
-rw-r--r-- | lib/private/legacy/OC_Util.php | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index 63eaf303759..c9e19221f95 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -72,6 +72,7 @@ use OCP\IGroupManager; use OCP\ILogger; use OCP\IUser; use OCP\IUserSession; +use OCP\Share\IManager; use Psr\Log\LoggerInterface; class OC_Util { @@ -336,8 +337,9 @@ class OC_Util { * @suppress PhanDeprecatedFunction */ public static function isPublicLinkPasswordRequired() { - $enforcePassword = \OC::$server->getConfig()->getAppValue('core', 'shareapi_enforce_links_password', 'no'); - return $enforcePassword === 'yes'; + /** @var IManager $shareManager */ + $shareManager = \OC::$server->get(IManager::class); + return $shareManager->shareApiLinkEnforcePassword(); } /** @@ -348,25 +350,10 @@ class OC_Util { * @return bool */ public static function isSharingDisabledForUser(IConfig $config, IGroupManager $groupManager, $user) { - if ($config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') { - $groupsList = $config->getAppValue('core', 'shareapi_exclude_groups_list', ''); - $excludedGroups = json_decode($groupsList); - if (is_null($excludedGroups)) { - $excludedGroups = explode(',', $groupsList); - $newValue = json_encode($excludedGroups); - $config->setAppValue('core', 'shareapi_exclude_groups_list', $newValue); - } - $usersGroups = $groupManager->getUserGroupIds($user); - if (!empty($usersGroups)) { - $remainingGroups = array_diff($usersGroups, $excludedGroups); - // if the user is only in groups which are disabled for sharing then - // sharing is also disabled for the user - if (empty($remainingGroups)) { - return true; - } - } - } - return false; + /** @var IManager $shareManager */ + $shareManager = \OC::$server->get(IManager::class); + $userId = $user ? $user->getUID() : null; + return $shareManager->sharingDisabledForUser($userId); } /** @@ -376,14 +363,9 @@ class OC_Util { * @suppress PhanDeprecatedFunction */ public static function isDefaultExpireDateEnforced() { - $isDefaultExpireDateEnabled = \OC::$server->getConfig()->getAppValue('core', 'shareapi_default_expire_date', 'no'); - $enforceDefaultExpireDate = false; - if ($isDefaultExpireDateEnabled === 'yes') { - $value = \OC::$server->getConfig()->getAppValue('core', 'shareapi_enforce_expire_date', 'no'); - $enforceDefaultExpireDate = $value === 'yes'; - } - - return $enforceDefaultExpireDate; + /** @var IManager $shareManager */ + $shareManager = \OC::$server->get(IManager::class); + return $shareManager->shareApiLinkDefaultExpireDateEnforced(); } /** |