allow excluding groups from creating link shares
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
b1dca57a1c
commit
0e6321957d
|
@ -1,5 +1,5 @@
|
|||
window.addEventListener('DOMContentLoaded', function(){
|
||||
$('#excludedGroups').each(function (index, element) {
|
||||
$('#excludedGroups,#linksExcludedGroups').each(function (index, element) {
|
||||
OC.Settings.setupGroupsSelect($(element));
|
||||
$(element).change(function(ev) {
|
||||
var groups = ev.val || [];
|
||||
|
|
|
@ -64,11 +64,15 @@ class Sharing implements ISettings {
|
|||
$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
|
||||
$excludeGroupsList = !is_null(json_decode($excludedGroups))
|
||||
? implode('|', json_decode($excludedGroups, true)) : '';
|
||||
$linksExcludedGroups = $this->config->getAppValue('core', 'shareapi_allow_links_exclude_groups', '');
|
||||
$linksExcludeGroupsList = !is_null(json_decode($linksExcludedGroups))
|
||||
? implode('|', json_decode($linksExcludedGroups, true)) : '';
|
||||
|
||||
$parameters = [
|
||||
// Built-In Sharing
|
||||
'allowGroupSharing' => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'),
|
||||
'allowLinks' => $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'),
|
||||
'allowLinksExcludeGroups' => $linksExcludeGroupsList,
|
||||
'allowPublicUpload' => $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'),
|
||||
'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'),
|
||||
'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'),
|
||||
|
|
|
@ -138,6 +138,14 @@
|
|||
<p class="<?php if ($_['shareAPIEnabled'] === 'no') {
|
||||
p('hidden');
|
||||
}?>">
|
||||
<p class="indent">
|
||||
<?php p($l->t('Exclude groups from creating link shares:'));?>
|
||||
</p>
|
||||
<p id="selectLinksExcludedGroups" class="indent <?php if ($_['allowLinks'] === 'no') {
|
||||
p('hidden');
|
||||
} ?>">
|
||||
<input name="shareapi_allow_links_exclude_groups" type="hidden" id="linksExcludedGroups" value="<?php p($_['allowLinksExcludeGroups']) ?>" style="width: 400px" class="noJSAutoUpdate"/>
|
||||
</p>
|
||||
<input type="checkbox" name="shareapi_allow_resharing" id="allowResharing" class="checkbox"
|
||||
value="1" <?php if ($_['allowResharing'] === 'yes') {
|
||||
print_unescaped('checked="checked"');
|
||||
|
|
|
@ -1234,7 +1234,8 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
$c->get(IMailer::class),
|
||||
$c->get(IURLGenerator::class),
|
||||
$c->get('ThemingDefaults'),
|
||||
$c->get(IEventDispatcher::class)
|
||||
$c->get(IEventDispatcher::class),
|
||||
$c->get(IUserSession::class)
|
||||
);
|
||||
|
||||
return $manager;
|
||||
|
|
|
@ -57,6 +57,7 @@ use OCP\ILogger;
|
|||
use OCP\IURLGenerator;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\Mail\IMailer;
|
||||
use OCP\Security\Events\ValidatePasswordPolicyEvent;
|
||||
|
@ -104,8 +105,6 @@ class Manager implements IManager {
|
|||
private $sharingDisabledForUsersCache;
|
||||
/** @var EventDispatcherInterface */
|
||||
private $legacyDispatcher;
|
||||
/** @var LegacyHooks */
|
||||
private $legacyHooks;
|
||||
/** @var IMailer */
|
||||
private $mailer;
|
||||
/** @var IURLGenerator */
|
||||
|
@ -114,27 +113,8 @@ class Manager implements IManager {
|
|||
private $defaults;
|
||||
/** @var IEventDispatcher */
|
||||
private $dispatcher;
|
||||
private $userSession;
|
||||
|
||||
|
||||
/**
|
||||
* Manager constructor.
|
||||
*
|
||||
* @param ILogger $logger
|
||||
* @param IConfig $config
|
||||
* @param ISecureRandom $secureRandom
|
||||
* @param IHasher $hasher
|
||||
* @param IMountManager $mountManager
|
||||
* @param IGroupManager $groupManager
|
||||
* @param IL10N $l
|
||||
* @param IFactory $l10nFactory
|
||||
* @param IProviderFactory $factory
|
||||
* @param IUserManager $userManager
|
||||
* @param IRootFolder $rootFolder
|
||||
* @param EventDispatcherInterface $eventDispatcher
|
||||
* @param IMailer $mailer
|
||||
* @param IURLGenerator $urlGenerator
|
||||
* @param \OC_Defaults $defaults
|
||||
*/
|
||||
public function __construct(
|
||||
ILogger $logger,
|
||||
IConfig $config,
|
||||
|
@ -151,7 +131,8 @@ class Manager implements IManager {
|
|||
IMailer $mailer,
|
||||
IURLGenerator $urlGenerator,
|
||||
\OC_Defaults $defaults,
|
||||
IEventDispatcher $dispatcher
|
||||
IEventDispatcher $dispatcher,
|
||||
IUserSession $userSession
|
||||
) {
|
||||
$this->logger = $logger;
|
||||
$this->config = $config;
|
||||
|
@ -166,11 +147,11 @@ class Manager implements IManager {
|
|||
$this->rootFolder = $rootFolder;
|
||||
$this->legacyDispatcher = $legacyDispatcher;
|
||||
$this->sharingDisabledForUsersCache = new CappedMemoryCache();
|
||||
$this->legacyHooks = new LegacyHooks($this->legacyDispatcher);
|
||||
$this->mailer = $mailer;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->defaults = $defaults;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->userSession = $userSession;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -919,7 +900,7 @@ class Manager implements IManager {
|
|||
'%1$s via %2$s',
|
||||
[
|
||||
$initiatorDisplayName,
|
||||
$instanceName
|
||||
$instanceName,
|
||||
]
|
||||
);
|
||||
$message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]);
|
||||
|
@ -1756,7 +1737,20 @@ class Manager implements IManager {
|
|||
* @return bool
|
||||
*/
|
||||
public function shareApiAllowLinks() {
|
||||
return $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes';
|
||||
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = $this->userSession->getUser();
|
||||
if ($user) {
|
||||
$excludedGroups = json_decode($this->config->getAppValue('core', 'shareapi_allow_links_exclude_groups', '[]'));
|
||||
if ($excludedGroups) {
|
||||
$userGroups = $this->groupManager->getUserGroupIds($user);
|
||||
return !(bool)array_intersect($excludedGroups, $userGroups);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1780,6 +1774,7 @@ class Manager implements IManager {
|
|||
/**
|
||||
* Is default link expire date enforced
|
||||
*`
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shareApiLinkDefaultExpireDateEnforced() {
|
||||
|
@ -1790,6 +1785,7 @@ class Manager implements IManager {
|
|||
|
||||
/**
|
||||
* Number of default link expire days
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function shareApiLinkDefaultExpireDays() {
|
||||
|
@ -1836,6 +1832,7 @@ class Manager implements IManager {
|
|||
|
||||
/**
|
||||
* Number of default expire days
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function shareApiInternalDefaultExpireDays(): int {
|
||||
|
@ -1844,6 +1841,7 @@ class Manager implements IManager {
|
|||
|
||||
/**
|
||||
* Number of default expire days for remote shares
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function shareApiRemoteDefaultExpireDays(): int {
|
||||
|
@ -1861,6 +1859,7 @@ class Manager implements IManager {
|
|||
|
||||
/**
|
||||
* check if user can only share with group members
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shareWithGroupMembersOnly() {
|
||||
|
@ -1869,6 +1868,7 @@ class Manager implements IManager {
|
|||
|
||||
/**
|
||||
* Check if users can share with groups
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function allowGroupSharing() {
|
||||
|
|
Loading…
Reference in New Issue