summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gapczynski <GapczynskiM@gmail.com>2011-08-05 11:18:35 -0400
committerMichael Gapczynski <GapczynskiM@gmail.com>2011-08-05 11:18:35 -0400
commit843f8aca7ce89e1aa3d7379a5f06c4e7f340c2c8 (patch)
tree3a98393f29ca676d9c8ab9ae60f3b52c2c146699
parent8f01abf054d577f923437871a3d6f873317c9544 (diff)
downloadnextcloud-server-843f8aca7ce89e1aa3d7379a5f06c4e7f340c2c8.tar.gz
nextcloud-server-843f8aca7ce89e1aa3d7379a5f06c4e7f340c2c8.zip
Full support for making and deleting public links from share dropdown
-rw-r--r--apps/files_publiclink/ajax/getlink.php8
-rw-r--r--apps/files_publiclink/lib_public.php8
-rw-r--r--apps/files_sharing/ajax/getitem.php1
-rw-r--r--apps/files_sharing/js/share.js27
4 files changed, 28 insertions, 16 deletions
diff --git a/apps/files_publiclink/ajax/getlink.php b/apps/files_publiclink/ajax/getlink.php
new file mode 100644
index 00000000000..551bcc8780c
--- /dev/null
+++ b/apps/files_publiclink/ajax/getlink.php
@@ -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)); \ No newline at end of file
diff --git a/apps/files_publiclink/lib_public.php b/apps/files_publiclink/lib_public.php
index ff1df130834..21286fe4ff2 100644
--- a/apps/files_publiclink/lib_public.php
+++ b/apps/files_publiclink/lib_public.php
@@ -53,7 +53,13 @@ class OC_PublicLink{
public function getToken(){
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
diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php
index a074510363f..580b6ca5585 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 53057d87285..5538073d0fb 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 = "<ul>";
$.each(users, function(index, row) {
- list += "<li>";
+ 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();