Some code improvements
Signed-off-by: Tobia De Koninck <tobia@ledfan.be>
This commit is contained in:
parent
d2d6ed5c97
commit
3409c364fe
|
@ -81,7 +81,7 @@ class ContactsStore {
|
||||||
* 1. filter the current user
|
* 1. filter the current user
|
||||||
* 2. if the `shareapi_exclude_groups` config option is enabled and the
|
* 2. if the `shareapi_exclude_groups` config option is enabled and the
|
||||||
* current user is in an excluded group it will filter all local users.
|
* current user is in an excluded group it will filter all local users.
|
||||||
* 3. if the ``shareapi_only_share_with_group_members config option is
|
* 3. if the `shareapi_only_share_with_group_members` config option is
|
||||||
* enabled it will filter all users which doens't have a common group
|
* enabled it will filter all users which doens't have a common group
|
||||||
* with the current user.
|
* with the current user.
|
||||||
* @param IUser $self
|
* @param IUser $self
|
||||||
|
@ -89,16 +89,17 @@ class ContactsStore {
|
||||||
* @return array the filtered contacts
|
* @return array the filtered contacts
|
||||||
*/
|
*/
|
||||||
private function filterContacts(IUser $self, Array $entries) {
|
private function filterContacts(IUser $self, Array $entries) {
|
||||||
$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false;
|
$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes';
|
||||||
|
|
||||||
$skipLocal = false; // whether to filter out local users
|
$skipLocal = false; // whether to filter out local users
|
||||||
$ownGroupsOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes' ? true : false; // whether to filter out all users which doesn't have the same group as the current user
|
$ownGroupsOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no'); // whether to filter out all users which doesn't have the same group as the current user
|
||||||
|
|
||||||
$selfGroups = $this->groupManager->getUserGroupIds($self);
|
$selfGroups = $this->groupManager->getUserGroupIds($self);
|
||||||
|
|
||||||
if ($excludedGroups) {
|
if ($excludedGroups) {
|
||||||
$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
|
$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
|
||||||
$excludeGroupsList = !is_null(json_decode($excludedGroups)) ? json_decode($excludedGroups, true) : [];
|
$decodedExcludeGroups = json_decode($excludedGroups, true);
|
||||||
|
$excludeGroupsList = !is_null($decodedExcludeGroups) ? $decodedExcludeGroups : [];
|
||||||
|
|
||||||
if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) {
|
if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) {
|
||||||
// a group of the current user is excluded -> filter all local users
|
// a group of the current user is excluded -> filter all local users
|
||||||
|
|
Loading…
Reference in New Issue