Initial merging of files_sharing and files_publiclink
This commit is contained in:
parent
9c3a836044
commit
582dca4d91
|
@ -136,23 +136,29 @@ $(document).ready(function() {
|
||||||
|
|
||||||
$('#makelink').live('change', function() {
|
$('#makelink').live('change', function() {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
var data = 'path='+$('#dropdown').data('file')+'&expire=0';
|
var source = $('#dropdown').data('file');
|
||||||
|
var uid_shared_with = "public";
|
||||||
|
var permissions = 0;
|
||||||
|
var data = 'sources='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with)+'&permissions='+encodeURIComponent(permissions);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'POST',
|
||||||
url: OC.linkTo('files_publiclink','ajax/makelink.php'),
|
url: OC.linkTo('files_sharing','ajax/share.php'),
|
||||||
cache: false,
|
cache: false,
|
||||||
data: data,
|
data: data,
|
||||||
success: function(token) {
|
success: function(result) {
|
||||||
if (token) {
|
if (result !== 'false') {
|
||||||
|
var token = 1234;
|
||||||
showPublicLink(token);
|
showPublicLink(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var data = 'token='+$('#link').data('token');
|
var source = $('#dropdown').data('file');
|
||||||
|
var uid_shared_with = "public";
|
||||||
|
var data = 'source='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: OC.linkTo('files_publiclink','ajax/deletelink.php'),
|
url: OC.linkTo('files_sharing','ajax/unshare.php'),
|
||||||
cache: false,
|
cache: false,
|
||||||
data: data,
|
data: data,
|
||||||
success: function(){
|
success: function(){
|
||||||
|
@ -207,11 +213,11 @@ function createDropdown(filename, files) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$.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) {
|
||||||
showPublicLink(token);
|
// showPublicLink(token);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
$('#dropdown').show('blind');
|
$('#dropdown').show('blind');
|
||||||
$('#share_with').chosen();
|
$('#share_with').chosen();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,9 @@ class OC_Share {
|
||||||
|
|
||||||
const WRITE = 1;
|
const WRITE = 1;
|
||||||
const DELETE = 2;
|
const DELETE = 2;
|
||||||
|
const PUBLICLINK = "public";
|
||||||
|
|
||||||
|
private $token;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Share an item, adds an entry into the database
|
* Share an item, adds an entry into the database
|
||||||
|
@ -39,6 +42,12 @@ class OC_Share {
|
||||||
*/
|
*/
|
||||||
public function __construct($source, $uid_shared_with, $permissions) {
|
public function __construct($source, $uid_shared_with, $permissions) {
|
||||||
$uid_owner = OC_User::getUser();
|
$uid_owner = OC_User::getUser();
|
||||||
|
$query = OC_DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)");
|
||||||
|
if ($uid_shared_with == self::PUBLICLINK) {
|
||||||
|
$token = sha1("$uid_shared_with-$source");
|
||||||
|
$query->execute(array($uid_owner, self::PUBLICLINK, $source, $token, $permissions));
|
||||||
|
$this->token = $token;
|
||||||
|
} else {
|
||||||
if (OC_Group::groupExists($uid_shared_with)) {
|
if (OC_Group::groupExists($uid_shared_with)) {
|
||||||
$gid = $uid_shared_with;
|
$gid = $uid_shared_with;
|
||||||
$uid_shared_with = OC_Group::usersInGroup($gid);
|
$uid_shared_with = OC_Group::usersInGroup($gid);
|
||||||
|
@ -79,10 +88,10 @@ class OC_Share {
|
||||||
if (isset($gid)) {
|
if (isset($gid)) {
|
||||||
$uid = $uid."@".$gid;
|
$uid = $uid."@".$gid;
|
||||||
}
|
}
|
||||||
$query = OC_DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)");
|
|
||||||
$query->execute(array($uid_owner, $uid, $source, $target, $permissions));
|
$query->execute(array($uid_owner, $uid, $source, $target, $permissions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove any duplicate or trailing '/' from the path
|
* Remove any duplicate or trailing '/' from the path
|
||||||
|
|
Loading…
Reference in New Issue