summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/ajax/userautocomplete.php
blob: 73b5f126984dcd3251fb0fda9f42cdca2ba6bb38 (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;

 

OCP\JSON::checkLoggedIn();
OCP\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);
OCP\JSON::encodedPrint($users);

?>