server/apps/files_sharing/ajax/userautocomplete.php

31 lines
847 B
PHP
Raw Normal View History

2011-07-24 19:47:37 +00:00
<?php
2012-05-03 10:23:29 +00:00
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('files_sharing');
2011-07-24 19:47:37 +00:00
$users = array();
$groups = array();
2012-05-01 16:50:31 +00:00
$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);
$userCount = 0;
foreach ($groupUsers as $user) {
if ($user != $self) {
$users[] = "<option value='".$user."'>".$user."</option>";
$userCount++;
}
2011-07-24 19:47:37 +00:00
}
// Don't include the group if only the current user is a member of it
if ($userCount > 0) {
$groups[] = "<option value='".$group."(group)'>".$group." (group) </option>";
}
2011-07-24 19:47:37 +00:00
}
$users = array_unique($users);
$users[] = "</optgroup>";
$groups[] = "</optgroup>";
$users = array_merge($users, $groups);
2012-05-03 10:23:29 +00:00
OCP\JSON::encodedPrint($users);