Merge pull request #7363 from nextcloud/default-share-perms
Let the admin configure the default share permissions
This commit is contained in:
commit
7bc3c2e057
17 changed files with 244 additions and 64 deletions
|
@ -23,6 +23,7 @@
|
||||||
namespace OCA\Files_Sharing;
|
namespace OCA\Files_Sharing;
|
||||||
|
|
||||||
use OCP\Capabilities\ICapability;
|
use OCP\Capabilities\ICapability;
|
||||||
|
use OCP\Constants;
|
||||||
use \OCP\IConfig;
|
use \OCP\IConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,6 +87,7 @@ class Capabilities implements ICapability {
|
||||||
$res['group'] = [];
|
$res['group'] = [];
|
||||||
$res['group']['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes';
|
$res['group']['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes';
|
||||||
$res['group']['expire_date']['enabled'] = true;
|
$res['group']['expire_date']['enabled'] = true;
|
||||||
|
$res['default_permissions'] = (int)$this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Federated sharing
|
//Federated sharing
|
||||||
|
|
|
@ -35,8 +35,10 @@ use OCP\AppFramework\OCS\OCSException;
|
||||||
use OCP\AppFramework\OCS\OCSForbiddenException;
|
use OCP\AppFramework\OCS\OCSForbiddenException;
|
||||||
use OCP\AppFramework\OCS\OCSNotFoundException;
|
use OCP\AppFramework\OCS\OCSNotFoundException;
|
||||||
use OCP\AppFramework\OCSController;
|
use OCP\AppFramework\OCSController;
|
||||||
|
use OCP\Constants;
|
||||||
use OCP\Files\Node;
|
use OCP\Files\Node;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
|
use OCP\IConfig;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
|
@ -75,6 +77,8 @@ class ShareAPIController extends OCSController {
|
||||||
private $l;
|
private $l;
|
||||||
/** @var \OCP\Files\Node */
|
/** @var \OCP\Files\Node */
|
||||||
private $lockedNode;
|
private $lockedNode;
|
||||||
|
/** @var IConfig */
|
||||||
|
private $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Share20OCS constructor.
|
* Share20OCS constructor.
|
||||||
|
@ -88,6 +92,7 @@ class ShareAPIController extends OCSController {
|
||||||
* @param IURLGenerator $urlGenerator
|
* @param IURLGenerator $urlGenerator
|
||||||
* @param string $userId
|
* @param string $userId
|
||||||
* @param IL10N $l10n
|
* @param IL10N $l10n
|
||||||
|
* @param IConfig $config
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$appName,
|
$appName,
|
||||||
|
@ -98,7 +103,8 @@ class ShareAPIController extends OCSController {
|
||||||
IRootFolder $rootFolder,
|
IRootFolder $rootFolder,
|
||||||
IURLGenerator $urlGenerator,
|
IURLGenerator $urlGenerator,
|
||||||
$userId,
|
$userId,
|
||||||
IL10N $l10n
|
IL10N $l10n,
|
||||||
|
IConfig $config
|
||||||
) {
|
) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
|
|
||||||
|
@ -110,6 +116,7 @@ class ShareAPIController extends OCSController {
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->urlGenerator = $urlGenerator;
|
||||||
$this->currentUser = $userId;
|
$this->currentUser = $userId;
|
||||||
$this->l = $l10n;
|
$this->l = $l10n;
|
||||||
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -318,7 +325,7 @@ class ShareAPIController extends OCSController {
|
||||||
*/
|
*/
|
||||||
public function createShare(
|
public function createShare(
|
||||||
$path = null,
|
$path = null,
|
||||||
$permissions = \OCP\Constants::PERMISSION_ALL,
|
$permissions = null,
|
||||||
$shareType = -1,
|
$shareType = -1,
|
||||||
$shareWith = null,
|
$shareWith = null,
|
||||||
$publicUpload = 'false',
|
$publicUpload = 'false',
|
||||||
|
@ -327,6 +334,10 @@ class ShareAPIController extends OCSController {
|
||||||
) {
|
) {
|
||||||
$share = $this->shareManager->newShare();
|
$share = $this->shareManager->newShare();
|
||||||
|
|
||||||
|
if ($permissions === null) {
|
||||||
|
$permissions = $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
// Verify path
|
// Verify path
|
||||||
if ($path === null) {
|
if ($path === null) {
|
||||||
throw new OCSNotFoundException($this->l->t('Please specify a file or folder path'));
|
throw new OCSNotFoundException($this->l->t('Please specify a file or folder path'));
|
||||||
|
@ -347,17 +358,17 @@ class ShareAPIController extends OCSController {
|
||||||
throw new OCSNotFoundException($this->l->t('Could not create share'));
|
throw new OCSNotFoundException($this->l->t('Could not create share'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($permissions < 0 || $permissions > \OCP\Constants::PERMISSION_ALL) {
|
if ($permissions < 0 || $permissions > Constants::PERMISSION_ALL) {
|
||||||
throw new OCSNotFoundException($this->l->t('invalid permissions'));
|
throw new OCSNotFoundException($this->l->t('invalid permissions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shares always require read permissions
|
// Shares always require read permissions
|
||||||
$permissions |= \OCP\Constants::PERMISSION_READ;
|
$permissions |= Constants::PERMISSION_READ;
|
||||||
|
|
||||||
if ($path instanceof \OCP\Files\File) {
|
if ($path instanceof \OCP\Files\File) {
|
||||||
// Single file shares should never have delete or create permissions
|
// Single file shares should never have delete or create permissions
|
||||||
$permissions &= ~\OCP\Constants::PERMISSION_DELETE;
|
$permissions &= ~Constants::PERMISSION_DELETE;
|
||||||
$permissions &= ~\OCP\Constants::PERMISSION_CREATE;
|
$permissions &= ~Constants::PERMISSION_CREATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -414,13 +425,13 @@ class ShareAPIController extends OCSController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$share->setPermissions(
|
$share->setPermissions(
|
||||||
\OCP\Constants::PERMISSION_READ |
|
Constants::PERMISSION_READ |
|
||||||
\OCP\Constants::PERMISSION_CREATE |
|
Constants::PERMISSION_CREATE |
|
||||||
\OCP\Constants::PERMISSION_UPDATE |
|
Constants::PERMISSION_UPDATE |
|
||||||
\OCP\Constants::PERMISSION_DELETE
|
Constants::PERMISSION_DELETE
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$share->setPermissions(\OCP\Constants::PERMISSION_READ);
|
$share->setPermissions(Constants::PERMISSION_READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set password
|
// Set password
|
||||||
|
@ -447,13 +458,9 @@ class ShareAPIController extends OCSController {
|
||||||
$share->setPermissions($permissions);
|
$share->setPermissions($permissions);
|
||||||
} else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
|
} else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
|
||||||
if ($share->getNodeType() === 'file') {
|
if ($share->getNodeType() === 'file') {
|
||||||
$share->setPermissions(\OCP\Constants::PERMISSION_READ);
|
$share->setPermissions(Constants::PERMISSION_READ);
|
||||||
} else {
|
} else {
|
||||||
$share->setPermissions(
|
$share->setPermissions($permissions);
|
||||||
\OCP\Constants::PERMISSION_READ |
|
|
||||||
\OCP\Constants::PERMISSION_CREATE |
|
|
||||||
\OCP\Constants::PERMISSION_UPDATE |
|
|
||||||
\OCP\Constants::PERMISSION_DELETE);
|
|
||||||
}
|
}
|
||||||
$share->setSharedWith($shareWith);
|
$share->setSharedWith($shareWith);
|
||||||
} else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) {
|
} else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) {
|
||||||
|
@ -698,23 +705,23 @@ class ShareAPIController extends OCSController {
|
||||||
|
|
||||||
$newPermissions = null;
|
$newPermissions = null;
|
||||||
if ($publicUpload === 'true') {
|
if ($publicUpload === 'true') {
|
||||||
$newPermissions = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE;
|
$newPermissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE;
|
||||||
} else if ($publicUpload === 'false') {
|
} else if ($publicUpload === 'false') {
|
||||||
$newPermissions = \OCP\Constants::PERMISSION_READ;
|
$newPermissions = Constants::PERMISSION_READ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($permissions !== null) {
|
if ($permissions !== null) {
|
||||||
$newPermissions = (int)$permissions;
|
$newPermissions = (int)$permissions;
|
||||||
$newPermissions = $newPermissions & ~\OCP\Constants::PERMISSION_SHARE;
|
$newPermissions = $newPermissions & ~Constants::PERMISSION_SHARE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($newPermissions !== null &&
|
if ($newPermissions !== null &&
|
||||||
!in_array($newPermissions, [
|
!in_array($newPermissions, [
|
||||||
\OCP\Constants::PERMISSION_READ,
|
Constants::PERMISSION_READ,
|
||||||
\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE, // legacy
|
Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE, // legacy
|
||||||
\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE, // correct
|
Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE, // correct
|
||||||
\OCP\Constants::PERMISSION_CREATE, // hidden file list
|
Constants::PERMISSION_CREATE, // hidden file list
|
||||||
\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, // allow to edit single files
|
Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE, // allow to edit single files
|
||||||
])
|
])
|
||||||
) {
|
) {
|
||||||
throw new OCSBadRequestException($this->l->t('Can\'t change permissions for public share links'));
|
throw new OCSBadRequestException($this->l->t('Can\'t change permissions for public share links'));
|
||||||
|
@ -722,9 +729,9 @@ class ShareAPIController extends OCSController {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
// legacy
|
// legacy
|
||||||
$newPermissions === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE) ||
|
$newPermissions === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE) ||
|
||||||
// correct
|
// correct
|
||||||
$newPermissions === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE)
|
$newPermissions === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE)
|
||||||
) {
|
) {
|
||||||
if (!$this->shareManager->shareApiLinkAllowPublicUpload()) {
|
if (!$this->shareManager->shareApiLinkAllowPublicUpload()) {
|
||||||
throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
|
throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
|
||||||
|
@ -735,7 +742,7 @@ class ShareAPIController extends OCSController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// normalize to correct public upload permissions
|
// normalize to correct public upload permissions
|
||||||
$newPermissions = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE;
|
$newPermissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($newPermissions !== null) {
|
if ($newPermissions !== null) {
|
||||||
|
|
|
@ -37,6 +37,7 @@ use OCP\AppFramework\OCS\OCSBadRequestException;
|
||||||
use OCP\AppFramework\OCS\OCSException;
|
use OCP\AppFramework\OCS\OCSException;
|
||||||
use OCP\AppFramework\OCS\OCSForbiddenException;
|
use OCP\AppFramework\OCS\OCSForbiddenException;
|
||||||
use OCP\AppFramework\OCS\OCSNotFoundException;
|
use OCP\AppFramework\OCS\OCSNotFoundException;
|
||||||
|
use OCP\IConfig;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
|
||||||
|
@ -105,6 +106,7 @@ class ApiTest extends TestCase {
|
||||||
->will($this->returnCallback(function($text, $parameters = []) {
|
->will($this->returnCallback(function($text, $parameters = []) {
|
||||||
return vsprintf($text, $parameters);
|
return vsprintf($text, $parameters);
|
||||||
}));
|
}));
|
||||||
|
$config = $this->createMock(IConfig::class);
|
||||||
|
|
||||||
return new ShareAPIController(
|
return new ShareAPIController(
|
||||||
self::APP_NAME,
|
self::APP_NAME,
|
||||||
|
@ -115,7 +117,8 @@ class ApiTest extends TestCase {
|
||||||
\OC::$server->getRootFolder(),
|
\OC::$server->getRootFolder(),
|
||||||
\OC::$server->getURLGenerator(),
|
\OC::$server->getURLGenerator(),
|
||||||
$userId,
|
$userId,
|
||||||
$l
|
$l,
|
||||||
|
$config
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ use OCP\AppFramework\OCS\OCSNotFoundException;
|
||||||
use OCP\Files\File;
|
use OCP\Files\File;
|
||||||
use OCP\Files\Folder;
|
use OCP\Files\Folder;
|
||||||
use OCP\Files\Storage;
|
use OCP\Files\Storage;
|
||||||
|
use OCP\IConfig;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCA\Files_Sharing\Controller\ShareAPIController;
|
use OCA\Files_Sharing\Controller\ShareAPIController;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
|
@ -84,6 +85,9 @@ class ShareAPIControllerTest extends TestCase {
|
||||||
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
private $l;
|
private $l;
|
||||||
|
|
||||||
|
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
|
private $config;
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
$this->shareManager = $this->createMock(IManager::class);
|
$this->shareManager = $this->createMock(IManager::class);
|
||||||
$this->shareManager
|
$this->shareManager
|
||||||
|
@ -102,6 +106,7 @@ class ShareAPIControllerTest extends TestCase {
|
||||||
->will($this->returnCallback(function($text, $parameters = []) {
|
->will($this->returnCallback(function($text, $parameters = []) {
|
||||||
return vsprintf($text, $parameters);
|
return vsprintf($text, $parameters);
|
||||||
}));
|
}));
|
||||||
|
$this->config = $this->createMock(IConfig::class);
|
||||||
|
|
||||||
$this->ocs = new ShareAPIController(
|
$this->ocs = new ShareAPIController(
|
||||||
$this->appName,
|
$this->appName,
|
||||||
|
@ -112,7 +117,8 @@ class ShareAPIControllerTest extends TestCase {
|
||||||
$this->rootFolder,
|
$this->rootFolder,
|
||||||
$this->urlGenerator,
|
$this->urlGenerator,
|
||||||
$this->currentUser,
|
$this->currentUser,
|
||||||
$this->l
|
$this->l,
|
||||||
|
$this->config
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +137,7 @@ class ShareAPIControllerTest extends TestCase {
|
||||||
$this->urlGenerator,
|
$this->urlGenerator,
|
||||||
$this->currentUser,
|
$this->currentUser,
|
||||||
$this->l,
|
$this->l,
|
||||||
|
$this->config
|
||||||
])->setMethods(['formatShare'])
|
])->setMethods(['formatShare'])
|
||||||
->getMock();
|
->getMock();
|
||||||
}
|
}
|
||||||
|
@ -439,6 +446,7 @@ class ShareAPIControllerTest extends TestCase {
|
||||||
$this->urlGenerator,
|
$this->urlGenerator,
|
||||||
$this->currentUser,
|
$this->currentUser,
|
||||||
$this->l,
|
$this->l,
|
||||||
|
$this->config
|
||||||
])->setMethods(['canAccessShare'])
|
])->setMethods(['canAccessShare'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
@ -707,6 +715,7 @@ class ShareAPIControllerTest extends TestCase {
|
||||||
$this->urlGenerator,
|
$this->urlGenerator,
|
||||||
$this->currentUser,
|
$this->currentUser,
|
||||||
$this->l,
|
$this->l,
|
||||||
|
$this->config
|
||||||
])->setMethods(['formatShare'])
|
])->setMethods(['formatShare'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
@ -804,6 +813,7 @@ class ShareAPIControllerTest extends TestCase {
|
||||||
$this->urlGenerator,
|
$this->urlGenerator,
|
||||||
$this->currentUser,
|
$this->currentUser,
|
||||||
$this->l,
|
$this->l,
|
||||||
|
$this->config
|
||||||
])->setMethods(['formatShare'])
|
])->setMethods(['formatShare'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
@ -1119,6 +1129,7 @@ class ShareAPIControllerTest extends TestCase {
|
||||||
$this->urlGenerator,
|
$this->urlGenerator,
|
||||||
$this->currentUser,
|
$this->currentUser,
|
||||||
$this->l,
|
$this->l,
|
||||||
|
$this->config
|
||||||
])->setMethods(['formatShare'])
|
])->setMethods(['formatShare'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
namespace OC\Core\Controller;
|
namespace OC\Core\Controller;
|
||||||
|
|
||||||
use bantu\IniGetWrapper\IniGetWrapper;
|
use bantu\IniGetWrapper\IniGetWrapper;
|
||||||
|
use OC\CapabilitiesManager;
|
||||||
use OC\Template\JSConfigHelper;
|
use OC\Template\JSConfigHelper;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
|
@ -59,6 +60,7 @@ class OCJSController extends Controller {
|
||||||
* @param IGroupManager $groupManager
|
* @param IGroupManager $groupManager
|
||||||
* @param IniGetWrapper $iniWrapper
|
* @param IniGetWrapper $iniWrapper
|
||||||
* @param IURLGenerator $urlGenerator
|
* @param IURLGenerator $urlGenerator
|
||||||
|
* @param CapabilitiesManager $capabilitiesManager
|
||||||
*/
|
*/
|
||||||
public function __construct($appName,
|
public function __construct($appName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
|
@ -70,7 +72,8 @@ class OCJSController extends Controller {
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
IGroupManager $groupManager,
|
IGroupManager $groupManager,
|
||||||
IniGetWrapper $iniWrapper,
|
IniGetWrapper $iniWrapper,
|
||||||
IURLGenerator $urlGenerator) {
|
IURLGenerator $urlGenerator,
|
||||||
|
CapabilitiesManager $capabilitiesManager) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
|
|
||||||
$this->helper = new JSConfigHelper(
|
$this->helper = new JSConfigHelper(
|
||||||
|
@ -82,7 +85,8 @@ class OCJSController extends Controller {
|
||||||
$config,
|
$config,
|
||||||
$groupManager,
|
$groupManager,
|
||||||
$iniWrapper,
|
$iniWrapper,
|
||||||
$urlGenerator
|
$urlGenerator,
|
||||||
|
$capabilitiesManager
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,13 @@ var OCP = {},
|
||||||
*/
|
*/
|
||||||
webroot:oc_webroot,
|
webroot:oc_webroot,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capabilities
|
||||||
|
*
|
||||||
|
* @type array
|
||||||
|
*/
|
||||||
|
_capabilities: window.oc_capabilities || null,
|
||||||
|
|
||||||
appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
|
appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
|
||||||
/**
|
/**
|
||||||
* Currently logged in user or null if none
|
* Currently logged in user or null if none
|
||||||
|
@ -308,6 +315,18 @@ var OCP = {},
|
||||||
return OC.webroot;
|
return OC.webroot;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the capabilities
|
||||||
|
*
|
||||||
|
* @return {array} capabilities
|
||||||
|
*
|
||||||
|
* @since 14.0
|
||||||
|
*/
|
||||||
|
getCapabilities: function() {
|
||||||
|
return OC._capabilities;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the currently logged in user or null if there is no logged in
|
* Returns the currently logged in user or null if there is no logged in
|
||||||
* user (public page mode)
|
* user (public page mode)
|
||||||
|
|
|
@ -158,23 +158,24 @@
|
||||||
var shareType = attributes.shareType;
|
var shareType = attributes.shareType;
|
||||||
attributes = _.extend({}, attributes);
|
attributes = _.extend({}, attributes);
|
||||||
|
|
||||||
// Default permissions are Edit (CRUD) and Share
|
// get default permissions
|
||||||
// Check if these permissions are possible
|
var defaultPermissions = OC.getCapabilities()['files_sharing']['default_permissions'] || OC.PERMISSION_ALL;
|
||||||
var permissions = OC.PERMISSION_READ;
|
var possiblePermissions = OC.PERMISSION_READ;
|
||||||
|
|
||||||
if (this.updatePermissionPossible()) {
|
if (this.updatePermissionPossible()) {
|
||||||
permissions = permissions | OC.PERMISSION_UPDATE;
|
possiblePermissions = possiblePermissions | OC.PERMISSION_UPDATE;
|
||||||
}
|
}
|
||||||
if (this.createPermissionPossible()) {
|
if (this.createPermissionPossible()) {
|
||||||
permissions = permissions | OC.PERMISSION_CREATE;
|
possiblePermissions = possiblePermissions | OC.PERMISSION_CREATE;
|
||||||
}
|
}
|
||||||
if (this.deletePermissionPossible()) {
|
if (this.deletePermissionPossible()) {
|
||||||
permissions = permissions | OC.PERMISSION_DELETE;
|
possiblePermissions = possiblePermissions | OC.PERMISSION_DELETE;
|
||||||
}
|
}
|
||||||
if (this.configModel.get('isResharingAllowed') && (this.sharePermissionPossible())) {
|
if (this.configModel.get('isResharingAllowed') && (this.sharePermissionPossible())) {
|
||||||
permissions = permissions | OC.PERMISSION_SHARE;
|
possiblePermissions = possiblePermissions | OC.PERMISSION_SHARE;
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes.permissions = permissions;
|
attributes.permissions = defaultPermissions & possiblePermissions;
|
||||||
if (_.isUndefined(attributes.path)) {
|
if (_.isUndefined(attributes.path)) {
|
||||||
attributes.path = this.fileInfoModel.getFullPath();
|
attributes.path = this.fileInfoModel.getFullPath();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ describe('OC.Share.ShareItemModel', function() {
|
||||||
var fetchSharesDeferred, fetchReshareDeferred;
|
var fetchSharesDeferred, fetchReshareDeferred;
|
||||||
var fileInfoModel, configModel, model;
|
var fileInfoModel, configModel, model;
|
||||||
var oldCurrentUser;
|
var oldCurrentUser;
|
||||||
|
var capsSpec;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
oldCurrentUser = OC.currentUser;
|
oldCurrentUser = OC.currentUser;
|
||||||
|
@ -56,8 +57,15 @@ describe('OC.Share.ShareItemModel', function() {
|
||||||
configModel: configModel,
|
configModel: configModel,
|
||||||
fileInfoModel: fileInfoModel
|
fileInfoModel: fileInfoModel
|
||||||
});
|
});
|
||||||
|
capsSpec = sinon.stub(OC, 'getCapabilities');
|
||||||
|
capsSpec.returns({
|
||||||
|
'files_sharing': {
|
||||||
|
'default_permissions': OC.PERMISSION_ALL
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
|
capsSpec.restore();
|
||||||
if (fetchSharesStub) {
|
if (fetchSharesStub) {
|
||||||
fetchSharesStub.restore();
|
fetchSharesStub.restore();
|
||||||
}
|
}
|
||||||
|
@ -527,7 +535,22 @@ describe('OC.Share.ShareItemModel', function() {
|
||||||
});
|
});
|
||||||
expect(
|
expect(
|
||||||
testWithPermissions(OC.PERMISSION_UPDATE | OC.PERMISSION_SHARE)
|
testWithPermissions(OC.PERMISSION_UPDATE | OC.PERMISSION_SHARE)
|
||||||
).toEqual(OC.PERMISSION_READ | OC.PERMISSION_UPDATE | OC.PERMISSION_UPDATE);
|
).toEqual(OC.PERMISSION_READ | OC.PERMISSION_UPDATE);
|
||||||
|
});
|
||||||
|
it('uses default permissions from capabilities', function() {
|
||||||
|
capsSpec.returns({
|
||||||
|
'files_sharing': {
|
||||||
|
'default_permissions': OC.PERMISSION_READ | OC.PERMISSION_CREATE | OC.PERMISSION_SHARE
|
||||||
|
}
|
||||||
|
});
|
||||||
|
configModel.set('isResharingAllowed', true);
|
||||||
|
model.set({
|
||||||
|
reshare: {},
|
||||||
|
shares: []
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
testWithPermissions(OC.PERMISSION_ALL)
|
||||||
|
).toEqual(OC.PERMISSION_READ | OC.PERMISSION_CREATE | OC.PERMISSION_SHARE);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,7 +28,9 @@ namespace OC\Settings\Admin;
|
||||||
|
|
||||||
use OC\Share\Share;
|
use OC\Share\Share;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
use OCP\Constants;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
use OCP\IL10N;
|
||||||
use OCP\Settings\ISettings;
|
use OCP\Settings\ISettings;
|
||||||
use OCP\Util;
|
use OCP\Util;
|
||||||
|
|
||||||
|
@ -36,11 +38,15 @@ class Sharing implements ISettings {
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
|
/** @var IL10N */
|
||||||
|
private $l;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IConfig $config
|
* @param IConfig $config
|
||||||
*/
|
*/
|
||||||
public function __construct(IConfig $config) {
|
public function __construct(IConfig $config, IL10N $l) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
$this->l = $l;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,26 +59,58 @@ class Sharing implements ISettings {
|
||||||
|
|
||||||
$parameters = [
|
$parameters = [
|
||||||
// Built-In Sharing
|
// Built-In Sharing
|
||||||
'allowGroupSharing' => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'),
|
'allowGroupSharing' => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'),
|
||||||
'allowLinks' => $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'),
|
'allowLinks' => $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'),
|
||||||
'allowPublicUpload' => $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'),
|
'allowPublicUpload' => $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'),
|
||||||
'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' => Share::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'),
|
||||||
'shareEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'),
|
'shareEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'),
|
||||||
'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes',
|
'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes',
|
||||||
'shareExcludedGroupsList' => $excludeGroupsList,
|
'shareExcludedGroupsList' => $excludeGroupsList,
|
||||||
'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null),
|
'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null),
|
||||||
'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'),
|
'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'),
|
||||||
|
'shareApiDefaultPermissions' => $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL),
|
||||||
|
'shareApiDefaultPermissionsCheckboxes' => $this->getSharePermissionList(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return new TemplateResponse('settings', 'settings/admin/sharing', $parameters, '');
|
return new TemplateResponse('settings', 'settings/admin/sharing', $parameters, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get share permission list for template
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getSharePermissionList() {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'id' => 'cancreate',
|
||||||
|
'label' => $this->l->t('Create'),
|
||||||
|
'value' => Constants::PERMISSION_CREATE
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 'canupdate',
|
||||||
|
'label' => $this->l->t('Change'),
|
||||||
|
'value' => Constants::PERMISSION_UPDATE
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 'candelete',
|
||||||
|
'label' => $this->l->t('Delete'),
|
||||||
|
'value' => Constants::PERMISSION_DELETE
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 'canshare',
|
||||||
|
'label' => $this->l->t('Share'),
|
||||||
|
'value' => Constants::PERMISSION_SHARE
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string the section ID, e.g. 'sharing'
|
* @return string the section ID, e.g. 'sharing'
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -271,7 +271,7 @@ class Manager implements IManager {
|
||||||
}
|
}
|
||||||
if ($section === 'sharing') {
|
if ($section === 'sharing') {
|
||||||
/** @var ISettings $form */
|
/** @var ISettings $form */
|
||||||
$form = new Admin\Sharing($this->config);
|
$form = new Admin\Sharing($this->config, $this->l);
|
||||||
$forms[$form->getPriority()] = [$form];
|
$forms[$form->getPriority()] = [$form];
|
||||||
}
|
}
|
||||||
if ($section === 'additional') {
|
if ($section === 'additional') {
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
namespace OC\Template;
|
namespace OC\Template;
|
||||||
|
|
||||||
use bantu\IniGetWrapper\IniGetWrapper;
|
use bantu\IniGetWrapper\IniGetWrapper;
|
||||||
|
use OC\CapabilitiesManager;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\Defaults;
|
use OCP\Defaults;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
@ -66,6 +67,9 @@ class JSConfigHelper {
|
||||||
/** @var IURLGenerator */
|
/** @var IURLGenerator */
|
||||||
private $urlGenerator;
|
private $urlGenerator;
|
||||||
|
|
||||||
|
/** @var CapabilitiesManager */
|
||||||
|
private $capabilitiesManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IL10N $l
|
* @param IL10N $l
|
||||||
* @param Defaults $defaults
|
* @param Defaults $defaults
|
||||||
|
@ -76,6 +80,7 @@ class JSConfigHelper {
|
||||||
* @param IGroupManager $groupManager
|
* @param IGroupManager $groupManager
|
||||||
* @param IniGetWrapper $iniWrapper
|
* @param IniGetWrapper $iniWrapper
|
||||||
* @param IURLGenerator $urlGenerator
|
* @param IURLGenerator $urlGenerator
|
||||||
|
* @param CapabilitiesManager $capabilitiesManager
|
||||||
*/
|
*/
|
||||||
public function __construct(IL10N $l,
|
public function __construct(IL10N $l,
|
||||||
Defaults $defaults,
|
Defaults $defaults,
|
||||||
|
@ -85,7 +90,8 @@ class JSConfigHelper {
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
IGroupManager $groupManager,
|
IGroupManager $groupManager,
|
||||||
IniGetWrapper $iniWrapper,
|
IniGetWrapper $iniWrapper,
|
||||||
IURLGenerator $urlGenerator) {
|
IURLGenerator $urlGenerator,
|
||||||
|
CapabilitiesManager $capabilitiesManager) {
|
||||||
$this->l = $l;
|
$this->l = $l;
|
||||||
$this->defaults = $defaults;
|
$this->defaults = $defaults;
|
||||||
$this->appManager = $appManager;
|
$this->appManager = $appManager;
|
||||||
|
@ -95,6 +101,7 @@ class JSConfigHelper {
|
||||||
$this->groupManager = $groupManager;
|
$this->groupManager = $groupManager;
|
||||||
$this->iniWrapper = $iniWrapper;
|
$this->iniWrapper = $iniWrapper;
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->urlGenerator = $urlGenerator;
|
||||||
|
$this->capabilitiesManager = $capabilitiesManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfig() {
|
public function getConfig() {
|
||||||
|
@ -146,6 +153,8 @@ class JSConfigHelper {
|
||||||
$lastConfirmTimestamp = 0;
|
$lastConfirmTimestamp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$capabilities = $this->capabilitiesManager->getCapabilities();
|
||||||
|
|
||||||
$array = [
|
$array = [
|
||||||
"oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false',
|
"oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false',
|
||||||
"oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false',
|
"oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false',
|
||||||
|
@ -252,6 +261,7 @@ class JSConfigHelper {
|
||||||
'longFooter' => $this->defaults->getLongFooter(),
|
'longFooter' => $this->defaults->getLongFooter(),
|
||||||
'folder' => \OC_Util::getTheme(),
|
'folder' => \OC_Util::getTheme(),
|
||||||
]),
|
]),
|
||||||
|
"oc_capabilities" => json_encode($capabilities),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->currentUser !== null) {
|
if ($this->currentUser !== null) {
|
||||||
|
|
|
@ -160,7 +160,8 @@ class TemplateLayout extends \OC_Template {
|
||||||
$this->config,
|
$this->config,
|
||||||
\OC::$server->getGroupManager(),
|
\OC::$server->getGroupManager(),
|
||||||
\OC::$server->getIniWrapper(),
|
\OC::$server->getIniWrapper(),
|
||||||
\OC::$server->getURLGenerator()
|
\OC::$server->getURLGenerator(),
|
||||||
|
\OC::$server->getCapabilitiesManager()
|
||||||
);
|
);
|
||||||
$this->assign('inline_ocjs', $jsConfigHelper->getConfig());
|
$this->assign('inline_ocjs', $jsConfigHelper->getConfig());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1030,6 +1030,13 @@ table.grid td.date {
|
||||||
.double-indent {
|
.double-indent {
|
||||||
padding-left: 56px;
|
padding-left: 56px;
|
||||||
}
|
}
|
||||||
|
.nocheckbox {
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#shareApiDefaultPermissionsSection label {
|
||||||
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#fileSharingSettings h3 {
|
#fileSharingSettings h3 {
|
||||||
|
|
|
@ -121,6 +121,28 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#shareApiDefaultPermissionsSection input').change(function(ev) {
|
||||||
|
var $el = $('#shareApiDefaultPermissions');
|
||||||
|
var $target = $(ev.target);
|
||||||
|
|
||||||
|
var value = $el.val();
|
||||||
|
if ($target.is(':checked')) {
|
||||||
|
value = value | $target.val();
|
||||||
|
} else {
|
||||||
|
value = value & ~$target.val();
|
||||||
|
}
|
||||||
|
|
||||||
|
// always set read permission
|
||||||
|
value |= OC.PERMISSION_READ;
|
||||||
|
|
||||||
|
// this will trigger the field's change event and will save it
|
||||||
|
$el.val(value).change();
|
||||||
|
|
||||||
|
ev.preventDefault();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
var savePublicShareDisclaimerText = _.debounce(function(value) {
|
var savePublicShareDisclaimerText = _.debounce(function(value) {
|
||||||
var options = {
|
var options = {
|
||||||
success: function() {
|
success: function() {
|
||||||
|
|
|
@ -106,4 +106,15 @@
|
||||||
<br/>
|
<br/>
|
||||||
<textarea placeholder="<?php p($l->t('This text will be shown on the public link upload page when the file list is hidden.')) ?>" id="publicShareDisclaimerText" <?php if ($_['publicShareDisclaimerText'] === null) { print_unescaped('class="hidden"'); } ?>><?php p($_['publicShareDisclaimerText']) ?></textarea>
|
<textarea placeholder="<?php p($l->t('This text will be shown on the public link upload page when the file list is hidden.')) ?>" id="publicShareDisclaimerText" <?php if ($_['publicShareDisclaimerText'] === null) { print_unescaped('class="hidden"'); } ?>><?php p($_['publicShareDisclaimerText']) ?></textarea>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h3><?php p($l->t('Default share permissions'));?></h3>
|
||||||
|
<input type="hidden" name="shareapi_default_permissions" id="shareApiDefaultPermissions" class="checkbox"
|
||||||
|
value="<?php p($_['shareApiDefaultPermissions']) ?>" />
|
||||||
|
<p id="shareApiDefaultPermissionsSection" class="indent <?php if ($_['shareAPIEnabled'] === 'no') p('hidden'); ?>">
|
||||||
|
<?php foreach ($_['shareApiDefaultPermissionsCheckboxes'] as $perm): ?>
|
||||||
|
<input type="checkbox" name="shareapi_default_permission_<?php p($perm['id']) ?>" id="shareapi_default_permission_<?php p($perm['id']) ?>"
|
||||||
|
class="noautosave checkbox" value="<?php p($perm['value']) ?>" <?php if (($_['shareApiDefaultPermissions'] & $perm['value']) !== 0) print_unescaped('checked="checked"'); ?> />
|
||||||
|
<label for="shareapi_default_permission_<?php p($perm['id']) ?>"><?php p($perm['label']);?></label>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -25,7 +25,9 @@ namespace Test\Settings\Admin;
|
||||||
|
|
||||||
use OC\Settings\Admin\Sharing;
|
use OC\Settings\Admin\Sharing;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
use OCP\Constants;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
use OCP\IL10N;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class SharingTest extends TestCase {
|
class SharingTest extends TestCase {
|
||||||
|
@ -33,13 +35,17 @@ class SharingTest extends TestCase {
|
||||||
private $admin;
|
private $admin;
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
private $config;
|
private $config;
|
||||||
|
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
|
private $l10n;
|
||||||
|
|
||||||
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->admin = new Sharing(
|
$this->admin = new Sharing(
|
||||||
$this->config
|
$this->config,
|
||||||
|
$this->l10n
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +115,11 @@ class SharingTest extends TestCase {
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('core', 'shareapi_enable_link_password_by_default', 'no')
|
->with('core', 'shareapi_enable_link_password_by_default', 'no')
|
||||||
->willReturn('yes');
|
->willReturn('yes');
|
||||||
|
$this->config
|
||||||
|
->expects($this->at(13))
|
||||||
|
->method('getAppValue')
|
||||||
|
->with('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL)
|
||||||
|
->willReturn(Constants::PERMISSION_ALL);
|
||||||
|
|
||||||
$expected = new TemplateResponse(
|
$expected = new TemplateResponse(
|
||||||
'settings',
|
'settings',
|
||||||
|
@ -128,7 +139,9 @@ class SharingTest extends TestCase {
|
||||||
'shareExcludeGroups' => false,
|
'shareExcludeGroups' => false,
|
||||||
'shareExcludedGroupsList' => '',
|
'shareExcludedGroupsList' => '',
|
||||||
'publicShareDisclaimerText' => 'Lorem ipsum',
|
'publicShareDisclaimerText' => 'Lorem ipsum',
|
||||||
'enableLinkPasswordByDefault' => 'yes'
|
'enableLinkPasswordByDefault' => 'yes',
|
||||||
|
'shareApiDefaultPermissions' => Constants::PERMISSION_ALL,
|
||||||
|
'shareApiDefaultPermissionsCheckboxes' => $this->invokePrivate($this->admin, 'getSharePermissionList', [])
|
||||||
],
|
],
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
@ -202,6 +215,12 @@ class SharingTest extends TestCase {
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('core', 'shareapi_enable_link_password_by_default', 'no')
|
->with('core', 'shareapi_enable_link_password_by_default', 'no')
|
||||||
->willReturn('yes');
|
->willReturn('yes');
|
||||||
|
$this->config
|
||||||
|
->expects($this->at(13))
|
||||||
|
->method('getAppValue')
|
||||||
|
->with('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL)
|
||||||
|
->willReturn(Constants::PERMISSION_ALL);
|
||||||
|
|
||||||
|
|
||||||
$expected = new TemplateResponse(
|
$expected = new TemplateResponse(
|
||||||
'settings',
|
'settings',
|
||||||
|
@ -221,7 +240,9 @@ class SharingTest extends TestCase {
|
||||||
'shareExcludeGroups' => true,
|
'shareExcludeGroups' => true,
|
||||||
'shareExcludedGroupsList' => 'NoSharers|OtherNoSharers',
|
'shareExcludedGroupsList' => 'NoSharers|OtherNoSharers',
|
||||||
'publicShareDisclaimerText' => 'Lorem ipsum',
|
'publicShareDisclaimerText' => 'Lorem ipsum',
|
||||||
'enableLinkPasswordByDefault' => 'yes'
|
'enableLinkPasswordByDefault' => 'yes',
|
||||||
|
'shareApiDefaultPermissions' => Constants::PERMISSION_ALL,
|
||||||
|
'shareApiDefaultPermissionsCheckboxes' => $this->invokePrivate($this->admin, 'getSharePermissionList', [])
|
||||||
],
|
],
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
|
@ -209,7 +209,7 @@ class ManagerTest extends TestCase {
|
||||||
|
|
||||||
public function testGetAdminSettings() {
|
public function testGetAdminSettings() {
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
0 => [new Sharing($this->config)],
|
0 => [new Sharing($this->config, $this->l10n)],
|
||||||
], $this->manager->getAdminSettings('sharing'));
|
], $this->manager->getAdminSettings('sharing'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue