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-09-24 00:22:59 +04:00
|
|
|
|
2011-07-24 23:47:37 +04:00
|
|
|
$users = array();
|
2012-03-29 05:18:17 +04:00
|
|
|
$groups = array();
|
2012-05-01 20:50:31 +04:00
|
|
|
$self = OCP\USER::getUser();
|
2012-03-29 05:18:17 +04:00
|
|
|
$userGroups = OC_Group::getUserGroups($self);
|
2011-08-09 18:34:00 +04:00
|
|
|
$users[] = "<optgroup label='Users'>";
|
2012-03-29 05:18:17 +04:00
|
|
|
$groups[] = "<optgroup label='Groups'>";
|
|
|
|
foreach ($userGroups as $group) {
|
|
|
|
$groupUsers = OC_Group::usersInGroup($group);
|
2012-05-05 22:56:52 +04:00
|
|
|
$userCount = 0;
|
2012-03-29 05:18:17 +04:00
|
|
|
foreach ($groupUsers as $user) {
|
|
|
|
if ($user != $self) {
|
|
|
|
$users[] = "<option value='".$user."'>".$user."</option>";
|
2012-05-05 22:56:52 +04:00
|
|
|
$userCount++;
|
2012-03-29 05:18:17 +04:00
|
|
|
}
|
2011-07-24 23:47:37 +04:00
|
|
|
}
|
2012-05-05 22:56:52 +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
|
|
|
}
|
2012-05-09 13:35:36 +04:00
|
|
|
$users = array_unique($users);
|
2011-08-09 18:34:00 +04:00
|
|
|
$users[] = "</optgroup>";
|
2012-03-29 05:18:17 +04:00
|
|
|
$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
|
|
|
|
|
|
|
?>
|