fixed contactgroups in usersearch

Signed-off-by: dartcafe <github@dartcafe.de>
This commit is contained in:
dartcafe 2021-02-28 21:17:09 +01:00
Родитель b39a24a705
Коммит e13fddd571
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: CCE73CEF3035D3C8
4 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -132,7 +132,7 @@ class Contact extends UserGroupClass {
public static function search(string $query = '', $queryRange = ['FN', 'EMAIL', 'ORG', 'CATEGORIES']): array {
$contacts = [];
foreach (self::listRaw($query, $queryRange) as $contact) {
$contacts[] = new Self($contact['UID']);
$contacts[] = new self($contact['UID']);
}
return $contacts;
}

Просмотреть файл

@ -79,18 +79,18 @@ class ContactGroup extends UserGroupClass {
*/
public static function search(string $query = ''): array {
$contactGroups = [];
$categories = [];
if (self::isEnabled() && $query) {
foreach (self::getContainer()->query(IContactsManager::class)->search($query, ['CATEGORIES']) as $contact) {
// get all groups from the found contact and explode to array
$temp = explode(',', $contact['CATEGORIES']);
foreach ($temp as $contactGroup) {
if (stripos($contactGroup, $query) === 0) {
$contactGroups[] = $contactGroup;
foreach (explode(',', $contact['CATEGORIES']) as $category) {
if (stripos($category, $query) === 0) {
$categories[] = $category;
}
}
}
foreach (array_unique($contactGroups) as $contactGroup) {
foreach (array_unique($categories) as $contactGroup) {
$contactGroups[] = new self($contactGroup);
}
}

Просмотреть файл

@ -72,7 +72,7 @@ class Group extends UserGroupClass {
foreach (self::getContainer()->query(IGroupManager::class)->search($query) as $group) {
if (!in_array($group->getGID(), $skip)) {
$groups[] = new Self($group->getGID());
$groups[] = new self($group->getGID());
}
}
return $groups;

Просмотреть файл

@ -62,7 +62,7 @@ class User extends UserGroupClass {
foreach (self::getContainer()->query(IUserManager::class)->search($query) as $user) {
if (!in_array($user->getUID(), $skip)) {
$users[] = new Self($user->getUID());
$users[] = new self($user->getUID());
}
}
return $users;