summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_sharing/ajax/share.php4
-rw-r--r--apps/files_sharing/ajax/userautocomplete.php15
-rw-r--r--apps/files_sharing/appinfo/app.php2
-rw-r--r--apps/files_sharing/js/share.js35
4 files changed, 35 insertions, 21 deletions
diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php
index 0de899a0e1d..10a235e4323 100644
--- a/apps/files_sharing/ajax/share.php
+++ b/apps/files_sharing/ajax/share.php
@@ -8,9 +8,7 @@ $sources = explode(";", $_POST['sources']);
$uid_shared_with = $_POST['uid_shared_with'];
$permissions = $_POST['permissions'];
foreach ($sources as $source) {
- foreach ($uid_shared_with as $uid) {
- new OC_Share($source, $uid, $permissions);
- }
+ new OC_Share($source, $uid_shared_with, $permissions);
}
?> \ No newline at end of file
diff --git a/apps/files_sharing/ajax/userautocomplete.php b/apps/files_sharing/ajax/userautocomplete.php
index 816e01ba9ee..c6519cc6b50 100644
--- a/apps/files_sharing/ajax/userautocomplete.php
+++ b/apps/files_sharing/ajax/userautocomplete.php
@@ -7,23 +7,22 @@ if (!OC_User::isLoggedIn()) {
echo json_encode(array("status" => "error", "data" => array("message" => "Authentication error")));
exit();
}
-$query = $_GET['term'];
-$length = strlen($query);
-$query = strtolower($query);
$users = array();
$ocusers = OC_User::getUsers();
$self = OC_User::getUser();
$groups = OC_GROUP::getUserGroups($self);
+$users[] = "<optgroup label='Users'>";
foreach ($ocusers as $user) {
- if ($user != $self && substr(strtolower($user), 0, $length) == $query) {
- $users[] = (object)array('id' => $user, 'label' => $user, 'name' => $user);
+ if ($user != $self) {
+ $users[] = "<option value='".$user."'>".$user."</option>";
}
}
+$users[] = "</optgroup>";
+$users[] = "<optgroup label='Groups'>";
foreach ($groups as $group) {
- if (substr(strtolower($group), 0, $length) == $query) {
- $users[] = (object)array('id' => $group, 'label' => $group, 'name' => $group);
- }
+ $users[] = "<option value='".$group."'>".$group."</option>";
}
+$users[] = "</optgroup>";
echo json_encode($users);
?>
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index 7f7aebb2b24..0587ce550e8 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -5,7 +5,9 @@ require_once('apps/files_sharing/sharedstorage.php');
OC_Filesystem::registerStorageType("shared", "OC_Filestorage_Shared", array("datadir"=>"string"));
OC_Util::addScript("files_sharing", "share");
+OC_Util::addScript("3rdparty", "chosen/chosen.jquery.min");
OC_Util::addStyle( 'files_sharing', 'sharing' );
+OC_Util::addStyle("3rdparty", "chosen/chosen");
OC_App::addNavigationSubEntry("files_index", array(
"id" => "files_sharing_list",
"order" => 10,
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index d6cf45bf44f..f914f8da175 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -28,17 +28,21 @@ $(document).ready(function() {
}
createShareDropdown(filenames, files);
});
- $('#uid_shared_with').live('keyup', function() {
- $(this).autocomplete({
- source: OC.linkTo('files_sharing','ajax/userautocomplete.php')
- });
- $('.ui-autocomplete').click(function(event) {
- event.stopPropagation();
+ $('#uid_shared_with').live('change', function() {
+ var source = $('#dropdown').data('file');
+ var uid_shared_with = $(this).val();
+ var permissions = 0;
+ var data = 'sources='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with)+'&permissions='+encodeURIComponent(permissions);
+ $.ajax({
+ type: 'POST',
+ url: OC.linkTo('files_sharing','ajax/share.php'),
+ cache: false,
+ data: data
});
});
$('.permissions').live('change', function() {
var permissions;
- if (this.checked) {
+ if ($(this).checked) {
permissions = 1;
} else {
permissions = 0;
@@ -111,7 +115,9 @@ $(document).ready(function() {
function createShareDropdown(filenames, files) {
var html = "<div id='dropdown' data-file='"+files+"'>";
html += "<div id='private'>";
- html += "<input placeholder='User or Group' id='uid_shared_with' />";
+ html += "<select data-placeholder='User or Group' style='width:220px;' id='uid_shared_with' class='chzen-select'>";
+ html += "<option value=''></option>";
+ html += "</select>";
html += "<div id='shared_list'></div>";
html += "</div>";
html += "<div id='public'>";
@@ -122,7 +128,15 @@ function createShareDropdown(filenames, files) {
html += "</div>";
$('tr[data-file="'+filenames+'"]').addClass('mouseOver');
$(html).appendTo($('tr[data-file="'+filenames+'"] td.filename'));
- $.getJSON(OC.linkTo('files_sharing','ajax/getitem.php'), { source: files }, function(users) {
+ $.getJSON(OC.linkTo('files_sharing', 'ajax/userautocomplete.php'), function(users) {
+ if (users) {
+ $.each(users, function(index, row) {
+ $(row).appendTo('#uid_shared_with');
+ });
+ $('#uid_shared_with').trigger('liszt:updated');
+ }
+ });
+ $.getJSON(OC.linkTo('files_sharing', 'ajax/getitem.php'), { source: files }, function(users) {
if (users) {
var list = "<ul>";
$.each(users, function(index, row) {
@@ -146,7 +160,7 @@ function createShareDropdown(filenames, files) {
$(list).appendTo('#shared_list');
}
});
- $.getJSON(OC.linkTo('files_publiclink','ajax/getlink.php'), { path: files }, function(token) {
+ $.getJSON(OC.linkTo('files_publiclink', 'ajax/getlink.php'), { path: files }, function(token) {
if (token) {
$('#makelink').attr('checked', true);
$('#link').data('token', token);
@@ -155,4 +169,5 @@ function createShareDropdown(filenames, files) {
}
});
$('#dropdown').show('blind');
+ $('#uid_shared_with').chosen();
}