diff --git a/apps/files_publiclink/ajax/getlink.php b/apps/files_publiclink/ajax/getlink.php new file mode 100644 index 0000000000..551bcc8780 --- /dev/null +++ b/apps/files_publiclink/ajax/getlink.php @@ -0,0 +1,8 @@ +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 diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php index a074510363..580b6ca558 100644 --- a/apps/files_sharing/ajax/getitem.php +++ b/apps/files_sharing/ajax/getitem.php @@ -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)); ?> \ No newline at end of file diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 53057d8728..5538073d0f 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -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'); } }); } @@ -104,10 +105,10 @@ function createShareDropdown(filenames, files) { if (users) { var list = "