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