mirror of
https://github.com/nextcloud/server.git
synced 2026-04-28 09:37:29 -04:00
fix: Fix types for sharingDisabledForUser
and use the non-deprecated version whenever possible Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
943bb775d9
commit
59edcdc537
5 changed files with 12 additions and 18 deletions
|
|
@ -1967,7 +1967,7 @@ class Manager implements IManager {
|
|||
/**
|
||||
* Check if sharing is disabled for the current user
|
||||
*/
|
||||
public function sharingDisabledForUser(string $userId): bool {
|
||||
public function sharingDisabledForUser(?string $userId): bool {
|
||||
return $this->shareDisableChecker->sharingDisabledForUser($userId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,7 @@ class ShareDisableChecker {
|
|||
$this->sharingDisabledForUsersCache = new CappedMemoryCache();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ?string $userId
|
||||
* @return bool
|
||||
*/
|
||||
public function sharingDisabledForUser(?string $userId) {
|
||||
public function sharingDisabledForUser(?string $userId): bool {
|
||||
if ($userId === null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ use OCP\ILogger;
|
|||
use OCP\ISession;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUser;
|
||||
use OCP\Server;
|
||||
use OCP\ServerVersion;
|
||||
use OCP\Session\Exceptions\SessionNotAvailableException;
|
||||
use OCP\Share\IManager as IShareManager;
|
||||
|
|
@ -161,6 +162,8 @@ class JSConfigHelper {
|
|||
'enable_non-accessible_features' => $this->config->getSystemValueBool('enable_non-accessible_features', true),
|
||||
];
|
||||
|
||||
$shareManager = Server::get(IShareManager::class);
|
||||
|
||||
$array = [
|
||||
'_oc_debug' => $this->config->getSystemValue('debug', false) ? 'true' : 'false',
|
||||
'_oc_isadmin' => $uid !== null && $this->groupManager->isAdmin($uid) ? 'true' : 'false',
|
||||
|
|
@ -235,11 +238,11 @@ class JSConfigHelper {
|
|||
'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
|
||||
'enforcePasswordForPublicLink' => Util::isPublicLinkPasswordRequired(),
|
||||
'enableLinkPasswordByDefault' => $enableLinkPasswordByDefault,
|
||||
'sharingDisabledForUser' => Util::isSharingDisabledForUser(),
|
||||
'sharingDisabledForUser' => $shareManager->sharingDisabledForUser($uid),
|
||||
'resharingAllowed' => Share::isResharingAllowed(),
|
||||
'remoteShareAllowed' => $outgoingServer2serverShareEnabled,
|
||||
'federatedCloudShareDoc' => $this->urlGenerator->linkToDocs('user-sharing-federated'),
|
||||
'allowGroupSharing' => \OC::$server->get(IShareManager::class)->allowGroupSharing(),
|
||||
'allowGroupSharing' => $shareManager->allowGroupSharing(),
|
||||
'defaultInternalExpireDateEnabled' => $defaultInternalExpireDateEnabled,
|
||||
'defaultInternalExpireDate' => $defaultInternalExpireDate,
|
||||
'defaultInternalExpireDateEnforced' => $defaultInternalExpireDateEnforced,
|
||||
|
|
|
|||
|
|
@ -485,10 +485,9 @@ interface IManager {
|
|||
/**
|
||||
* Check if sharing is disabled for the given user
|
||||
*
|
||||
* @return bool
|
||||
* @since 9.0.0
|
||||
*/
|
||||
public function sharingDisabledForUser(string $userId);
|
||||
public function sharingDisabledForUser(?string $userId): bool;
|
||||
|
||||
/**
|
||||
* Check if outgoing server2server shares are allowed
|
||||
|
|
|
|||
|
|
@ -78,19 +78,16 @@ class Util {
|
|||
*
|
||||
* @return boolean
|
||||
* @since 7.0.0
|
||||
* @deprecated 9.1.0 Use \OC::$server->get(\OCP\Share\IManager::class)->sharingDisabledForUser
|
||||
* @deprecated 9.1.0 Use Server::get(\OCP\Share\IManager::class)->sharingDisabledForUser
|
||||
*/
|
||||
public static function isSharingDisabledForUser() {
|
||||
if (self::$shareManager === null) {
|
||||
self::$shareManager = \OC::$server->get(IManager::class);
|
||||
self::$shareManager = Server::get(IManager::class);
|
||||
}
|
||||
|
||||
$user = \OC::$server->getUserSession()->getUser();
|
||||
if ($user !== null) {
|
||||
$user = $user->getUID();
|
||||
}
|
||||
$user = Server::get(\OCP\IUserSession::class)->getUser();
|
||||
|
||||
return self::$shareManager->sharingDisabledForUser($user);
|
||||
return self::$shareManager->sharingDisabledForUser($user?->getUID());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue