nextcloud/apps/files_sharing/ajax/userautocomplete.php

32 lines
820 B
PHP
Raw Normal View History

2011-07-24 23:47:37 +04:00
<?php
2012-05-03 14:23:29 +04:00
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('files_sharing');
2011-07-24 23:47:37 +04:00
$users = array();
$groups = array();
2012-05-01 20:50:31 +04: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 23:47:37 +04: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 23:47:37 +04:00
}
$users[] = "</optgroup>";
$groups[] = "</optgroup>";
$users = array_merge($users, $groups);
2012-05-03 14:23:29 +04:00
OCP\JSON::encodedPrint($users);
2011-07-24 23:47:37 +04:00
?>