Full support for viewing public links from sharing drop down
This commit is contained in:
parent
60019278e7
commit
ca86093270
|
@ -7,18 +7,29 @@ require_once('../lib_share.php');
|
||||||
$userDirectory = "/".OC_User::getUser()."/files";
|
$userDirectory = "/".OC_User::getUser()."/files";
|
||||||
$source = $userDirectory.$_GET['source'];
|
$source = $userDirectory.$_GET['source'];
|
||||||
$users = OC_Share::getMySharedItem($source);
|
$users = OC_Share::getMySharedItem($source);
|
||||||
|
$path = $source;
|
||||||
|
for ($i = 0; $i < count($users); $i++) {
|
||||||
|
if ($users[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) {
|
||||||
|
$users[$i]['token'] = OC_Share::getTokenFromSource($source);
|
||||||
|
}
|
||||||
|
}
|
||||||
$source = dirname($source);
|
$source = dirname($source);
|
||||||
while ($source != "" && $source != "/" && $source != "." && $source != $userDirectory) {
|
while ($source != "" && $source != "/" && $source != "." && $source != $userDirectory) {
|
||||||
$values = array_values(OC_Share::getMySharedItem($source));
|
$values = array_values(OC_Share::getMySharedItem($source));
|
||||||
if (count($values) > 0) {
|
if (count($values) > 0) {
|
||||||
$parentUsers = array();
|
$parentUsers = array();
|
||||||
for ($i = 0; $i < count($values); $i++) {
|
for ($i = 0; $i < count($values); $i++) {
|
||||||
|
if ($values[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) {
|
||||||
|
$values[$i]['token'] = OC_Share::getTokenFromSource($source)."&path=".substr($path, strlen($source));
|
||||||
|
}
|
||||||
$parentUsers[basename($source)."-".$i] = $values[$i];
|
$parentUsers[basename($source)."-".$i] = $values[$i];
|
||||||
}
|
}
|
||||||
$users = array_merge($users, $parentUsers);
|
$users = array_merge($users, $parentUsers);
|
||||||
}
|
}
|
||||||
$source = dirname($source);
|
$source = dirname($source);
|
||||||
}
|
}
|
||||||
echo json_encode($users);
|
if (!empty($users)) {
|
||||||
|
echo json_encode($users);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -10,7 +10,7 @@ $(document).ready(function() {
|
||||||
data: 'source='+file,
|
data: 'source='+file,
|
||||||
async: false,
|
async: false,
|
||||||
success: function(users) {
|
success: function(users) {
|
||||||
if (users.length > 0) {
|
if (users) {
|
||||||
icon = OC.imagePath('core', 'actions/shared');
|
icon = OC.imagePath('core', 'actions/shared');
|
||||||
$.each(users, function(index, row) {
|
$.each(users, function(index, row) {
|
||||||
if (row.uid_shared_with == 'public') {
|
if (row.uid_shared_with == 'public') {
|
||||||
|
@ -196,8 +196,7 @@ function createDropdown(filename, files) {
|
||||||
if (users) {
|
if (users) {
|
||||||
$.each(users, function(index, row) {
|
$.each(users, function(index, row) {
|
||||||
if (row.uid_shared_with == 'public') {
|
if (row.uid_shared_with == 'public') {
|
||||||
var token = 1234;
|
showPublicLink(row.token);
|
||||||
showPublicLink(token);
|
|
||||||
} else if (isNaN(index)) {
|
} else if (isNaN(index)) {
|
||||||
addUser(row.uid_shared_with, row.permissions, index.substr(0, index.lastIndexOf('-')));
|
addUser(row.uid_shared_with, row.permissions, index.substr(0, index.lastIndexOf('-')));
|
||||||
} else {
|
} else {
|
||||||
|
@ -228,6 +227,6 @@ function addUser(uid_shared_with, permissions, parentFolder) {
|
||||||
function showPublicLink(token) {
|
function showPublicLink(token) {
|
||||||
$('#makelink').attr('checked', true);
|
$('#makelink').attr('checked', true);
|
||||||
$('#link').data('token', token);
|
$('#link').data('token', token);
|
||||||
$('#link').val(parent.location.protocol+"//"+location.host+OC.linkTo('files_publiclink','get.php')+'?token='+token);
|
$('#link').val(parent.location.protocol+"//"+location.host+OC.linkTo('files_sharing','get.php')+'?token='+token);
|
||||||
$('#link').show('blind');
|
$('#link').show('blind');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue