Use chosen select form for selecting users in sharing drop down
This commit is contained in:
parent
23c8d7b3fb
commit
cdf2dbcd52
|
@ -8,9 +8,7 @@ $sources = explode(";", $_POST['sources']);
|
||||||
$uid_shared_with = $_POST['uid_shared_with'];
|
$uid_shared_with = $_POST['uid_shared_with'];
|
||||||
$permissions = $_POST['permissions'];
|
$permissions = $_POST['permissions'];
|
||||||
foreach ($sources as $source) {
|
foreach ($sources as $source) {
|
||||||
foreach ($uid_shared_with as $uid) {
|
new OC_Share($source, $uid_shared_with, $permissions);
|
||||||
new OC_Share($source, $uid, $permissions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -7,23 +7,22 @@ if (!OC_User::isLoggedIn()) {
|
||||||
echo json_encode(array("status" => "error", "data" => array("message" => "Authentication error")));
|
echo json_encode(array("status" => "error", "data" => array("message" => "Authentication error")));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
$query = $_GET['term'];
|
|
||||||
$length = strlen($query);
|
|
||||||
$query = strtolower($query);
|
|
||||||
$users = array();
|
$users = array();
|
||||||
$ocusers = OC_User::getUsers();
|
$ocusers = OC_User::getUsers();
|
||||||
$self = OC_User::getUser();
|
$self = OC_User::getUser();
|
||||||
$groups = OC_GROUP::getUserGroups($self);
|
$groups = OC_GROUP::getUserGroups($self);
|
||||||
|
$users[] = "<optgroup label='Users'>";
|
||||||
foreach ($ocusers as $user) {
|
foreach ($ocusers as $user) {
|
||||||
if ($user != $self && substr(strtolower($user), 0, $length) == $query) {
|
if ($user != $self) {
|
||||||
$users[] = (object)array('id' => $user, 'label' => $user, 'name' => $user);
|
$users[] = "<option value='".$user."'>".$user."</option>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$users[] = "</optgroup>";
|
||||||
|
$users[] = "<optgroup label='Groups'>";
|
||||||
foreach ($groups as $group) {
|
foreach ($groups as $group) {
|
||||||
if (substr(strtolower($group), 0, $length) == $query) {
|
$users[] = "<option value='".$group."'>".$group."</option>";
|
||||||
$users[] = (object)array('id' => $group, 'label' => $group, 'name' => $group);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$users[] = "</optgroup>";
|
||||||
echo json_encode($users);
|
echo json_encode($users);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -5,7 +5,9 @@ require_once('apps/files_sharing/sharedstorage.php');
|
||||||
|
|
||||||
OC_Filesystem::registerStorageType("shared", "OC_Filestorage_Shared", array("datadir"=>"string"));
|
OC_Filesystem::registerStorageType("shared", "OC_Filestorage_Shared", array("datadir"=>"string"));
|
||||||
OC_Util::addScript("files_sharing", "share");
|
OC_Util::addScript("files_sharing", "share");
|
||||||
|
OC_Util::addScript("3rdparty", "chosen/chosen.jquery.min");
|
||||||
OC_Util::addStyle( 'files_sharing', 'sharing' );
|
OC_Util::addStyle( 'files_sharing', 'sharing' );
|
||||||
|
OC_Util::addStyle("3rdparty", "chosen/chosen");
|
||||||
OC_App::addNavigationSubEntry("files_index", array(
|
OC_App::addNavigationSubEntry("files_index", array(
|
||||||
"id" => "files_sharing_list",
|
"id" => "files_sharing_list",
|
||||||
"order" => 10,
|
"order" => 10,
|
||||||
|
|
|
@ -28,17 +28,21 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
createShareDropdown(filenames, files);
|
createShareDropdown(filenames, files);
|
||||||
});
|
});
|
||||||
$('#uid_shared_with').live('keyup', function() {
|
$('#uid_shared_with').live('change', function() {
|
||||||
$(this).autocomplete({
|
var source = $('#dropdown').data('file');
|
||||||
source: OC.linkTo('files_sharing','ajax/userautocomplete.php')
|
var uid_shared_with = $(this).val();
|
||||||
});
|
var permissions = 0;
|
||||||
$('.ui-autocomplete').click(function(event) {
|
var data = 'sources='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with)+'&permissions='+encodeURIComponent(permissions);
|
||||||
event.stopPropagation();
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: OC.linkTo('files_sharing','ajax/share.php'),
|
||||||
|
cache: false,
|
||||||
|
data: data
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$('.permissions').live('change', function() {
|
$('.permissions').live('change', function() {
|
||||||
var permissions;
|
var permissions;
|
||||||
if (this.checked) {
|
if ($(this).checked) {
|
||||||
permissions = 1;
|
permissions = 1;
|
||||||
} else {
|
} else {
|
||||||
permissions = 0;
|
permissions = 0;
|
||||||
|
@ -111,7 +115,9 @@ $(document).ready(function() {
|
||||||
function createShareDropdown(filenames, files) {
|
function createShareDropdown(filenames, files) {
|
||||||
var html = "<div id='dropdown' data-file='"+files+"'>";
|
var html = "<div id='dropdown' data-file='"+files+"'>";
|
||||||
html += "<div id='private'>";
|
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 id='shared_list'></div>";
|
||||||
html += "</div>";
|
html += "</div>";
|
||||||
html += "<div id='public'>";
|
html += "<div id='public'>";
|
||||||
|
@ -122,7 +128,15 @@ function createShareDropdown(filenames, files) {
|
||||||
html += "</div>";
|
html += "</div>";
|
||||||
$('tr[data-file="'+filenames+'"]').addClass('mouseOver');
|
$('tr[data-file="'+filenames+'"]').addClass('mouseOver');
|
||||||
$(html).appendTo($('tr[data-file="'+filenames+'"] td.filename'));
|
$(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) {
|
if (users) {
|
||||||
var list = "<ul>";
|
var list = "<ul>";
|
||||||
$.each(users, function(index, row) {
|
$.each(users, function(index, row) {
|
||||||
|
@ -146,7 +160,7 @@ function createShareDropdown(filenames, files) {
|
||||||
$(list).appendTo('#shared_list');
|
$(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) {
|
if (token) {
|
||||||
$('#makelink').attr('checked', true);
|
$('#makelink').attr('checked', true);
|
||||||
$('#link').data('token', token);
|
$('#link').data('token', token);
|
||||||
|
@ -155,4 +169,5 @@ function createShareDropdown(filenames, files) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#dropdown').show('blind');
|
$('#dropdown').show('blind');
|
||||||
|
$('#uid_shared_with').chosen();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue