Skip to content

Commit 576d828

Browse files
committed
Remove group from excluded_groups_list after delete
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
1 parent 8772a1e commit 576d828

File tree

2 files changed

+80
-67
lines changed

2 files changed

+80
-67
lines changed

apps/settings/js/settings.js

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* This file is licensed under the Affero General Public License version 3 or later.
44
* See the COPYING-README file.
55
*/
6-
OC.Settings = OC.Settings || {};
6+
OC.Settings = OC.Settings || {}
77
OC.Settings = _.extend(OC.Settings, {
88

9-
_cachedGroups: null,
9+
_cachedGroups: null,
1010

11-
/**
11+
/**
1212
* Setup selection box for group selection.
1313
*
1414
* Values need to be separated by a pipe "|" character.
@@ -20,38 +20,38 @@ OC.Settings = _.extend(OC.Settings, {
2020
* @param {Array} [options] extra options
2121
* @param {Array} [options.excludeAdmins=false] flag whether to exclude admin groups
2222
*/
23-
setupGroupsSelect: function($elements, extraOptions, options) {
24-
var self = this;
25-
options = options || {};
26-
if ($elements.length > 0) {
27-
// Let's load the data and THEN init our select
28-
$.ajax({
29-
url: OC.linkToOCS('cloud/groups', 2) + 'details',
30-
dataType: 'json',
31-
success: function(data) {
32-
var results = [];
23+
setupGroupsSelect: function($elements, extraOptions, options) {
24+
const self = this
25+
options = options || {}
26+
if ($elements.length > 0) {
27+
// Let's load the data and THEN init our select
28+
$.ajax({
29+
url: OC.linkToOCS('cloud/groups', 2) + 'details',
30+
dataType: 'json',
31+
success: function(data) {
32+
const results = []
3333

34-
if (data.ocs.data.groups && data.ocs.data.groups.length > 0) {
34+
if (data.ocs.data.groups && data.ocs.data.groups.length > 0) {
3535

36-
data.ocs.data.groups.forEach(function(group) {
37-
if (!options.excludeAdmins || group.id !== 'admin') {
38-
results.push({ id: group.id, displayname: group.displayname });
39-
}
40-
})
36+
data.ocs.data.groups.forEach(function(group) {
37+
if (!options.excludeAdmins || group.id !== 'admin') {
38+
results.push({ id: group.id, displayname: group.displayname })
39+
}
40+
})
4141

42-
// note: settings are saved through a "change" event registered
43-
// on all input fields
44-
$elements.select2(_.extend({
45-
placeholder: t('core', 'Groups'),
46-
allowClear: true,
47-
multiple: true,
48-
toggleSelect: true,
49-
separator: '|',
50-
data: { results: results, text: 'displayname' },
51-
initSelection: function(element, callback) {
52-
var groups = $(element).val();
53-
var selection;
54-
if (groups && results.length > 0) {
42+
// note: settings are saved through a "change" event registered
43+
// on all input fields
44+
$elements.select2(_.extend({
45+
placeholder: t('core', 'Groups'),
46+
allowClear: true,
47+
multiple: true,
48+
toggleSelect: true,
49+
separator: '|',
50+
data: { results: results, text: 'displayname' },
51+
initSelection: function(element, callback) {
52+
const groups = $(element).val()
53+
let selection
54+
if (groups && results.length > 0) {
5555
selection = _.map(_.filter((groups || []).split('|').sort(), function(groupId) {
5656
return results.find(function(group) {
5757
return group.id === groupId
@@ -61,40 +61,40 @@ OC.Settings = _.extend(OC.Settings, {
6161
id: groupId,
6262
displayname: results.find(function(group) {
6363
return group.id === groupId
64-
}).displayname
64+
}).displayname,
6565
}
6666
})
67-
} else if (groups) {
68-
selection = _.map((groups || []).split('|').sort(), function(groupId) {
69-
return {
70-
id: groupId,
71-
displayname: groupId
72-
};
73-
});
74-
}
75-
callback(selection);
76-
},
77-
formatResult: function(element) {
78-
return escapeHTML(element.displayname);
79-
},
80-
formatSelection: function(element) {
81-
return escapeHTML(element.displayname);
82-
},
83-
escapeMarkup: function(m) {
84-
// prevent double markup escape
85-
return m;
86-
}
87-
}, extraOptions || {}));
88-
} else {
89-
OC.Notification.show(t('settings', 'Group list is empty'), { type: 'error' });
90-
console.log(data);
91-
}
92-
},
93-
error: function(data) {
94-
OC.Notification.show(t('settings', 'Unable to retrieve the group list'), { type: 'error' });
95-
console.log(data);
96-
}
97-
});
98-
}
99-
}
100-
});
67+
} else if (groups) {
68+
selection = _.map((groups || []).split('|').sort(), function(groupId) {
69+
return {
70+
id: groupId,
71+
displayname: groupId,
72+
}
73+
})
74+
}
75+
callback(selection)
76+
},
77+
formatResult: function(element) {
78+
return escapeHTML(element.displayname)
79+
},
80+
formatSelection: function(element) {
81+
return escapeHTML(element.displayname)
82+
},
83+
escapeMarkup: function(m) {
84+
// prevent double markup escape
85+
return m
86+
},
87+
}, extraOptions || {}))
88+
} else {
89+
OC.Notification.show(t('settings', 'Group list is empty'), { type: 'error' })
90+
console.log(data)
91+
}
92+
},
93+
error: function(data) {
94+
OC.Notification.show(t('settings', 'Unable to retrieve the group list'), { type: 'error' })
95+
console.log(data)
96+
},
97+
})
98+
}
99+
},
100+
})

lib/private/Share20/Manager.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,19 @@ public function userDeleted($uid) {
15071507
public function groupDeleted($gid) {
15081508
$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP);
15091509
$provider->groupDeleted($gid);
1510+
1511+
$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
1512+
if ($excludedGroups === '') {
1513+
return;
1514+
}
1515+
1516+
$excludedGroups = json_decode($excludedGroups, true);
1517+
if (json_last_error() !== JSON_ERROR_NONE) {
1518+
return;
1519+
}
1520+
1521+
$excludedGroups = array_diff($excludedGroups, [$gid]);
1522+
$this->config->setAppValue('core', 'shareapi_exclude_groups_list', json_encode($excludedGroups));
15101523
}
15111524

15121525
/**

0 commit comments

Comments
 (0)