summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/ajax/userautocomplete.php
blob: 83fdc3bdf4daaae1ab9fd7bdc0a64618cde9f31a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
//$RUNTIME_NOAPPS = true;

 

OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('files_sharing');

$users = array();
$groups = array();
$self = OCP\USER::getUser();
$userGroups = OC_Group::getUserGroups($self);
$users[] = "<optgroup label='Users'>";
$groups[] = "<optgroup label='Groups'>";
foreach ($userGroups as $group) {
	$groupUsers = OC_Group::usersInGroup($group);
	foreach ($groupUsers as $user) {
		if ($user != $self) {
			$users[] = "<option value='".$user."'>".$user."</option>";
		}
	}
	$groups[] = "<option value='".$group."'>".$group."</option>";
}
$users[] = "</optgroup>";
$groups[] = "</optgroup>";
$users = array_merge($users, $groups);
OC_JSON::encodedPrint($users);

?>