Skip to content

Commit

Permalink
adjust ContactStore class
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisfritsche committed Oct 2, 2020
1 parent d77d52d commit 0244d55
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
12 changes: 12 additions & 0 deletions apps/settings/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ window.addEventListener('DOMContentLoaded', function(){
});
});

$('#globalScopedGroups').each(function (index, element) {
OC.Settings.setupGroupsSelect($(element));
$(element).change(function(ev) {
var groups = ev.val || [];
groups = JSON.stringify(groups);
OCP.AppConfig.setValue('core', $(this).attr('name'), groups);
});
});

$('#loglevel').change(function(){
$.post(OC.generateUrl('/settings/admin/log/level'), {level: $(this).val()},function(){
Expand Down Expand Up @@ -252,6 +260,10 @@ window.addEventListener('DOMContentLoaded', function(){
$("#selectExcludedGroups").toggleClass('hidden', !this.checked);
});

$('#onlyShareWithGroupMembers').change(function() {
$("#selectGlobalScopedGroups").toggleClass('hidden', !this.checked);
});

var setupChecks = function () {
// run setup checks then gather error messages
$.when(
Expand Down
1 change: 1 addition & 0 deletions apps/settings/l10n/de_DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ OC.L10N.register(
"Allow sharing with groups" : "Teilen mit Gruppen erlauben",
"Restrict users to only share with users in their groups" : "Benutzer auf das Teilen innerhalb ihrer Gruppen beschränken",
"Exclude groups from sharing" : "Gruppen von Freigaben ausschließen",
"Add exceptions: Groups that can always receive shares." : "Ausnahmen hinzufügen: Gruppen die immer Freigaben empfangen können.",
"These groups will still be able to receive shares, but not to initiate them." : "Diese Gruppen können weiterhin Freigaben empfangen, aber selbst keine mehr initiieren.",
"Allow username autocompletion in share dialog (if this is disabled the full username or email address needs to be entered)" : "Die Auto-Vervollständigung von Benutzernamen im Teilen-Dialog zulassen (Wenn dies deaktiviert ist, müssen der vollständige Benutzername oder die E-Mail-Adresse eingegeben werden)",
"Restrict username autocompletion to users within the same groups" : "Automatische Vervollständigung der Benutzernamen auf Benutzer innerhalb der gleichen Gruppen beschränken",
Expand Down
3 changes: 2 additions & 1 deletion apps/settings/l10n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@
"Allow sharing with groups" : "Teilen mit Gruppen erlauben",
"Restrict users to only share with users in their groups" : "Benutzer auf das Teilen innerhalb ihrer Gruppen beschränken",
"Exclude groups from sharing" : "Gruppen von Freigaben ausschließen",
"Add exceptions: Groups that can always receive shares." : "Ausnahmen hinzufügen: Gruppen die immer Freigaben empfangen können.",
"These groups will still be able to receive shares, but not to initiate them." : "Diese Gruppen können weiterhin Freigaben empfangen, aber selbst keine mehr initiieren.",
"Allow username autocompletion in share dialog (if this is disabled the full username or email address needs to be entered)" : "Die Auto-Vervollständigung von Benutzernamen im Teilen-Dialog zulassen (Wenn dies deaktiviert ist, müssen der vollständige Benutzername oder die E-Mail-Adresse eingegeben werden)",
"Restrict username autocompletion to users within the same groups" : "Automatische Vervollständigung der Benutzernamen auf Benutzer innerhalb der gleichen Gruppen beschränken",
Expand Down Expand Up @@ -884,4 +885,4 @@
"Show image" : "Bild anzeigen",
"Show file" : "Datei anzeigen"
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}
}
5 changes: 5 additions & 0 deletions apps/settings/lib/Settings/Admin/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public function getForm() {
$excludeGroupsList = !is_null(json_decode($excludedGroups))
? implode('|', json_decode($excludedGroups, true)) : '';

$globalScopedGroups = $this->config->getAppValue('core', 'shareapi_global_scoped_group_list', '');
$globalScopedGroupList = !is_null(json_decode($globalScopedGroups))
? implode('|', json_decode($globalScopedGroups, true)) : '';

$parameters = [
// Built-In Sharing
'allowGroupSharing' => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'),
Expand All @@ -81,6 +85,7 @@ public function getForm() {
'shareEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'),
'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes',
'shareExcludedGroupsList' => $excludeGroupsList,
'shareGlobalScopedGroupList' => $globalScopedGroupList,
'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null),
'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'),
'shareApiDefaultPermissions' => $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL),
Expand Down
7 changes: 7 additions & 0 deletions apps/settings/templates/settings/admin/sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@
} ?> />
<label for="onlyShareWithGroupMembers"><?php p($l->t('Restrict users to only share with users in their groups'));?></label><br/>
</p>
<p id="selectGlobalScopedGroups" class="indent <?php if (!$_['onlyShareWithGroupMembers'] || $_['shareAPIEnabled'] === 'no') {
p('hidden');
} ?>">
<input name="shareapi_global_scoped_group_list" type="hidden" id="globalScopedGroups" value="<?php p($_['shareGlobalScopedGroupList']) ?>" style="width: 400px" class="noJSAutoUpdate"/>
<br />
<em><?php p($l->t('Add exceptions: Groups that can always receive shares.')); ?></em>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') {
p('hidden');
}?>">
Expand Down
9 changes: 8 additions & 1 deletion lib/private/Contacts/ContactsMenu/ContactsStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function getContacts(IUser $user, $filter, ?int $limit = null, ?int $offs
* current user is in an excluded group it will filter all local users.
* 4. if the `shareapi_only_share_with_group_members` config option is
* enabled it will filter all users which doens't have a common group
* with the current user.
* with the current user, considering exceptions (global scoped groups)
*
* @param IUser $self
* @param Entry[] $entries
Expand All @@ -132,6 +132,13 @@ private function filterContacts(IUser $self,

$selfGroups = $this->groupManager->getUserGroupIds($self);

// check for existing global scoped groups to include them into selfGroups
$globalScopedGroupList = $this->config->getAppValue('core', 'shareapi_global_scoped_group_list', '');
$globalScopedGroups = json_decode($globalScopedGroupList);
if (!is_null($globalScopedGroups)) {
$selfGroups = array_merge($selfGroups, $globalScopedGroups);
}

if ($excludedGroups) {
$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
$decodedExcludeGroups = json_decode($excludedGroups, true);
Expand Down

0 comments on commit 0244d55

Please sign in to comment.