diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-30 15:30:21 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-30 15:30:21 -0400 |
commit | ed71343df8a3d35c2a0fe7d6c91778278f8d7dd1 (patch) | |
tree | 6826dee6a69b67718f8cf811a0211cd49574ba55 /core/ajax/share.php | |
parent | 98c020d954f6a8dac93c5e93309807c7a66456eb (diff) | |
download | nextcloud-server-ed71343df8a3d35c2a0fe7d6c91778278f8d7dd1.tar.gz nextcloud-server-ed71343df8a3d35c2a0fe7d6c91778278f8d7dd1.zip |
Autocomplete for share with search in sharing dropdown
Diffstat (limited to 'core/ajax/share.php')
-rw-r--r-- | core/ajax/share.php | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php index 4c5ef310b7f..41c9e80fd75 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -49,21 +49,34 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['item'] } break; } -} else if (isset($_GET['fetch']) && isset($_GET['itemType'])) { +} else if (isset($_GET['fetch'])) { switch ($_GET['fetch']) { case 'getItemsSharedStatuses': - $return = OCP\Share::getItemsShared($_GET['itemType'], OCP\Share::FORMAT_STATUSES); - ($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error(); + if (isset($_GET['itemType'])) { + $return = OCP\Share::getItemsShared($_GET['itemType'], OCP\Share::FORMAT_STATUSES); + ($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error(); + } break; case 'getItem': // TODO Check if the item was shared to the current user - if (isset($_GET['item'])) { + if (isset($_GET['itemType']) && isset($_GET['item'])) { $return = OCP\Share::getItemShared($_GET['itemType'], $_GET['item']); ($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error(); } break; case 'getShareWith': - // TODO Autocomplete for all users, groups, etc. + if (isset($_GET['search'])) { + $shareWith = array(); + $users = OC_User::getUsers(); + foreach ($users as $user) { + $shareWith[] = array('label' => $user, 'value' => array('shareType' => OCP\Share::SHARE_TYPE_USER, 'shareWith' => $user)); + } + $groups = OC_Group::getGroups(); + foreach ($groups as $group) { + $shareWith[] = array('label' => $group.' (group)', 'value' => array('shareType' => OCP\Share::SHARE_TYPE_GROUP, 'shareWith' => $group)); + } + OC_JSON::success(array('data' => $shareWith)); + } break; } } |