Full support for making and deleting public links from share dropdown
This commit is contained in:
parent
8f01abf054
commit
843f8aca7c
4 changed files with 28 additions and 16 deletions
8
apps/files_publiclink/ajax/getlink.php
Normal file
8
apps/files_publiclink/ajax/getlink.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
$RUNTIME_NOAPPS = true;
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../lib_public.php');
|
||||
|
||||
$path = $_GET['path'];
|
||||
echo json_encode(OC_PublicLink::getLink($path));
|
|
@ -54,6 +54,12 @@ class OC_PublicLink{
|
|||
return $this->token;
|
||||
}
|
||||
|
||||
public static function getLink($path) {
|
||||
$query=OC_DB::prepare("SELECT token FROM *PREFIX*publiclink WHERE user=? AND path=? LIMIT 1");
|
||||
$result=$query->execute(array(OC_User::getUser(),$path))->fetchAll();
|
||||
return $result[0]['token'];
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all public links
|
||||
* @return array
|
||||
|
|
|
@ -5,6 +5,5 @@ require_once('../../../lib/base.php');
|
|||
require_once('../lib_share.php');
|
||||
|
||||
$source = "/".OC_User::getUser()."/files".$_GET['source'];
|
||||
error_log($source);
|
||||
echo json_encode(OC_Share::getMySharedItem($source));
|
||||
?>
|
|
@ -37,7 +37,8 @@ $(document).ready(function() {
|
|||
$('.permissions').live('change', function() {
|
||||
// TODO Modify item ajax call
|
||||
});
|
||||
$('.unshare').live('click', function() {
|
||||
$('.unshare').live('click', function(event) {
|
||||
event.preventDefault();
|
||||
var source = $('#dropdown').data('file');
|
||||
var uid_shared_with = $(this).data('uid_shared_with');
|
||||
var data='source='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with);
|
||||
|
@ -63,22 +64,22 @@ $(document).ready(function() {
|
|||
data: data,
|
||||
success: function(token) {
|
||||
if (token) {
|
||||
var link = OC.linkTo('files_publiclink','get.php')+'?token='+token;
|
||||
$('#link').data('token', token);
|
||||
$('#link').val('http://'+location.host+OC.linkTo('files_publiclink','get.php')+'?token='+token);
|
||||
$('#link').show('blind');
|
||||
$('#link').val(link);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var token = $(this).attr('data-token');
|
||||
var data = "token="+token;
|
||||
var token = $('#link').data('token');
|
||||
var data = 'token='+token;
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: OC.linkTo('files_publiclink','ajax/deletelink.php'),
|
||||
cache: false,
|
||||
data: data,
|
||||
success: function(){
|
||||
$('#token').hide('blind');
|
||||
$('#link').hide('blind');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -107,7 +108,7 @@ function createShareDropdown(filenames, files) {
|
|||
list += "<li>";
|
||||
list += row.uid_shared_with;
|
||||
list += "<input type='checkbox' name='permissions' data-uid_shared_with='"+row.uid_shared_with+"' /><label>can edit</label>";
|
||||
list += "<a href='#' title='Unshare' class='unshare' data-uid_shared_with='"+row.uid_shared_with+"'><img src='"+OC.imagePath('core','actions/delete')+"'/></a>";
|
||||
list += "<a href='' title='Unshare' class='unshare' data-uid_shared_with='"+row.uid_shared_with+"'><img src='"+OC.imagePath('core','actions/delete')+"'/></a>";
|
||||
list += "</li>";
|
||||
if (row.permissions > 0) {
|
||||
$('share_private_permissions').prop('checked', true);
|
||||
|
@ -117,16 +118,14 @@ function createShareDropdown(filenames, files) {
|
|||
$(list).appendTo('#shared_list');
|
||||
}
|
||||
});
|
||||
// TODO Create gettoken.php
|
||||
//$.getJSON(OC.linkTo('files_publiclink','ajax/gettoken.php'), { path: files }, function(token) {
|
||||
var token;
|
||||
$.getJSON(OC.linkTo('files_publiclink','ajax/getlink.php'), { path: files }, function(token) {
|
||||
if (token) {
|
||||
var link = OC.linkTo('files_publiclink','get.php')+'?token='+token;
|
||||
$('#makelink').attr('checked', true);
|
||||
$('#link').data('token', token);
|
||||
$('#link').val('http://'+location.host+OC.linkTo('files_publiclink','get.php')+'?token='+token);
|
||||
$('#link').show('blind');
|
||||
$('#link').val(link);
|
||||
}
|
||||
//});
|
||||
});
|
||||
$('#dropdown').show('blind');
|
||||
$('#dropdown').click(function(event) {
|
||||
event.stopPropagation();
|
||||
|
|
Loading…
Reference in a new issue