Merge pull request #12200 from nextcloud/tech-debt/noid/cleanup-legacy-sharing
Cleanup some unused sharing methods from the old sharing code
This commit is contained in:
commit
337cd25187
3 changed files with 14 additions and 22 deletions
|
@ -32,6 +32,7 @@ use OCP\Constants;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\Settings\ISettings;
|
use OCP\Settings\ISettings;
|
||||||
|
use OCP\Share\IManager;
|
||||||
use OCP\Util;
|
use OCP\Util;
|
||||||
|
|
||||||
class Sharing implements ISettings {
|
class Sharing implements ISettings {
|
||||||
|
@ -41,12 +42,16 @@ class Sharing implements ISettings {
|
||||||
/** @var IL10N */
|
/** @var IL10N */
|
||||||
private $l;
|
private $l;
|
||||||
|
|
||||||
|
/** @var IManager */
|
||||||
|
private $shareManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IConfig $config
|
* @param IConfig $config
|
||||||
*/
|
*/
|
||||||
public function __construct(IConfig $config, IL10N $l) {
|
public function __construct(IConfig $config, IL10N $l, IManager $shareManager) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->l = $l;
|
$this->l = $l;
|
||||||
|
$this->shareManager = $shareManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +70,7 @@ class Sharing implements ISettings {
|
||||||
'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'),
|
'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'),
|
||||||
'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'),
|
'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'),
|
||||||
'enforceLinkPassword' => Util::isPublicLinkPasswordRequired(),
|
'enforceLinkPassword' => Util::isPublicLinkPasswordRequired(),
|
||||||
'onlyShareWithGroupMembers' => Share::shareWithGroupMembersOnly(),
|
'onlyShareWithGroupMembers' => $this->shareManager->shareWithGroupMembersOnly(),
|
||||||
'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'),
|
'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'),
|
||||||
'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'),
|
'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'),
|
||||||
'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'),
|
'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'),
|
||||||
|
|
|
@ -341,7 +341,7 @@ class Share extends Constants {
|
||||||
}
|
}
|
||||||
|
|
||||||
$uidOwner = \OC_User::getUser();
|
$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)) {
|
if (is_null($itemSourceName)) {
|
||||||
$itemSourceName = $itemSource;
|
$itemSourceName = $itemSource;
|
||||||
|
@ -2054,15 +2054,6 @@ class Share extends Constants {
|
||||||
return ($result['success'] && ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200));
|
return ($result['success'] && ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@ -2103,15 +2094,6 @@ class Share extends Constants {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
* @param string $password
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
|
|
|
@ -28,6 +28,7 @@ use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\Constants;
|
use OCP\Constants;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
|
use OCP\Share\IManager;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class SharingTest extends TestCase {
|
class SharingTest extends TestCase {
|
||||||
|
@ -37,15 +38,19 @@ class SharingTest extends TestCase {
|
||||||
private $config;
|
private $config;
|
||||||
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
private $l10n;
|
private $l10n;
|
||||||
|
/** @var IManager|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
|
private $shareManager;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
|
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
|
||||||
$this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
|
$this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
|
||||||
|
$this->shareManager = $this->getMockBuilder(IManager::class)->getMock();
|
||||||
|
|
||||||
$this->admin = new Sharing(
|
$this->admin = new Sharing(
|
||||||
$this->config,
|
$this->config,
|
||||||
$this->l10n
|
$this->l10n,
|
||||||
|
$this->shareManager
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue