Functions to get the token of a public link now stored by OC_Share, remove no longer needed ajax call to getlink.php
This commit is contained in:
parent
0edce1796b
commit
b7b3a49203
|
@ -11,7 +11,10 @@ foreach ($sources as $source) {
|
||||||
if ($source && OC_FILESYSTEM::file_exists($source) && OC_FILESYSTEM::is_readable($source)) {
|
if ($source && OC_FILESYSTEM::file_exists($source) && OC_FILESYSTEM::is_readable($source)) {
|
||||||
$source = "/".OC_User::getUser()."/files".$source;
|
$source = "/".OC_User::getUser()."/files".$source;
|
||||||
try {
|
try {
|
||||||
new OC_Share($source, $uid_shared_with, $permissions);
|
$shared = new OC_Share($source, $uid_shared_with, $permissions);
|
||||||
|
if ($uid_shared_with == OC_Share::PUBLICLINK) {
|
||||||
|
echo $shared->getToken();
|
||||||
|
}
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
echo "false";
|
echo "false";
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,9 +145,8 @@ $(document).ready(function() {
|
||||||
url: OC.linkTo('files_sharing','ajax/share.php'),
|
url: OC.linkTo('files_sharing','ajax/share.php'),
|
||||||
cache: false,
|
cache: false,
|
||||||
data: data,
|
data: data,
|
||||||
success: function(result) {
|
success: function(token) {
|
||||||
if (result !== 'false') {
|
if (token) {
|
||||||
var token = 1234;
|
|
||||||
showPublicLink(token);
|
showPublicLink(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +204,10 @@ function createDropdown(filename, files) {
|
||||||
$.getJSON(OC.linkTo('files_sharing', 'ajax/getitem.php'), { source: files }, function(users) {
|
$.getJSON(OC.linkTo('files_sharing', 'ajax/getitem.php'), { source: files }, function(users) {
|
||||||
if (users) {
|
if (users) {
|
||||||
$.each(users, function(index, row) {
|
$.each(users, function(index, row) {
|
||||||
if (isNaN(index)) {
|
if (row.uid_shared_with == 'public') {
|
||||||
|
var token = 1234;
|
||||||
|
showPublicLink(token);
|
||||||
|
} 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 {
|
||||||
addUser(row.uid_shared_with, row.permissions, false);
|
addUser(row.uid_shared_with, row.permissions, false);
|
||||||
|
@ -213,11 +215,6 @@ function createDropdown(filename, files) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// $.getJSON(OC.linkTo('files_publiclink', 'ajax/getlink.php'), { path: files }, function(token) {
|
|
||||||
// if (token) {
|
|
||||||
// showPublicLink(token);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
$('#dropdown').show('blind');
|
$('#dropdown').show('blind');
|
||||||
$('#share_with').chosen();
|
$('#share_with').chosen();
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,6 +276,29 @@ class OC_Share {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the token for a public link
|
||||||
|
* @return The token of the public link, a sha1 hash
|
||||||
|
*/
|
||||||
|
public function getToken() {
|
||||||
|
return $this->token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the token for a public link
|
||||||
|
* @param $source The source location of the item
|
||||||
|
* @return The token of the public link, a sha1 hash
|
||||||
|
*/
|
||||||
|
public static function getTokenFromSource($source) {
|
||||||
|
$query = OC_DB::prepare("SELECT target FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with = ? AND uid_owner = ? LIMIT 1");
|
||||||
|
$result = $query->execute(array($source, self::PUBLICLINK, OC_User::getUser()))->fetchAll();
|
||||||
|
if (count($result) > 0) {
|
||||||
|
return $result[0]['target'];
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the source location to a new value
|
* Set the source location to a new value
|
||||||
* @param $oldSource The current source location
|
* @param $oldSource The current source location
|
||||||
|
|
Loading…
Reference in New Issue